Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有没有必要设置size变量 #32

Closed
yffbit opened this issue Sep 10, 2021 · 3 comments
Closed

有没有必要设置size变量 #32

yffbit opened this issue Sep 10, 2021 · 3 comments

Comments

@yffbit
Copy link
Contributor

yffbit commented Sep 10, 2021

为什么不直接用 len(obs_z_buf)
而且执行 position, obs, env_output = env.step(action) 后, position 指向下一个玩家,加1加错地方了

position, obs, env_output = env.step(action)
size[position] += 1

@daochenzha
Copy link
Collaborator

@yffbit 确实可以用len(obs_z_buf[position])。对于第二个问题这里的position是字典,在['landlord', 'landlord_up', 'landlord_down']中取值,所以不是加1

@yffbit
Copy link
Contributor Author

yffbit commented Sep 11, 2021

@yffbit 确实可以用len(obs_z_buf[position])。对于第二个问题这里的position是字典,在['landlord', 'landlord_up', 'landlord_down']中取值,所以不是加1

我说的是 size[position] += 1 这里 position指向下一个玩家,应该是上一个玩家对应的数据个数+1。要么把这一行代码放在 env.step(action) 之前,要么删除 size 变量,用 len(obs_z_buf[position]) 代替

obs_x_no_action_buf[position].append(env_output['obs_x_no_action'])
obs_z_buf[position].append(env_output['obs_z'])
with torch.no_grad():
agent_output = model.forward(position, obs['z_batch'], obs['x_batch'], flags=flags)
_action_idx = int(agent_output['action'].cpu().detach().numpy())
action = obs['legal_actions'][_action_idx]
obs_action_buf[position].append(_cards2tensor(action))
position, obs, env_output = env.step(action)
size[position] += 1

@daochenzha
Copy link
Collaborator

@yffbit 确实应该放在env.step(action)前更好。不过我觉得其实是等价的。现在的写法下,首先地主的第一手牌是不会计数的。如果size[position] += 1后游戏没结束,那么下个玩家一定会打,相当于给下一个玩家计数。如果size[position] += 1后游戏结束,那么下一个玩家一定是地主,相当于把之间地主第一手牌补上了。我会把它放在env.step(action)前,感谢反馈。

@karoka karoka closed this as completed Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants