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

Probably a bug in mahjong/game.py step_back() #193

Open
196693 opened this issue Dec 10, 2020 · 2 comments
Open

Probably a bug in mahjong/game.py step_back() #193

196693 opened this issue Dec 10, 2020 · 2 comments
Assignees

Comments

@196693
Copy link

196693 commented Dec 10, 2020

在 麻将的 Game.py 中 有 round, dealer 这俩对象, round当中又包含一个dealer,在init_game当中 先实例化了一个dealer ,然后把指针传给了 round
但是在开启了step_back之后,在step当中会用deepcopy存一下之前的内容,在step_back函数中,仅仅用了一个pop,此时的game.dealer 和 game.round.dealer 就对不上了。 所以在用cfrAgent的时候会出现错误。

目前我在step_back当中,简单改了一下

self.dealer, self.players, self.round = self.history.pop()
self.round.dealer = self.dealer
self.round.judger = self.judger

judger这个不知道有没有必要。不过正如另一个issue所说,麻将这里面有一些redundancy,优化完了就不用这样啦。

Plus: 这个CFR也太慢了

@jkterry1
Copy link
Contributor

@daochenzha Just following up on this

@kaanozdogru
Copy link
Contributor

I think in the step_back function, simply the line
self.dealer, self.players, self.round = self.history.pop()
is enough and the lines

self.round.dealer = self.dealer
self.round.judger = self.judger

are unnecessary because when we do the pop, we also get the previous state of self.round, which contains the previous state self.round.dealer and this should already be the same as the previous state of self.dealer. Since in each step function, self.round.dealer is updated as well self.dealer and they match, self.round.dealer contained in the deepcopy of self.round and deepcopy of self.dealer also match. Consequently using pop will get you those previous states and there will be no mismatch between self.dealer and self.round.dealer.

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

4 participants