Question: Write a program that lets a user play the game of MovingDay. Here are the rules of the game: - there are N Falses on

Write a program that lets a user play the game of MovingDay. Here are the rules of the game:

- there are N Falses on N squares, M Trues on M squares, and one empty square for a total of N + M + 1 squares

- the Falses start out on the right, the Trues start out on the left, the empty square is in the middle

- there are two moves JUMP and SLIDE

- a False can JUMP over a True or False onto an empty square

- a True can JUMP over a False onto an empty square

- a False or True can slide onto an empty square

- Falses can ONLY move left, Trues can ONLY move right

- the user WINS when the Falses occupy the left most N squares, the Trues occupy the rightmost M squares, and the empty square is in the middle

- the user LOSES when the user can't make any more moves and the winning condition hasn't been satisfied

Sample run (bold indicates user input):

---- MovingDay Game ----

Number of Falses: 3

Number of Trues: 3

0 1 2 3 4 5 6

| T | T | T | | F | F | F |

Choose move: 4

Sliding False @ 4 to the LEFT

0 1 2 3 4 5 6

| T | T | T | F | | F | F |

Choose move: 2

Jumping True @ 2 to the RIGHT

0 1 2 3 4 5 6

| T | T | | F | T | F | F |

Choose move: 0

Cannot Jump True over a True!

Choose move: 1

Sliding True @ 1 to the RIGHT

0 1 2 3 4 5 6

| T | | T | F | T | F | F |

Choose move: 2

Cannot Slide True (no empty space).

Cannot Jump True (no empty space).

Choose move: 0

Sliding True @ 0 to the RIGHT

0 1 2 3 4 5 6

| | T | T | F | T | F | F |

Choose move: 0

Sliding True @ 0 to the RIGHT

Game Over! You lose!

---- MovingDay Game ----

Number of Falses: 3

Number of Trues: 3

0 1 2 3 4 5 6

| T | T | T | | F | F | F |

Choose move: 4

Sliding False @ 4 to the LEFT

... much later ...

0 1 2 3 4 5 6

| F | F | F | T | | T | T |

Choose move: 3

Sliding True @ 3 to the RIGHT

0 1 2 3 4 5 6

| F | F | F | | T | T | T |

Congratulations! You win!

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 Databases Questions!