The board is given by a rectangle with r rows numbered from 0 to r-1 and c columns numbered from 0 to c-1. Row 0 and r-1 as well as column 0 and c-1 are walls that bound the playing field. There might also be walls (obstacles) inside of this area.
Initially the blue player must place its pieces somewhere in the left half of the board, and the red player must place its pieces in the right half of the board. Failure to do so, i.e., placing a piece in the oppenents half or placing a piece on the wall, leads to immediate loss of the game.
You must provide a function called setup.
The input parameters of this function are (in this given order):
the color you are playing (int) (0 for blue, 1 for red)
the number of rows of the gameboard (int)
the number of columns of the gameboard (int)
the gameboard itself
(an r-tuple of c-tuples of type string,
where the string "WWWW" indicates the wall,
and " " (a string with 4 blanks) is a regular (empty) square on the board).
Your setup funtion must return a tuple of tuples of type int. For example, ((a,b), (c,d)) means the cheeSe will be placed initially on the square (a,b) and the Mouse will be placed initially on the square (c,d), where each location is given in form (row, column).
The two players move simultaneously. This means both players submit their moves and then all moves will be executed at the same time.
All pieces, except for the cheese, which can never be moved, move like a Chess king, i.e., they can move to any of the eight neighboring squares (horizontally, vertically, and diagonally). The numbers on the numeric keypad (numpad) will be used to indicate the directions.
You must provide a function called move
that returns the moves of the pieces made in form of a single string.
If you are playing blue, then use the initial capitalized letter of the piece to move.
For red, use the corresponding lower case letter.
So, for the mouse, blue will use M and red will use m.
The direction of the move must follow the initial of the piece separated by a single blank.
For example, if blue wants to move its mouse horizontally left,
then the function must return the string "M 4",
and if red wants to move its mouse diagonally up right,
then the function must return the string "m 9".
The input parameters of the function move are the same as the input parameters of the function setup as described above. However, there is one additional last parameter. The placement of the pieces is given as a dictionary, where the keys are strings, such as "S" for blue cheeSe, "s" for red cheeSe, "M" for blue Mouse, "m" for red Mouse. The corresponding value is either None if no such piece is on the board or a 2-tuple of the form (row, column) indicating the position of this piece on the board.
Please note that the board itself does not contain information about where the pieces are placed.
If a piece tries to move into the wall, then the piece will simply not move. If you actually don't want to move a piece, then direction "5" should be used.
Multiple pieces can stand on the same square! However, if pieces of blue and red are on the same square, then pieces might be captured. To be more precise, if a blue piece of rank x and a red piece of rank x+1 are on the same square, then the blue piece will be captured and taken off the board. If two pieces of the same rank are on the same square, then both will be taken off the board.
In our game, cheeSe has the lowest rank. If the opponent's Mouse is on the same square as our cheeSe, then the Mouse eats the cheeSe and the game is lost. As a special case if our Mouse also ate the opponent's cheeSe in the same turn, then the game ends in a draw. If both of the Mice are sitting on the same square at the end of a move, they will start a (deadly) fight and both will be taken off the board. However, the evaluation always works from the lowest rank up to the highest rank, so it might happen that a Mouse first eats the opponent's cheeSe, and after that will get into a fight with the other Mouse.
If the cheeSe is not eaten after a predetermined number of moves (60), the game will be decided by score, which is based on the number of pieces remaining on the board.
The game playing programs will have a time limit of 5 seconds per move. Exceeding this time limit will not automatically result in a lost game, but rather a null-move will be submitted. This means none of your pieces will move.
However, if your program crashes, then the game will count as lost!
Please upload your Python 3 source code here in a single file. Use your team name as the name of the file with the suffix ".py".
The submission deadline is at 7:00pm sharp! Before this deadline you may overwrite your submissions as many times as you like.