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

'list' object has no attribute 'drop' #6

Open
Leci37 opened this issue Jun 9, 2023 · 1 comment
Open

'list' object has no attribute 'drop' #6

Leci37 opened this issue Jun 9, 2023 · 1 comment

Comments

@Leci37
Copy link

Leci37 commented Jun 9, 2023

Thank very much for your public work, I am learing RL , my friend recomented this project

When I runing in it

import gym
import gym_chess
import random

env = gym.make('Chess-v0')
print(env.render())

env.reset()
done = False

while not done:
    action =   random.sample(env.legal_moves, 10)
    env.step(action)
    print(env.render(mode='unicode'))

env.close()

I recive this error

Traceback (most recent call last):
  File "C:\Users\Luis\Documents\GitHub\gym-chess\start.py", line 13, in <module>
    env.step(action)
  File "C:\Users\Luis\Documents\GitHub\gym-chess\gym_chess\envs.py", line 97, in step
    if action not in self._board.legal_moves:
  File "C:\Users\Luis\.conda\envs\RLhaha\lib\site-packages\chess\__init__.py", line 3554, in __contains__
    return self.board.is_legal(move)
  File "C:\Users\Luis\.conda\envs\RLhaha\lib\site-packages\chess\__init__.py", line 1659, in is_legal
    return not self.is_variant_end() and self.is_pseudo_legal(move) and not self.is_into_check(move)
  File "C:\Users\Luis\.conda\envs\RLhaha\lib\site-packages\chess\__init__.py", line 1615, in is_pseudo_legal
    if move.drop:
AttributeError: 'list' object has no attribute 'drop'

Process finished with exit code 1
@iamlucaswolf
Copy link
Owner

HI @Leci37 , thank you for using gym-chess.

random.sample returns a list, but env.step only takes a single action at a time. If you look at the README, I've included a code example that plays a game with random moves.

Let me know if that helps. Cheers! 😊

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

2 participants