-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathagent.py
33 lines (27 loc) · 885 Bytes
/
agent.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
The intelligent agent
see flipped_agent for an example of how to flip the board in order to always
perceive the board as player 1
"""
import numpy as np
import Backgammon
def action(board_copy,dice,player,i):
# the champion to be
# inputs are the board, the dice and which player is to move
# outputs the chosen move accordingly to its policy
# check out the legal moves available for the throw
possible_moves, possible_boards = Backgammon.legal_moves(board_copy, dice, player)
# if there are no moves available
if len(possible_moves) == 0:
return []
# make the best move according to the policy
# policy missing, returns a random move for the time being
#
#
#
#
#
move = possible_moves[np.random.randint(len(possible_moves))]
return move