oeo
This commit is contained in:
parent
4ad4eff06a
commit
89c4a92d72
31
main.py
31
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"
|
class TicTacToe:
|
||||||
|
def __init__(self):
|
||||||
|
self.state = list(" "*9)
|
||||||
|
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
print(board)
|
print(board)
|
||||||
|
|
||||||
state = list(" "*9)
|
def make_move(self, token, field):
|
||||||
|
if self.state[field] == " ":
|
||||||
|
self.state[field] = token
|
||||||
|
else:
|
||||||
|
print("This field's taken.")
|
||||||
|
|
||||||
print_board(state)
|
|
||||||
|
|
||||||
state[0] = "X"
|
game = TicTacToe()
|
||||||
print_board(state)
|
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