Exemple #1
0
        static void Main()
        {
            var connection       = new ConnectionModule();
            var startInformation = connection.Initialize("127.0.0.1:30052", "example player");

            // Wait for the server to respond
            startInformation.Wait();

            // Server tells the client is either starting player (white),
            // or black. If black, info also contains white players first move
            var result = startInformation.Result;

            // Initialize your own ai
            var ai = new ExampleAiLogic(result.WhitePlayer, result);

            // Inject ai to connection module and play game
            var playTask = connection.Play(ai);

            playTask.Wait();

            // Game finished
            connection.CloseConnection();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(180, 40);
            var handle = GetStdHandle(-11);
            int mode;

            GetConsoleMode(handle, out mode);
            SetConsoleMode(handle, mode | 0x4);


            Log($"Chess ai {_aiName} [{_currentVersion}]");

            while (true)
            {
                Log("[1] Start game");
                Log("[2] Edit player name and start game");
                Log("[3] Start local game with two vergiBlues against each other");
                Log("[4] Start local game with two vergiBlues against each other. Delay between moves");
                Log("[5] Custom local game");
                Log("[9] Connection testing game");
                Log("[Any] Exit");

                Console.Write(" > ");
                var input = Console.ReadKey();
                if (input.KeyChar.ToString() == "1")
                {
                    var connection = new ConnectionModule();
                    StartGame(connection, _aiName, false);
                    connection.CloseConnection();
                }
                else if (input.KeyChar.ToString() == "2")
                {
                    Log(Environment.NewLine);
                    Log("Give player name: ");
                    Console.Write(" > ");
                    var playerName = Console.ReadLine();
                    Log($"Chess ai {playerName} [{_currentVersion}]");
                    var connection = new ConnectionModule();
                    StartGame(connection, playerName, false);
                    connection.CloseConnection();
                }
                else if (input.KeyChar.ToString() == "3")
                {
                    StartLocalGame(0, null);
                }
                else if (input.KeyChar.ToString() == "4")
                {
                    StartLocalGame(1000, null);
                }
                else if (input.KeyChar.ToString() == "5")
                {
                    CustomLocalGame();
                }
                else if (input.KeyChar.ToString() == "9")
                {
                    var connection = new ConnectionModule();
                    StartGame(connection, "Connection test AI", true);
                    connection.CloseConnection();
                }
                else
                {
                    break;
                }

                Log(Environment.NewLine);
            }
        }