Skip to content

Instantly share code, notes, and snippets.

View annh3's full-sized avatar
🎯
Focusing

Ann He annh3

🎯
Focusing
View GitHub Profile
@annh3
annh3 / game.py
Created February 22, 2024 11:49
tic tac toe game
class Game:
def __init__(self, nrounds: int=1):
self.board = [[-1]*3 for _ in range(3)]
self.nrounds = nrounds
self.turn = 0 # either player 0 or 1
self.player_scores = {0:0, 1:0}
def check_valid_position(self, x: int, y: int) -> bool:
"""Check that the location is in bounds and empty."""
return x >= 0 and x < 3 and y >= 0 and y < 3 and self.board[x][y] == -1

Keybase proof

I hereby claim:

  • I am annh3 on github.
  • I am annhe (https://keybase.io/annhe) on keybase.
  • I have a public key ASBxEwgvkXvnEkkY8XK0fpkumEuzhL0dINtg2O-f0zTKFQo

To claim this, I am signing this object: