Closed wei-ann-Github closed 1 year ago
@WillDudley can you take a look? Thanks!
Hi @wei-ann-Github, seems like pettingzoo includes an "action_mask"
key for the mask, but tianshou expects a "mask"
key instead.
The simple solution would probably be to add observation["mask"] = observation["action_mask"]
somewhere in the code.
Disclaimer: I haven't tested this code nor have extensive experience with TianShou, but it seems like this is what's going on. If you could post your full file implementation somewhere, that would probably help. For example, observation['obs'] = observation['obs'].reshape(-1, int(np.prod(state_shape)))
shouldn't have worked since PZ's tictactoe only issues an "observation"
key and not an "obs"
key.
Hi, have you solve the problem. I face the same concern. When I intentional made an illegal action in Tictactoe, a warning occured (see below). But I didn't see the action mask code either in Tianshou or the environment.
[WARNING]: Illegal move made, game terminating with current player losing. obs['action_mask'] contains a mask of all legal moves that can be chosen.
Versions: 0.4.10 0.26.3 1.13.1+cu117 1.23.5 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03)
Hi,
I followed the script https://github.com/Farama-Foundation/PettingZoo/blob/master/tutorials/Tianshou/2_training_agents.py to train a tictactoe agent. After training the model, I tried to play against the trained agent, but it seems that the agent is making illegal moves. My code
The game:
I've checked the mask. It looks correct.
Anyone able to help?