Sei sulla pagina 1di 3

CC 104 – Data Structures and Algorithms Final Requirement

Submission Deadline: December 20, 2019


Applied Data Structure and Algorithm Concept: Binary Trees

CHOOSE YOUR PARTNER GUYS.

Isola is a two-player board game. It is played on a 7x7 grid which is initially filled with squares
on each cell. Both players have one piece; it is in the middle position of the row closest to his/her
side of the board. Players can place their piece on squares only.

A move consists of two subsequent actions:

1. Moving one's piece to a neighboring (horizontally, vertically, or diagonally) position that


contains a square but not the opponent's piece.
2. Removing any square with no piece on it.

The player who cannot move his/her piece loses the game.

Now you are going to write code to play Isola with others or computer bot. The program you
submit will run for each move played by your player in the game.

Input
The input will be an 7x7 matrix consisting only of 0, 1, 2 and -1. Then another line will follow
which will contain a number 1 or 2, which is your player id. The difference between player 1 and
2 is that player 1 plays first in start of the game.

In the given matrix, top-left is [0,0] and bottom-right is [6,6]. The coordinate of a cell is
represented by [row, column]. Rows increases from top to bottom and column increases from left
to right.

The cell marked 0 means it contains a square which is yellow in color. The cell marked 1 means
it contains player 1's piece which is blue in color. The cell marked 2 means it contains player 2's
piece which is red in color. The cell marked -1 means it doesn't contain the square. The board is
brown in color.

Output
Print the coordinates of the neighbor cell [row, column] where you want to move your piece. In
next line, print the coordinates of any cell to remove the square.

Starting state
0002000
0000000
0000000
0000000
0000000
0000000
0001000

Scoring
The scores will be calculated by running a tournament of all submissions at the end of the
contest. Your last submission will be used while running the tournament. Score will be assigned
according to Elo rating system.

Example of a bot which plays the game randomly, while avoiding invalid move:
https://code.hackerearth.com/6f1718R
SAMPLE INPUT
0 0 0 2 0 0 0
0 0 0 -1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 1 0 0
0 0 0 0 0 0 0
2
SAMPLE OUTPUT
0 2
4 4
Explanation
This is player 2's turn, and the player moves his/her piece to cell [0, 2] and removes the square at
cell [4, 4].

After his/her move the state of game becomes:


0 0 2 0 0 0 0
0 0 0 -1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 -1 0 0
0 0 0 0 1 0 0
0 0 0 0 0 0 0

Preferred Language: C++ or Java


Submissions: One Short Video showing you and your partner play the game until one of you win
and your source code zipped together.
Zip File Format – LastnameFirstnameMI1_LastnameFirstnameMI2.zip
Send it via my email address:

Note: Project Specification adopted from www.hackerearth.com

Potrebbero piacerti anche