sotetsuk / pgx

♟️ Vectorized RL game environments in JAX (NeurIPS23)
http://sotets.uk/pgx/
Apache License 2.0
404 stars 25 forks source link

[Animal Shogi] Modify the move of GOLD in animal_shogi.py #1209

Closed KazukiOhta closed 2 months ago

KazukiOhta commented 2 months ago

Description

The current implementation of animal_shogi.py checks the reach of GOLD with following expression.

is_neighbour & ((dx != 0) | (dy != +1))

This means the following reach.

***
*G*
* *

However, the correct reach of GOLD is the following.

***
*G*
 * 

Proposal

Therefore, I propose to modify the expression as follows.

is_neighbour & ((dx == 0) | (dy != +1))

Bug Example

I found this bug because of the following move of white gold, which led to mate.

screenshot 2024-08-23 14 43 45screenshot 2024-08-23 14 43 59

KazukiOhta commented 2 months ago

By the way, the images show that there are three rooks (one at B4 and two in white hand), because of the issue https://github.com/sotetsuk/pgx/pull/1208 .

sotetsuk commented 2 months ago

Hi! Thank you for your PR! 🙏 Great 👍

Could you kindly add a simple test under def test_buggy_samples(): (please add if not exists)? Chees, Go, and Shogi have such tests for buggy examples.

KazukiOhta commented 2 months ago

Hi, thank you for your kind reply.

I added def test_buggy_samples() in test_animal_shogi.py. The test checks the legal_action_mask of white GOLD at the following state.

screenshot 2024-08-25 12 45 45

The expected mask of white GOLD is the following.

Go Down      : OK
Go Down Left : NG
Go Left      : OK
sotetsuk commented 2 months ago

Thank you so much! 🙏 I will review it next week 🙏

KazukiOhta commented 2 months ago

Thank you!

sotetsuk commented 2 months ago

@KazukiOhta Thank you for PR! I added minor comments. I'll merge this PR after these comments are applied and pass the CI.


I applied the comments fromcommit suggestion button

sotetsuk commented 2 months ago

Also, I'll release a new version 2.2.0 after this PR is merged

KazukiOhta commented 2 months ago

Thank you again for your kind review. I am looking forward to the new version!