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); }
public ErrorCondition Move(string input) { if (MoveParser.TryParseMove(input, CurrentState.Board, CurrentTurn, out AnnotatedMove move)) { return(Move(move.Move)); } return(ErrorCondition.InvalidInput); }
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"); }
public static Square ParseSquare(string input) { return(MoveParser.ParseSquare(input)); }