Question: Part 1 : Action Enumeration and Validation Next, you will need to enumerate the possible actions that a player can take from a given board

Part 1: Action Enumeration and Validation
Next, you will need to enumerate the possible actions that a player can take from a given board configuration state. As a reminder, players can only move their own pieces. This part has 4 subparts, highlighted in bolded italic. For parts A and B, return a valid set of encoded positions the piece is allowed to move to for this turn.
A. Implement Rules.single_piece_actions(board_state, piece_idx: int) Enumerate a single block pieces possible action. Given a BoardState and a piece_idx that is an index into the encoded board_state.state, return the set of actions that piece can take. In this part of the problem, we are interested only in the block pieces, not the ball pieces, so assume that piece_idx will only ever refer to block pieces.
B. Implement Rules.single_ball_actions(board_state, player_idx: int) Enumerate a single ball pieces possible actions. This is similar to part (A), except we are interested in the possible actions that can be taken with the ball.
C. Implement GameSimulator.generate_valid_actions(self, player_idx: int) Enumerate all the valid actions for a player given a board configuration. For this part, return the set of valid actions that the player can take. An action here is encoded as a tuple (relative_idx, position), as described in the code handout.
D. Implement GameSimulator.validate_action(self, action: tuple, player_idx: int) Action validation. For this part, return True only if the action is valid; otherwise you must raise a ValueError(with a description about why this action is not valid).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!