Exemplo n.º 1
0
 async Task Responce_Connect4_Play(string Msg, MessageEventArgs e)
 {
     if (Connect4Games.Where(x => !x.Finished).Any(x => x.Players.Any(y => e.User == y)))
     {
         var      Column = int.Parse(e.Message.RawText.Substring(2, 1));
         MainGame MG;
         if ((MG = Connect4.Play(e.User, Column)) != null)
         {
             if (MG.Players[MG._Turn].IsBot)
             {
                 Connect4.Play(MG.Players[MG._Turn], MG.PlayAI());
             }
         }
         else
         {
             (await e.Channel.SendMessage("It's not your turn, " + e.User.Mention)).Timed(40);
             WriteLine("Command Error: It is not the user's turn");
         }
     }
     else
     {
         (await e.Channel.SendMessage(":anger: You are not in a Connect 4 Game")).Timed(40);
         WriteLine("Command Error: User is not in a Connect 4 game");
         return;
     }
 }
Exemplo n.º 2
0
            async Task Responce_Connect4(string Msg, MessageEventArgs e)
            {
                var Opponent = e.Message.MentionedUsers.Where(x => x != e.User).FirstOrDefault();
                var Diff     = 50;

                try
                {
                    if (Msg.Contains('#'))
                    {
                        Diff = int.Parse(Msg.Substring(Msg.IndexOf('#') + 1));
                    }
                }
                catch (Exception)
                {
                    (await e.Channel.SendMessage(":anger: Unable to read difficulty\n`Syntax Error`")).Timed(40);
                    WriteLine("Command Error: Could not determine difficulty");
                    return;
                }
                if (Opponent == null)
                {
                    (await e.Channel.SendMessage(":anger: Could not find an opponent")).Timed(40);
                    WriteLine("Command Error: Could not determine a user");
                    return;
                }
                if (Connect4.StartNew(new User[] { e.User, Opponent }, e.Channel, Diff) == null)
                {
                    (await e.Channel.SendMessage(":anger: Specified players are currently in a game")).Timed(40);
                    WriteLine("Command Error: Users already in a game");
                    return;
                }
            }
Exemplo n.º 3
0
        private static void StartGame()
        {
            BoardSettings boardSettings = new BoardSettings()
            {
                Columns = 7, Rows = 6, WinningCount = 4
            };

            Connect4 c4 = new Connect4(boardSettings, new Message());

            c4.Player1 = new Human();
            c4.Player2 = new Computer(2, boardSettings);

            c4.PlayGame();

            System.Console.Write("Would you like another game? (Y or N)");
            char c = System.Console.ReadKey().KeyChar;

            if (c.ToString().ToUpper() == "Y")
            {
                StartGame();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Exemplo n.º 4
0
        public void Setup()
        {
            boardSettings = new BoardSettings()
            {
                Columns = 7, Rows = 6, WinningCount = 4
            };

            c4         = new Connect4(boardSettings, new Message());
            c4.Player1 = new Human();
            c4.Player2 = new Computer(2, boardSettings);
        }
Exemplo n.º 5
0
        private static void StartGame()
        {
            BoardSettings boardSettings = new BoardSettings() { Columns = 7, Rows = 6, WinningCount = 4 };

            Connect4 c4 = new Connect4(boardSettings, new Message());
            c4.Player1 = new Human();
            c4.Player2 = new Computer(2, boardSettings);

            c4.PlayGame();

            System.Console.Write("Would you like another game? (Y or N)");
            char c = System.Console.ReadKey().KeyChar;
            if (c.ToString().ToUpper() == "Y")
                StartGame();
            else
                Environment.Exit(0);
        }
Exemplo n.º 6
0
        private static void StartGame()
        {
            Connect4 c4 = new Connect4(new BoardSettings() { Columns = 7, Rows = 6 }, new Message());
            c4.Player1 = new Human();
            c4.Player2 = new Computer(2);

            //Uncomment code below for Computer vs computer game.
            c4.Player1 = new Computer(1);
            (c4.Player1 as Computer).CutOffLevel = 7;
            (c4.Player2 as Computer).Weights = new int[] { 1, 2, 4, 8, 1, 2, 8, 16 };

            c4.PlayGame();

            System.Console.Write("Would you like another game? (Y or N)");
            char c = System.Console.ReadKey().KeyChar;
            if (c.ToString().ToUpper() == "Y")
                StartGame();
            else
                Environment.Exit(0);
        }
Exemplo n.º 7
0
 //Set singleton instance and initialize all buttons
 void Awake()
 {
     _instance       = this;
     Grid            = GameObject.Find("Grid");
     Call_Button     = GameObject.Find("Button_Call");
     Single_Button   = GameObject.Find("Button_Single");
     Double_Button   = GameObject.Find("Button_Double");
     Triple_Button   = GameObject.Find("Button_Triple");
     Reset_Button    = GameObject.Find("Button_Reset");
     Quit_Button     = GameObject.Find("Button_Quit");
     Continue_Button = GameObject.Find("Button_Continue");
     ContextMessage  = GameObject.Find("ContextMessage");
     PairedAI        = GameObject.Find("PairedAI").GetComponent <TextMeshProUGUI>();
     AgentNames      = new Dictionary <string, string>
     {
         { "learning strategy and tactics", "high strategy and tactics" },
         { "learning tactics only", "low strategy and high tactics" },
         { "learning strategy only", "high strategy and low tactics" },
         { "no learning", "low strategy and tactics" }
     };
     HideButtons();
 }
Exemplo n.º 8
0
 public void Setup()
 {
     c4 = new Connect4(new BoardSettings() { Columns = 7, Rows = 6 }, new Message());
     c4.Player1 = new Human();
     c4.Player2 = new Computer(2);
 }
Exemplo n.º 9
0
        public void Setup()
        {
            boardSettings = new BoardSettings() { Columns = 7, Rows = 6, WinningCount = 4};

            c4 = new Connect4(boardSettings, new Message());
            c4.Player1 = new Human();
            c4.Player2 = new Computer(2, boardSettings);
        }