I am new to ML and I need to train a chess agent using proximal policy optimization. Board is represented as string and the environment gives a list of valid moves for each step.

# Set your environment parameters
input_size = 64  # Assuming a flat representation of the chess board as input
output_size = len(legal_moves)  # Number of legal moves in your chess environment

# Initialize the PPO agent
agent = PPOAgent(input_size, output_size)

At the beginning, there is this initialization of the agent with the number of valid moves at the beginning of the game as output layer size. However, in each time step, valid move size changes and how to represent and/or specify in the implementation?


1 Answer 1


I found a really broad and good answer to your question in this post on AI StackExchange. In general, a method is to always serve all possible actions in output and map huge negative values on these ones which are not allowed to be rejected in use by your agent.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.