-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (24 loc) · 913 Bytes
/
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
import random
from game import Game, Move, Player
class RandomPlayer(Player):
def __init__(self) -> None:
super().__init__()
def make_move(self, game: 'Game') -> tuple[tuple[int, int], Move]:
from_pos = (random.randint(0, 4), random.randint(0, 4))
move = random.choice([Move.TOP, Move.BOTTOM, Move.LEFT, Move.RIGHT])
return from_pos, move
class MyPlayer(Player):
def __init__(self) -> None:
super().__init__()
def make_move(self, game: 'Game') -> tuple[tuple[int, int], Move]:
from_pos = (random.randint(0, 4), random.randint(0, 4))
move = random.choice([Move.TOP, Move.BOTTOM, Move.LEFT, Move.RIGHT])
return from_pos, move
if __name__ == '__main__':
g = Game()
#g.print()
player1 = MyPlayer()
player2 = RandomPlayer()
winner = g.play(player1, player2)
#g.print()
print(f"Winner: Player {winner}")