forked from wenkesj/holdem
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlocal_example.py
79 lines (57 loc) · 2.51 KB
/
local_example.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import gym
import holdem
import agent
def lets_play(env, n_seats, model_list):
while True:
cur_state = env.reset()
env.render(mode='human')
cycle_terminal = False
# (cur_state)
if env.episode_end:
break
while not cycle_terminal:
# play safe actions, check when no one else has raised, call when raised.
# print(">>> Debug Information ")
# print("state(t)")
# for p in cur_state.player_states:
# print(p)
# print(cur_state.community_state)
actions = holdem.model_list_action(cur_state, n_seats=n_seats, model_list=model_list)
cur_state, rews, cycle_terminal, info = env.step(actions)
# print("action(t), (CALL=1, RAISE=2, FOLD=3 , CHECK=0, [action, amount])")
# print(actions)
# print("reward(t+1)")
# print(rews)
# print("<<< Debug Information ")
env.render(mode="human")
# print("final state")
# print(cur_state)
# total_stack = sum([p.stack for p in env._seats])
# if total_stack != 10000:
# return
print("Episode End!!!")
env = gym.make('TexasHoldem-v2') # holdem.TexasHoldemEnv(2)
model_list = list()
# start with 4 players
env.add_player(0, stack=1000) # add a player to seat 0 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(1, stack=1000) # add another player to seat 1 with 2000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(2, stack=1000) # add another player to seat 2 with 3000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(3, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(4, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(5, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(6, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allCallModel())
env.add_player(7, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(8, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allFoldModel())
env.add_player(9, stack=1000) # add another player to seat 3 with 1000 "chips"
model_list.append(agent.allinModel())
# play out a hand
lets_play(env, env.n_seats, model_list)