This is the archived CodeCup 2017 website.
Click here to go to the new CodeCup website.
CodeCup 2017 - An online programming competition  

CodeCup 2017 - An online programming competition

Less

About the game

Less is a game that was started as a KickStarter project. You can find more information about this game on http://www.less-game.com/. We will use the four-player version of the game.

This document will start with describing the board, the goal and the game play. It then discusses scoring. Finally it will discuss how your program should interact with the judging software, and how you can test your program at home using Caia.

Board and walls

Less is a four-player game played with programs from four different contestants. It is played on a board of 8x8 unit squares. Between two squares that share a side can be zero, one or two walls. The walls influence the score. When the game starts you will be sent the position of the walls. Your program should always start by reading the layout of the board. This layout may be different for every game, even if you play several times against the same players. While testing the game at home it is possible to play multiple games on the same board.

Goal

When the game starts yellow and white each have four pieces in the bottom 2x2 corners of the board. Black and red each start with four pieces in the top 2x2 corners of the board. Yellow and white play together against black and red. The order of the moves is: yellow, black, white red. The goal of the game is to move all pieces of each team (yellow + white, or black + red) as quickly as possible to opposite corners of the board.


Figure 1: A possible board at the beginning of the game. The beginning position of the pieces is always the same.

Game play

The players move consecutively in the order yellow, black, white red, yellow, black, ... Play continues until all players have moved their pieces to the diagonally opposite corner of where they started. If a player had moved all of his pieces into the opposite corner and he has moves left in his turn, or it is his turn again, he is allowed to move the pieces of his partner. When all your pieces and that of your partner ended up in the opposite corners, your program can terminate itself.

When all pieces have reached the opposite corner the score will be calculated.

Turns

Each turn a player makes between one and three moves. He can choose from the following moves:

  1. The player can move a piece from a square to a bordering empty square where no wall is shared between the squares. This move counts as a single move so each turn a maximum of three such moves can be made.
  2. The player can move from one square to a bordering empty square where a single wall is shared between the squares. This move counts as a double move, so within a single turn it can only be combined with a move of type 1 or type 4.
  3. The player can move from one square to a bordering empty square where a double wall is shared between the squares. This move counts as a triple move, so it can only be the first move of the turn, and the turn will end immediately.
  4. The player can jump his pieces horizontally or vertically over exactly one other piece to an empty square on the other side of this piece. He may not jump over any walls during a jump. This move counts as one move and therefore can be combined with two other moves.
  5. All moves are orthogonal; diagonal moves are not allowed. A piece can only be moved to an empty square.

    Each turn a player must make between one and three moves. Even if further moves would be allowed he may decide to make only one or two moves. Except for the very last turn where both four pieces move to their opposite corners, the number of moves in each turn counts as three moves.


    Figure 2: All possible jump moves from yellow

    I/O

    A communication protocol has been designed for your program to communicate with the judging software. You will read the moves of the other players from stdin (standard in). You must print your own moves to stdout (standard out). You are free to write to stderr (standard error).

    Your program must always start by reading the board. The board is described on the first line of stdin. The board is described in a string of 112 characters. Each character can be '0', '1' or '2' indicating whether there is no wall, a single wall, or a double wall in that position. The walls are described left to right, from top to bottom: the first 7 characters indicate the vertical walls on the first row, the second 8 characters indicate the 8 horizontal walls between the first and second row. The next 7 characters indicate the vertical walls on the second row, etc. The last 7 characters indicate the vertical walls in the 8th row.

    The string that describes figure 1 is:"0100000010000020000101001211000110000010010000101000000000010001101010001001000010000000000000100000101011001010"

    Your program should read which color it is playing from the second line of stdin. This will be indicated with a single word: Yellow, Black, White or Red. You will now read a number of lines that indicate what happened during the turns of the other players before it is your first turn. If you play as Black you should read a single line, if you play as White you have to read two lines, Red reads three lines.

    A turn is read from a single line. It contains one, two or three moves separated by a colon. An example of a valid turn would be 'h1f1:g1g3:h2f2', indicating that the first piece moved from h1 to f1, followed by a movement from g1 to g3, with a final move h2 to f2. A turn with one or two moves is shown as 'h1f1' or 'h1f1:g1g3'.

    Your program should write the moves from your turn to stdout. If your program plays as Yellow your move will be the first move of the game, so you won't have to read any prior moves. After each turn you read three lines with the turns of the other players. If you read the string 'Quit' instead of a normal turn of moves this indicates the game is over, and your program should terminate normally.

    If one or more programs have finished, the game continues until the opponents have moved their stones to the opposite coners. The moves of the finished players are shown as the string 'Nil' for the programs that are still busy. This indicates that they have not made a move, and your program should start calculating immediately which move to make. The finished programs will receive 'Quit' on their standard input.

    After your program has made 20 turns your program will read the instruction 'Move'. This instruction indicates that you have a single special final turn left. In this final turn you remove all pieces of the other three players from the board. You must now make as few moves as possible to move all your pieces to the opposite corner. A piece that jumps over a single wall counts as two moves, a piece that jumps over a double wall counts as three moves, a piece that jumps over another piece (with no walls!) counts as a single move. Write each move on an individual line to stdout in the format 'h1f1' without reading from stdin. Terminate your program normally when your pieces have all ended up in the right spot. If your program didn't finish in the opposite corner after the move phase, your receive 0 points.

    Game gets stuck

    In the case a player is not able to perform a legal move anymore, the following procedure applies. The player reads 'Move' from stdin and must then rush home as earlier described. The other three players follow the same procedure.

    Score

    When the game has finished your score is calculated. The score for your team is ten minus the sum of the number of your moves plus the sum of the moves of the two opponents. If your score is below 0, your score is 0. Your score is capped at 20. In a tie everybody scores 10 points. The sum of both scores is always 20. You always receive the same score as your partner.

    Example: it took your team 55 moves to reach the other side; your opponents needed 60 moves together. Your score is now 10-55+60=15. Your opponent scores 10-60+55=5.

    If your program crashes at any point, returns an invalid move (for example 0 or more than 3 moves in a turn) or takes over 30 seconds in total for a game, your program will score 0 points. The judge software will take over and will play in your place. The other players will obtain a normal score, but your score for this game will be 0.

    We will organize a tournament with all programs that are able to cooperate using the judging software.

    Generating the board

    The board consists of 8x8 squares. A double set of 12 tiles are used to generate the board. Each tile consists of 2x2 squares. Out of the double set of tiles 16 tiles are randomly chosen.

    If four players play against each other, there are 24 possible permutations for the players to play a game. For each set of 24 games a new board will be generated.


    Figure 3: The set of 12 tiles used to generate the boards.

    Example

    stdin yellowstdout yellowstdin blackstdout blackstdin whitestdout whitestdin redstdout red
    'board string''board string''board string''board string'
    YellowBlackWhiteRed
    'move 1'move 1''move 1''move 1'
    'move 2''move 2''move 2'
    'move 2''move 3''move 3'
    'move 3''move 3''move 4'
    'move 4''move 4''move 4'
    'move 5''move 5''move 5''move 5'
    'move 6''move 6''move 6'
    'move 6''move 7''move 7'
    'move 7''move 7'Etcetera