-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_main.py
34 lines (31 loc) · 1020 Bytes
/
example_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
from grid import *
import random
def main():
grids = [grid(), grid(), grid()]
current_player = J1
grids[J1].display()
while grids[0].gameOver() == -1:
if current_player == J1:
shot = -1
while shot <0 or shot >=NB_CELLS:
shot = int(input ("quel case allez-vous jouer ?"))
else:
shot = random.randint(0,8)
while grids[current_player].cells[shot] != EMPTY:
shot = random.randint(0,8)
if (grids[0].cells[shot] != EMPTY):
grids[current_player].cells[shot] = grids[0].cells[shot]
else:
grids[current_player].cells[shot] = current_player
grids[0].play(current_player, shot)
current_player = current_player%2+1
if current_player == J1:
grids[J1].display()
print("game over")
grids[0].display()
if grids[0].gameOver() == J1:
print("You win !")
else:
print("you loose !")
main()