Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length > 0) {
                foreach (string arg in args) {
                    if (arg.Contains("-c:")) {
                        switch (arg.Replace("-c:", "")) {
                            case "B":
                                player = Mode.AIBlack;
                                break;
                            case "A":
                                player = Mode.AIBoth;
                                break;
                            case "N":
                                player = Mode.AINone;
                                break;
                            case "W":
                            default:
                                player = Mode.AIWhite;
                                break;
                        }
                    }
                    if (arg.Contains("-i")) {
                        outputICMS = true;
                    }
                    if (arg.Contains("-t:")) {
                        int usrtime;
                        if (int.TryParse(arg.Replace("-t:", ""), out usrtime))
                            moveTime = usrtime;
                    }
                    if (arg.Contains("-s"))
                        showBoard = true;
                    if (arg.Contains("-b"))
                        stepOutput = true;
                }
            }
            Board board = new Board();
            board.resetBoard();
            Random rand = new Random();
            Move m = null;
            Boolean t = false;
            while (board.State == Board.BoardState.Playing) {
                if (showBoard) {
                    board.printToStdOut();
                    Console.WriteLine();
                }
                if (player == Mode.AIBoth || (player == Mode.AIBlack && board.CurrentColor == Piece.Color.Black) || (player == Mode.AIWhite && board.CurrentColor == Piece.Color.White)) {
                    while (!t) {
                        m = board.findBestMoveForCurrentPlayer(moveTime);
                        t = board.makeMove(m);
                    }
                    t = false;
                    if (outputICMS) {
                        Console.WriteLine("Giving my move to skirmish");
                        Console.Write("! ");
                    }
                    Console.WriteLine(m);
                }
                else {
                    while (!t) {
                        if (outputICMS)
                            Console.WriteLine("Getting move from skirmish");
                        else
                            Console.WriteLine("Please enter your move");
                        string play = Console.ReadLine();
                        if (string.IsNullOrEmpty(play))
                            continue;
                        play = play.Replace("!", "");
                        play = play.Trim();
                        m = new Move(play);
                        t = board.makeMove(m);
                    }
                    t = false;
                }
                if (stepOutput && !outputICMS)
                    Console.ReadLine();
            }

            if (outputICMS)
                Console.Write("= ");
            Console.WriteLine(Board.getStateString(board.State));
            AI.saveTTable();
            Board.saveCache();
            if(stepOutput && !outputICMS)
                Console.ReadLine();
        }