Ejemplo n.º 1
0
        private static string[] GetMoves(Game game)
        {
            var history = game.History.ToArray();

            Array.Reverse(history);

            var moves = new string[history.Length - 1];

            for (var i = 1; i < history.Length; i++)
            {
                var move   = history[i].PrecedingMove;
                var board  = history[i - 1].Board;
                var result = history[i].AttackState;

                var moveStr = MoveParser.ToMoveString(move, board, result);
                if (moveStr.StartsWith('0'))
                {
                    moveStr = moveStr.Replace('0', 'O');
                }

                moves[i - 1] = moveStr;
            }

            return(moves);
        }
Ejemplo n.º 2
0
        public ErrorCondition Move(string input)
        {
            if (MoveParser.TryParseMove(input, CurrentState.Board, CurrentTurn, out AnnotatedMove move))
            {
                return(Move(move.Move));
            }

            return(ErrorCondition.InvalidInput);
        }
Ejemplo n.º 3
0
        public AnnotatedMove ParseMove(string input)
        {
            if (MoveParser.TryParseMove(input, CurrentState.Board, CurrentTurn, out AnnotatedMove move))
            {
                return(move);
            }

            throw new FormatException($"Could not parse move '{input}' for current board state");
        }
Ejemplo n.º 4
0
 public static Square ParseSquare(string input)
 {
     return(MoveParser.ParseSquare(input));
 }