Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

If A: B 3:4 and B: C=5:6, express A: B: C. AppendixLO1

Answered: 1 week ago

Question

please dont use chat gpt AI 1 1 0 . .

Answered: 1 week ago

Question

Explain key approaches to implementing LMD

Answered: 1 week ago