Exemplo n.º 1
0
        public override void RefreshView(object genome)
        {
            IBlackBox phenome;

            if (_info.EvaluationMode == IPDExperiment.EvaluationMode.Novelty)
            {
                phenome = _info.BestNoveltyGenome();
            }
            else
            {
                phenome = _genomeDecoder.Decode(genome as NeatGenome);
            }

            _players[0] = new Players.IPDPlayerPhenome(phenome);
            for (int i = 1; i < _players.Length; i++)
            {
                var g = new IPDGame(_info.NumberOfGames, _players[0], _players[i]);
                g.Run();
                _games[0, i] = g;
                _games[i, 0] = g;
            }

            UpdateTable();
            UpdateArchiveGraph();
        }
Exemplo n.º 2
0
        private PhenomeInfo EvaluateBehavior(IBlackBox phenome)
        {
            Players.IPDPlayerPhenome p = new Players.IPDPlayerPhenome(phenome);
            double[] scores            = new double[_info.OpponentPool.Length + 1];
            double   wins         = 0;
            int      phenomeIndex = _info.OpponentPool.Length;

            IPDGame[] games = new IPDGame[phenomeIndex];

            for (int i = 0; i < phenomeIndex; i++)
            {
                games[i] = new IPDGame(_info.NumberOfGames, _info.OpponentPool[i], p);
                var s = games[i].Evaluate(_info.RandomRobustCheck);
                scores[i]            += s.a + _info.OpponentScores[i];
                scores[phenomeIndex] += s.b;

                if (s.a == s.b)
                {
                    wins += 0.5;
                }
                else if (s.b > s.a)
                {
                    wins += 1.0;
                }
            }

            double score = scores[phenomeIndex];
            var    ranks = scores.Rank();
            double rank  = (ranks[phenomeIndex] - 1) / ((double)ranks.Length - 1);

            if (rank == 1.0d)
            {
                //Ties are not allowed
                for (int i = 0; i < scores.Length; i++)
                {
                    if (scores[i] == scores[phenomeIndex] && i != phenomeIndex)
                    {
                        rank -= (1.0 / (double)_info.OpponentPool.Length) / 2.0;
                    }
                }
            }

            return(new PhenomeInfo(phenome, rank, wins, score, games));
        }
Exemplo n.º 3
0
            private void OpponentInfo()
            {
                var pool = OpponentPool;

                OpponentScores    = new double[pool.Length];
                OpponentPoolGames = new IPDGame[pool.Length, pool.Length];
                for (int i = 0; i < pool.Length; i++)
                {
                    for (int j = i + 1; j < pool.Length; j++)
                    {
                        if (i != j) //currently not against each other but..
                        {
                            IPDGame g = new IPDGame(NumberOfGames, pool[i], pool[j]);
                            var     s = g.Evaluate(RandomRobustCheck);

                            OpponentPoolGames[i, j] = g;
                            OpponentPoolGames[j, i] = g;

                            OpponentScores[i] += s.a;
                            OpponentScores[j] += s.b;
                        }
                    }
                }
            }
Exemplo n.º 4
0
        private void ShowHistory(IPDGame game)
        {
            IPDPlayer[] players = new IPDPlayer[2] {
                game.A, game.B
            };

            int  formWidth = 320;
            Form history   = new Form();

            history.Text            = game.ToString();
            history.Size            = new Size(formWidth, 500);
            history.FormBorderStyle = FormBorderStyle.Sizable;
            history.MinimumSize     = new Size(formWidth, 300);
            history.MaximumSize     = new Size(formWidth, 5000);
            history.MaximizeBox     = false;
            history.MinimizeBox     = false;

            DataGridView table = new DataGridView();

            table.Location           = new Point(0, 0);
            table.Dock               = DockStyle.Fill;
            table.AllowUserToAddRows = false;
            table.RowHeadersWidth    = 50;
            table.EditMode           = DataGridViewEditMode.EditProgrammatically;

            DataGridViewColumn[] cols       = new DataGridViewColumn[4];
            string[]             colHeaders = new string[4] {
                players[0].Name, players[1].Name, "Result", "Score"
            };
            for (int i = 0; i < cols.Length; i++)
            {
                cols[i]            = new DataGridViewTextBoxColumn();
                cols[i].HeaderText = colHeaders[i];
                cols[i].SortMode   = DataGridViewColumnSortMode.NotSortable;
                cols[i].Width      = 60;
            }
            table.Columns.AddRange(cols);

            table.Rows.Add(game.Length + 1);
            int a = 0, b = 0;

            for (int i = 0; i < game.Length; i++)
            {
                table.Rows[i].HeaderCell.Value = i.ToString();
                table.Rows[i].Cells[0].Value   = game.GetChoice(players[0], i);
                table.Rows[i].Cells[1].Value   = game.GetChoice(players[1], i);
                table.Rows[i].Cells[2].Value   = game.GetPast(players[0], i) + ", " + game.GetPast(players[1], i);
                a += IPDGame.PastToScore(game.GetPast(players[0], i)); b += IPDGame.PastToScore(game.GetPast(players[1], i));
                table.Rows[i].Cells[3].Value = a + ", " + b;
            }

            DataGridViewRow total = new DataGridViewRow();

            table.Rows.Add();
            table.Rows[game.Length].HeaderCell.Value = "T";
            table.Rows[game.Length].Cells[0].Value   = game.GetScore(players[0]).ToString("F0");
            table.Rows[game.Length].Cells[1].Value   = game.GetScore(players[1]).ToString("F0");

            history.Controls.Add(table);
            history.Show();
        }
Exemplo n.º 5
0
 public abstract IPDGame.Choices Choice(IPDGame game);