Beispiel #1
0
        public override int[] MakeMove(string[][] gameState)
        {
            int r;
            int k;

            while (true)
            {
                string move = Console.ReadLine();
                if (move.Length == 2)
                {
                    if (move.ToLower().Contains("a"))
                    {
                        r = 0;
                    }
                    else if (move.ToLower().Contains("b"))
                    {
                        r = 1;
                    }
                    else if (move.ToLower().Contains("c"))
                    {
                        r = 2;
                    }
                    else
                    {
                        display.InvalidMoveError();
                        continue;
                    }
                    if (move.Contains("1"))
                    {
                        k = 0;
                    }
                    else if (move.Contains("2"))
                    {
                        k = 1;
                    }
                    else if (move.Contains("3"))
                    {
                        k = 2;
                    }
                    else
                    {
                        display.InvalidMoveError();
                        continue;
                    }
                }
                else
                {
                    display.InvalidMoveError();
                    continue;
                }
                break;
            }


            return(new int[] { r, k });
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            display = new TerminalInterface();

            ModeSelection();
            display.AddTable(table);



            while (true)
            {
                Player.Player nextPlayer = table.NextToPlay();

                display.GameState();
                while (true)
                {
                    int[] move = nextPlayer.MakeMove(table.tableState);
                    if (table.AddMove(move[0], move[1]) == -1)
                    {
                        display.InvalidMoveError();
                    }
                    else
                    {
                        break;
                    }
                }
                if (table.Winner())
                {
                    display.Winner();
                    break;
                }
                else if (table.Draw())
                {
                    display.Draw();
                    break;
                }
            }
        }