-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_agent.py
More file actions
52 lines (41 loc) · 1.26 KB
/
random_agent.py
File metadata and controls
52 lines (41 loc) · 1.26 KB
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
48
49
50
51
52
'''
RANDOM AGENT
'''
import time
import random
class agent:
def __init__(self, player_num, env):
self.name = "random bot"
self.player_num = player_num
self.env = env
'''
This might need to be added in future
# This is the case if the player wants to decide on some actions before
#the start of the game
self.board = solid_state["board"]
self.done = solid_state["done"]
self.bombs = solid_state["bombs"]
self.turn = solid_state["turn"]
self.player = solid_state["players"][self.player_num-1]
'''
def give_next_move(self, solid_state):
'''
This method is called each time the player needs to choose an
action
solid_state: is a dictionary containing all the information about the board
'''
#transfering a single solid_state
self.board = solid_state["board"]
self.done = solid_state["done"]
self.bombs = solid_state["bombs"]
self.turn = solid_state["turn"]
self.player = solid_state["players"][self.player_num-1]
#actions = [0,1,2,3,4]
actions =[0,1,2,3,4,5]
action = random.choice(actions)
#I want to delay more than half of the times
#random.seed(1)
waitTime = 1 + (3*random.random())
##waitTime = 2
#time.sleep(waitTime)
return action