forked from datamllab/rlcard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_dmc.py
99 lines (89 loc) · 2.3 KB
/
run_dmc.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
''' An example of training a Deep Monte-Carlo (DMC) Agent on the environments in RLCard
'''
import os
import argparse
import torch
import rlcard
from rlcard.agents.dmc_agent import DMCTrainer
def train(args):
# Make the environment
env = rlcard.make(args.env)
# Initialize the DMC trainer
trainer = DMCTrainer(
env,
cuda=args.cuda,
load_model=args.load_model,
xpid=args.xpid,
savedir=args.savedir,
save_interval=args.save_interval,
num_actor_devices=args.num_actor_devices,
num_actors=args.num_actors,
training_device=args.training_device,
)
# Train DMC Agents
trainer.start()
if __name__ == '__main__':
parser = argparse.ArgumentParser("DMC example in RLCard")
parser.add_argument(
'--env',
type=str,
default='getaway',
choices=[
'blackjack',
'leduc-holdem',
'limit-holdem',
'doudizhu',
'mahjong',
'no-limit-holdem',
'uno',
'gin-rummy',
'getaway'
],
)
parser.add_argument(
'--cuda',
type=str,
default='',
)
parser.add_argument(
'--load_model',
action='store_true',
help='Load an existing model',
)
parser.add_argument(
'--xpid',
default='leduc_holdem',
help='Experiment id (default: leduc_holdem)',
)
parser.add_argument(
'--savedir',
default='experiments/dmc_result',
help='Root dir where experiment data will be saved'
)
parser.add_argument(
'--save_interval',
default=30,
type=int,
help='Time interval (in minutes) at which to save the model',
)
parser.add_argument(
'--num_actor_devices',
default=1,
type=int,
help='The number of devices used for simulation',
)
parser.add_argument(
'--num_actors',
default=5,
type=int,
help='The number of actors for each simulation device',
)
parser.add_argument(
'--training_device',
default="0",
type=str,
help='The index of the GPU used for training models',
)
args = parser.parse_args()
os.environ["CUDA_VISIBLE_DEVICES"] = args.cuda
train(args)