I am trying to find a solution to this board game problem this is how it goes.
Mike and Bob are playing a board game on an m by n board. The board has at least 3 rows and 3 columns. The bottom row is row 0 and the top row is row m − 1; the left-most column is column 0 and the right-most column is column n − 1.
Mike moves first, then Bob, then Mike, then Bob, etc. until the game is over. The game is over when one of two things happens: Bob wins or Mike wins.
- Bob wins if he lands on the same square as Mike before Mike reaches the top row. Note that this winning condition is checked only after Bob moves; Bob can never win right after Mike moves, even if Mike lands on the same square as Bob
- Mike wins if Mike reaches the top row before Bob wins, i.e., Mike reaches the top row without Bob ever landing on the same square as Mike. As soon as Mike reaches the top row, Mike wins (Bob cannot move anymore).
Mike’s move on each turn is fixed according to the following rule: he goes 1 square up and then, if not already at the right edge, goes 1 square to the right as well.
Bob, by contrast, has eight choices of move to make on his turn:
- 1 up, 2 right
- 1 up, 2 left
- 1 down, 2 right
- 1 down, 2 left
- 2 up, 1 right
- 2 up, 1 left
- 2 down, 1 right
- 2 down, 1 left
Note that some moves may be unavailable depending on Bob’s location; for example, if Bob is already in column n − 1, then any move that tries to go to the right is not allowed.
Given the starting locations of Mike and Bod, come up with a solution that determines the result of the game, as follows:
- If it is possible for Bob to win, then report that Bob can win and give the minimum number of Bob moves required for him to win.
- Otherwise, Mike wins; report the number of Bob moves that occur before Mike wins
we can assume that
- Mike’s starting location is never in the top row
- Bob’s starting location is never the same as Mike’s
we can use any type of methods we like, the only real restriction to solving this problem are mentioned above. How would we approach a question like this.