Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please write this program in PYTHON programming language. Lock game is a strategy game played with 2 people. The playing field is 8X8 and consists

Please write this program in PYTHON programming language.

Lock game is a strategy game played with 2 people. The playing field is 8X8 and consists of 64 squares.

In the game, both players have 8 playing marbles . The object of the game is to remove all the opponent's marbles.

At the beginning of the game, players place their marbles on the squares on the nearest row.

Then the players take turns trying to lock the opponent's marbles by moving a marble of their own.

The marbles can be moved as far as desired horizontally or vertically within the playing field, but the marbles cannot be jumped over.

A marble with an opponent marble in its 2 adjacent squares on the horizontal, aslo a marble with an opponent marble on the 2 adjacent squares vertically,

or a marble in the corner with an opponent marble on the adjacent squares horizontally and vertically is considered locked.

If the next player locks one or more of the opponent's marbles as a result of his move, he takes that marble/marbles out.

In other words, a player removes the marble/marbles belonging to the opponent player, which he/she locked with his/her own marble while it is his/her turn to move.

The player who manages to reduce the number of opponent's marbles below 2 wins the game.

For an example game, watch this video in youtube (Simulated version of the game):

https://www.youtube.com/watch?v=GxulU4jEP_s

PROBLEM DESCRIPTION :

It is desirable to develop a program that will simulate the Lock game described above.

The playing area should be at least 4X4 and maximum 8X8. The rows of the playing field must be represented by counting numbers and the columns by capital letters in English.

When the program runs, first two characters must be taken from the user to represent the players:

Enter a character to represent player 1: X

Enter a character to represent player 2: Y

The game should be able to be played repeatedly, and at the begining of each game the number of rows/columns of the playing field(as well as the number of marbles that each player will have) [4-8] should be taken from the user and the starting playing field should be displayed too.

For example, a 4X4 starting playing field might look something like this:

Enter the number of rows/columns of the playing field (4-8): 4

A B C D

----------------------------

1 | Y | Y | Y | Y | 1

----------------------------

2 | | | | | 2

----------------------------

3 | | | | | 3

----------------------------

4 | X | X | X | X | 4

----------------------------

A B C D

Player X, please enter the position of your own marble that you want to move and the target position:

Players must select the current position and target position of their own marble that they want to move, with

the row number of the corresponding position (in the example [1-4]) and

the column letter (in the example [A-D]) adjacent (for example 3C), leaving a space between the two positions (for example 3C 1C) should be entered.

After each move, the playing field must be re-displayed, and if there is a marble that has been locked and removed

with this move, the position of this marble must be specified.

For example, the playground in the example above can be displayed at any stage of the game like this:

A B C D

----------------------------

1 | Y | | X | | 1

----------------------------

2 | X | | | | 2

----------------------------

3 | | | X | | 3

----------------------------

4 | | | | | 4

----------------------------

A B C D

The marble at position 2C was locked and removed.

Player Y, please enter the position of your own marble you want to move and the target location:

At the end of the game, the player whom has won the game should be printed on the screen and the user should be asked

if he wants to play again.

For example :

Player X won the game.

Would you like to play again(Y/N)?:

Attention :

1.During data entries, the user's erroneous or invalid data entries according to the game rules, data entries that may cause

runtime errors (exception handling) should be checked and it should be ensured to wait until appropriate data entry.

In addition, the data must be taken in the specified order and manner.

2.The situation where a player does not have a chance to make a move that complies with the rules of the game doesn't need to be addressed.

In other words, you can assume that the player whose turn it is will definitely have a chance to make a valid move.

3.The main purpose of this project is to reinforce the use of one/two-dimensional list, dictionary and string data structures.

In addition, the program is expected to be modular (consist of functions) and not to use a global variable (a variable that is not defined/created inside a function).

Photos of the board game's status given in the examples above :

image text in transcribed
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions