From 5944ed9a4e6f617bcbd65a929001bc19b0b2de1f Mon Sep 17 00:00:00 2001 From: Paulina Nowak Date: Wed, 23 Dec 2020 20:21:46 +0100 Subject: [PATCH] sasa --- main.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 3ad5f86..ef6040d 100644 --- a/main.py +++ b/main.py @@ -11,13 +11,20 @@ from random import choice class TicTacToe: + """ + uruchamia program, gracze wykonuja na zmiane ruchy, + az do osiagniecia wygranej przez jednego z nich + """ + + def run(self): + +class Board: 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) def make_move(self, token, field): @@ -26,38 +33,33 @@ class TicTacToe: else: print("This field's taken.") + def get_state(): + pass + + def get_action(): + pass + class Player: def __init__(self, token): self.token = token def make_random_move(self, state): - sequence = ["X", "O"] emptyField = True while emptyField: field = state[randint(0,8)] if field == " ": - state[field] = choice(sequence) - emptyField = False + return -player = Player("X") -player1 = Player("O") +player1 = Player("X") +player2 = Player("O") game = TicTacToe() -game.print() +game.run() for x in range(1,10): player.make_random_move(game.state) game.print() player1.make_random_move(game.state) 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) \ No newline at end of file