oeo
This commit is contained in:
parent
4ad4eff06a
commit
89c4a92d72
33
main.py
33
main.py
@ -6,14 +6,33 @@
|
||||
| |
|
||||
|
||||
"""
|
||||
def print_board(state):
|
||||
board = ""+ state[0] +"|"+ state[1] +"|"+ state[2] +" \n-|-|-\n"+ state[3] +"|"+ state[4] +"|"+ state[5] +"\n-|-|-\n"+ state[6] +"|"+ state[7] +"|"+ state[8] +"\n"
|
||||
|
||||
print(board)
|
||||
class TicTacToe:
|
||||
def __init__(self):
|
||||
self.state = list(" "*9)
|
||||
|
||||
state = list(" "*9)
|
||||
|
||||
print_board(state)
|
||||
def print(self):
|
||||
board = ""+ self.state[0] +"|"+self.state[1] +"|"+self.state[2] +" \n-|-|-\n"+self.state[3] +"|"+self.state[4] +"|"+self.state[5] +"\n-|-|-\n"+self.state[6] +"|"+self.state[7] +"|"+self.state[8] +"\n"
|
||||
|
||||
state[0] = "X"
|
||||
print_board(state)
|
||||
print(board)
|
||||
|
||||
def make_move(self, token, field):
|
||||
if self.state[field] == " ":
|
||||
self.state[field] = token
|
||||
else:
|
||||
print("This field's taken.")
|
||||
|
||||
|
||||
game = TicTacToe()
|
||||
game.print()
|
||||
|
||||
game.make_move("X", 0)
|
||||
game.print()
|
||||
|
||||
# make_move(state, "X", 0)
|
||||
# print_board(state)
|
||||
# make_move(state, "O", 3)
|
||||
# print_board(state)
|
||||
# make_move(state, "X", 0)
|
||||
# print_board(state)
|
Loading…
Reference in New Issue
Block a user