Question: Write a matlab code to satisfy the following function conditions Function Name: checkers Inputs: (char) An M times N array representing a checkerboard Outputs: (double)
Write a matlab code to satisfy the following function conditions
Function Name: checkers Inputs: (char) An M times N array representing a checkerboard Outputs: (double) The number of possible jumps Function Description: Since we love games so much, let's analyze a checkerboard! Assume you are the player with red pieces, and it's your turn. Given a checkerboard where the capital letter 'O' represents empty spaces, 'R' represents red kings, 'r' represents red regular pieces, and 'b' represents any black piece, calculate the number of single jumps that can be made by moving any movable red pieces. In other words, how many possible jumps could you choose from on the next move? All pieces jump forward (up) diagonally. Kings can also jump backwards diagonally. If there is a black piece immediately across the red piece on the diagonal, and the other side is an empty space, a jump can take place. For example, if a king is able to jump forward-left, forward-right, backwards-left and backwards-right diagonally over four different black pieces, that is counted as 4 possible jumps for just that one king. If you are still confused, here are some simple rules
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
