import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* This example demonstrates how a Alquerque player can be made
* Alquerque is the CodeCup game 2008 (www.codecup.nl)
* The use of this file and/or ideas is not compulsory
* Left to do: six TODOs
* This example is written by Jaap Taal
* Use Caia to play Alquerque games (and more...) at your own house
* Success and a lot of joy in the contest!
*/
enum Player {
WHITE, BLACK
}
class Board {
public static final int SIZE = 7;
private Player[] board = new Player[SIZE * SIZE];
public boolean isDead(Player player) {
// TODO: Calculate deadness of player
return false;
}
public void doMove(Move move, Player player) {
// TODO: Update board acording to the move and player parameters
}
public Move calculateMove(Player player) {
// TODO: calculate best move
return null;
}
}
class Move {
// TODO: add usefull fields and methods
public static Move valueOf(String string) {
// TODO: create a TMove, based on string
return null;
}
@Override
public String toString() {
// TODO: return string representation of move
return null;
}
}
public class Alquerque {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Board board = new Board();
int numberOfMoves = 0;
String inputline;
inputline = in.readLine();
if (inputline.equals("Start")) { // PLAY AS WHITE
do {
Move move = board.calculateMove(Player.WHITE);
board.doMove(move, Player.WHITE);
System.out.println(move.toString());
System.out.flush();
if (board.isDead(Player.BLACK)) break;
inputline = in.readLine();
if (inputline.equals("Quit")) break;
move = Move.valueOf(inputline);
board.doMove(move, Player.BLACK);
} while (++numberOfMoves < 100);
} else { // PLAY AS BLACK
while (true) {
Move move = Move.valueOf(inputline);
board.doMove(move, Player.WHITE);
move = board.calculateMove(Player.BLACK);
board.doMove(move, Player.BLACK);
System.out.println(move.toString());
System.out.flush();
if (++numberOfMoves == 100) break;
if (board.isDead(Player.WHITE)) break;
inputline = in.readLine();
if (inputline.equals("Quit")) break;
}
}
}
}
syntax highlighted by Code2HTML, v. 0.9.1