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 : 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 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.singlepieceactionsboardstate, pieceidx: int Enumerate a single block pieces possible action. Given a BoardState and a pieceidx that is an index into the encoded boardstate.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 pieceidx will only ever refer to block pieces.
B Implement Rules.singleballactionsboardstate, playeridx: 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.generatevalidactionsself playeridx: 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 relativeidx, position as described in the code handout.
D Implement GameSimulator.validateactionself action: tuple, playeridx: int Action validation. For this part, return True only if the action is valid; otherwise you must raise a ValueErrorwith 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
