Exemple #1
0
        private void InitRound()
        {
            Countdown = 60;
            int i = 0;

            int[] numbers = Numbers.ToArray();


            PlayerOperands  = new List <int>();
            PlayerOperators = new List <string>();

            timer.Interval = 1000;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();

            lblPlayerScoreDisplay.Text   = PlayerScore.ToString();
            lblComputerScoreDisplay.Text = ComputerScore.ToString();
            lblRoundNo.Text = "Round " + RoundNo;

            Button[] numberButtons = new Button[] { btnNum1, btnNum2, btnNum3, btnNum4, btnNum5, btnNum6 };

            foreach (Button b in numberButtons)
            {
                b.Text = numbers[i].ToString();
                i++;
            }

            switch (Difficulty)
            {
            case "easy":
                ea  = new EasyAlgorithm(Goal, Numbers.ToList());
                gca = new GetComputerAnswer(ea.GetComputerAnswer);
                break;

            case "normal":
                double Temperature = 1000;
                a   = new Algorithm(Goal, Temperature, Numbers.ToList());
                gca = new GetComputerAnswer(a.GetComputerAnswer);
                break;
            }


            AiWorker.RunWorkerAsync();
        }
Exemple #2
0
        /// <summary>
        /// Called when the game starts, providing all info.
        /// </summary>
        /// <param name="map">The game map.</param>
        /// <param name="me">The player being setup..</param>
        /// <param name="players">All the players.</param>
        /// <param name="companies">All companies on the board.</param>
        /// <param name="passengers">All the passengers.</param>
        /// <param name="ordersEvent">Callback to pass orders to the engine.</param>
        public void Setup(GameMap map, Player me, List<Player> players, List<Company> companies, List<Passenger> passengers, PlayerAIBase.PlayerOrdersEvent ordersEvent)
        {
            // start the thread
            aiWorker = new AiWorker(map, me.Guid, companies, ordersEvent);
            aiThread = new Thread(aiWorker.MainLoop) {Name = me.Name.Replace(' ', '_'), IsBackground = true};
            aiThread.Start();

            // cause it to pick a passenger to pick up and calculate the path to that company.
            aiWorker.AddMessage(PlayerAIBase.STATUS.NO_PATH, me, AllPickups(me, passengers));
        }