コード例 #1
0
ファイル: Program.cs プロジェクト: johnathandavis/JohnChess
        static void Main(string[] args)
        {
            var client = new LichessClient();
            var game   = client.GetTrainingPuzzleAsync(1).Result;

            foreach (var move in game.UCIMoves)
            {
                Console.WriteLine(move);
            }
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var johnJohn     = new ReinfeldPlayer();
            var randomPlayer = new ReinfeldPlayer();

            var lichessClient  = new LichessClient();
            var lichessGame    = lichessClient.GetTrainingPuzzleAsync(2).Result;
            var johnChessBoard = LichessGameJohnChessConverter.ToJohnChessGame(lichessGame);

            game = new Game(johnJohn, randomPlayer, johnChessBoard);

            johnJohn.InitializePlayer(game.Board, game.ColorToPlay);
            randomPlayer.InitializePlayer(game.Board, game.ColorToPlay);

            Func <Move, string>         movePrinter     = (move) => moveFormatter.FormatMove(move, pieceFormatter);
            Func <MoveSnapshot, string> snapshotPrinter = (snapshot) =>
            {
                string moveStr = moveFormatter.FormatMove(snapshot.Move, pieceFormatter);
                return(moveStr + " (" + snapshot.EvaluatedScore + ")");
            };

            Console.WriteLine("Starting game...");
            while (true)
            {
                try
                {
                    var moves = game.GetCurrentPlayerMoves();
                    DrawList("Move History:", 38, game.MoveSnapshots, snapshotPrinter);
                    DrawList("Possible moves:", 82, game.GetCurrentPlayerMoves(), movePrinter);
                    DrawBoard(game.Board);
                    Console.WriteLine();
                    Console.WriteLine("Enter Move (blank for AI):");
                    game.MakePlayerMove();
                    long generatedMoves = ((ReinfeldPlayer)game.PreviousPlayer).Telemetry.GetCounter(Counters.GeneratedMoves);
                    Console.Title = Console.Title + " (Generated Moves: " + generatedMoves + ")";
                }
                catch (CheckmateException)
                {
                    bool blackWon = game.BlackPlayer == game.PreviousPlayer;
                    Console.WriteLine(blackWon ? "Black Wins!" : "White wins!");
                    Console.ReadKey();
                }
            }
        }