Commit cb324901 authored by sbl1996@126.com's avatar sbl1996@126.com

Debug seed

parent b5d92a22
......@@ -596,11 +596,16 @@ def main():
args.ckpt_dir, save_fn, n_saved=2)
# seeding
seed_offset = args.local_rank
args.seed += seed_offset
random.seed(args.seed)
seed = random.randint(0, 1e8)
seed_offset = args.local_rank
seed += seed_offset
init_key = jax.random.PRNGKey(seed - seed_offset)
random.seed(seed)
args.real_seed = random.randint(0, 1e8)
init_key = jax.random.PRNGKey(args.seed - seed_offset)
key = jax.random.PRNGKey(args.real_seed)
key, *learner_keys = jax.random.split(key, len(learner_devices) + 1)
learner_keys = jax.device_put_sharded(learner_keys, devices=learner_devices)
......
......@@ -1501,7 +1501,13 @@ public:
if (input == "quit") {
exit(0);
}
int idx = std::stoi(input) - 1;
int idx = -1;
try {
idx = std::stoi(input) - 1;
} catch (std::invalid_argument &e) {
fmt::println("{} Invalid input: {}", duel_player_, input);
continue;
}
if (idx >= 0 && idx < actions.size()) {
return idx;
} else {
......@@ -1720,6 +1726,7 @@ public:
throw std::runtime_error("record mode must be used with verbose mode and num_envs=1");
}
}
fmt::println("env_id: {}, seed: {}, x: {}", env_id_, seed_, dist_int_(gen_));
duel_gen_ = std::mt19937(dist_int_(gen_));
......@@ -4158,10 +4165,13 @@ private:
for (const auto &card : cards) {
auto spec = card.get_spec(player);
specs.push_back(spec);
int i = specs.size();
if (card.controler_ != player && card.position_ & POS_FACEDOWN) {
pl->notify(spec + ": " + card.get_position() + " card");
pl->notify(
fmt::format("{}: {} card ({})", i, card.get_position(), spec));
} else {
pl->notify(spec + ": " + card.name_);
pl->notify(
fmt::format("{}: {} ({})", i, card.name_, spec));
}
}
} else {
......@@ -4242,7 +4252,8 @@ private:
for (const auto &card : cards) {
auto spec = card.get_spec(player);
specs.push_back(spec);
pl->notify(spec + ": " + card.name_);
pl->notify(
fmt::format("{}: {} ({})", specs.size(), card.name_, spec));
}
} else {
for (int i = 0; i < size; ++i) {
......@@ -4369,7 +4380,8 @@ private:
for (const auto &card : select) {
auto spec = card.get_spec(player);
select_specs.push_back(spec);
pl->notify(spec + ": " + card.name_);
pl->notify(
fmt::format("{}: {} ({})", select_specs.size(), card.name_, spec));
}
} else {
for (int i = 0; i < select_size; ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment