-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirst_choice_player.py
47 lines (35 loc) · 1.56 KB
/
first_choice_player.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
35
36
37
38
39
40
41
42
43
44
45
46
47
from santorinai.player import Player
from santorinai.board import Board
from santorinai.pawn import Pawn
class FirstChoicePlayer(Player):
"""
A player that places his pawns and moves them at the first possible position
"""
def __init__(self, player_number, log_level=0) -> None:
super().__init__(player_number, log_level)
def name(self):
return "Firsty First"
def place_pawn(self, board: Board, pawn: Pawn):
available_positions = board.get_possible_movement_positions(pawn)
my_choice = available_positions[0]
return my_choice
def play_move(self, board: Board):
# Choose always first pawn
l_pawns = board.get_player_pawns(self.player_number)
pawn = l_pawns[0]
# Get movement positions
available_move_positions = board.get_possible_movement_positions(pawn)
if len(available_move_positions) == 0:
# The pawn cannot move
return pawn.order, None, None
my_move_choice = available_move_positions[0]
# Simulate the move (Need to use pawn copy since returned pawn will be moved)
pawn.move(my_move_choice)
# Get construction positions
available_build_positions = board.get_possible_building_positions(pawn)
if len(available_build_positions) == 0:
# The pawn cannot build
raise Exception("Pawn cannot build")
# Their is always at least one position available
my_build_choice = available_build_positions[0]
return pawn.order, my_move_choice, my_build_choice