generated from mwc/lab_tic_tac_toe
623 B
623 B
Tic Tac Toe Lab Assessment
Everything's done--nice work!
Checkpoint 1
Looks good.
Checkpoint 2
This works! It probably felt a bit tedious. If I were trying to do this elegantly, I'd probably start by separating the data from the algorithm. Then, there are a number of python builtin functions and idioms which I'd reach for:
combos = [
[0, 1, 2],
[3, 4, 5],
...
]
is_symbol = lambda index: state['board'][index] == symbol
return any(all(map(is_symbol, combo)) for combo in combos)
Happy to explain what's going on here if you have trouble figuring it out :)
Checkpoint 3
Looks good.