Ejemplo n.º 1
0
        // fire off a game with selected parameters
        async void StartGame()
        {
            // check if two bots picked
            // check if map picked

            var p1 = Bots.Where(b => b.Player1).FirstOrDefault();
            var p2 = Bots.Where(b => b.Player2).FirstOrDefault();

            if (p1 == null || p2 == null)
            {
                // sageBox.Show("Select player 1 and 2");
                return;
            }

            LoadBackground();
            frameQueue = new ConcurrentQueue <FrameInfo>(); // erase old one
            var queue = frameQueue;                         // use local to avoid some background thread problems - todo - better to cancel and check cancel took, but more complicated

            Frame           = 0;
            planetDiameters = null;
            while (queue.TryDequeue(out var s))
            { // nothing
            }
            History.Clear();

            var dispatcher = Dispatcher.CurrentDispatcher;

            var res = await Task.Factory.StartNew(() =>
            {
                return(GameRunner.PlayOneGame(p1.player, p2.player, RandomSeed, queue.Enqueue, FrameMax));
            });
        }
Ejemplo n.º 2
0
        public static HeadToHeadScore PlayMatch(int rounds, Player player1, Player player2, int maxFrame)
        {
            var scorer = new HeadToHeadScore(player1, player2);

            for (var i = 0; i < rounds; ++i)
            {
                var res = GameRunner.PlayOneGame(player1, player2, 1234, null, maxFrame);
                scorer.Tally(player1, player2, res);
            }

            return(scorer);
        }