Ejemplo n.º 1
0
        private void SetupPosition(string[] args)
        {
            var           positionType = args[1];
            ChessPosition position;

            switch (positionType)
            {
            case "startpos": position = ChessPosition.FromFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 "); break;

            case "fen": position = ChessPosition.FromFEN(args[2], args[3], args[4]); break;

            default: return;
            }

            game.Add(new GameState(position, new ChessMove(0)));

            int movesIndex;

            for (movesIndex = 2; movesIndex < args.Length; movesIndex++)
            {
                if (args[movesIndex] == "moves")
                {
                    break;
                }
            }

            for (int i = movesIndex + 1; i < args.Length; i++)
            {
                ChessMove move = ChessMove.Parse(args[i]);

                position = position.ApplyMove(move);
                game.Add(new GameState(position, move));
            }
        }