Example #1
0
        static void Main(string[] args)
        {
            Client client = new Client();
            string fen    = client.GetFenFromServer();

            Console.WriteLine(client.GameID);
            Chess chess = new Chess(fen);

            while (true)
            {
                Console.WriteLine(chess.fen);
                Print(ChessToAscii(chess));
                foreach (string moves in chess.YieldValidMoves())
                {
                    Console.WriteLine(moves);
                }
                string move = Console.ReadLine();
                if (move == "")
                {
                    break;
                }
                if (move == "s")
                {
                    fen   = client.GetFenFromServer();
                    chess = new Chess(fen);
                    continue;
                }
                if (!chess.IsValidMove(move))
                {
                    continue;
                }
                fen   = client.SendMove(move);
                chess = new Chess(fen);
            }
        }
Example #2
0
 static int NextMoves(int step, Chess chess)
 {
     if (step == 0) return 1;
     int count = 0;
     foreach (string moves in chess.YieldValidMoves())
         count += NextMoves((step - 1), chess.Move(moves));
     return count;
 }
Example #3
0
        static int NextMoves(int step, Chess chess)
        {
            if (step == 0)
            {
                return(1);
            }
            int count = 0;

            foreach (string moves in chess.YieldValidMoves())
            {
                count += NextMoves((step - 1), chess.Move(moves));
            }
            return(count);
        }
Example #4
0
        public static void Main(string[] args)
        {
            Chess chess = new Chess();

            // Console.WriteLine(NextMoves(5, chess));
            // Console.ReadKey();
            // return;
            while (true)
            {
                Console.WriteLine(chess.fen);
                Print(ChessToAscii(chess));
                foreach (string moves in chess.YieldValidMoves())
                {
                    Console.WriteLine(moves);
                }
                string move = Console.ReadLine();
                if (move == "")
                {
                    break;
                }
                chess = chess.Move(move);
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            string fen;

            // стандартная начальная позиция
            // fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 0";
            //fen = "rnbqkbnr/pPppppPp/8/8/8/8/PpPPPPpP/RNBQKBNR w KQkq - 0 1";
            // FEN используемый Евгением:
            fen = "rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NpPP/RNBQK2R w KQ - 1 8";


            //Client client = new Client();

            //string fen = client.GetFenFromServer();
            //Console.WriteLine(client.GameID);

            //Console.WriteLine(fen);
            //Console.ReadKey();

            Chess chess = new Chess(fen); // начальная позиция

            // позиция для тестирования
            //Chess chess = new Chess("8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 0");
            //Console.WriteLine(NextMoves(3, chess));
            //Console.ReadKey();
            //return;

            int i = 0;

            while (true)
            {
                Console.WriteLine(chess.fen);

                Print(ChessToAscii(chess)); // вывод доски на экран

                Console.WriteLine();

                foreach (string moves in chess.YieldValidMoves())

                {
                    if (i > 4)
                    {
                        Console.WriteLine("\n");
                        i = 0;
                    }
                    else
                    {
                        Console.Write(moves + "  ");
                        i++;
                    }
                }
                Console.WriteLine("\n");
                // запрашиваем желаемый ход
                string move = Console.ReadLine();
                if (move == "")
                {
                    break;             // выход из игры по нажатию клавиши
                }
                if (move == "s" || move == "S" || move == "ы" || move == "Ы")
                {
                    //fen = client.GetFenFromServer();
                    chess = new Chess(fen);
                    continue;
                }

                if (!chess.IsValidMove(move))
                {
                    continue;
                }
                //fen = client.SendMove(move);
                //chess = new Chess(fen);
                chess = chess.Move(move);
            }
        }