Exemplo n.º 1
0
        public override IPDGame.Choices Choice(IPDGame game)
        {
            lock (_choiceLock)
            {
                IPDGame.Choices pr;
                int             prt = game.T - 1;

                if (_initialChoices.Count > 0)
                {
                    return(_initialChoices.Dequeue());
                }
                else
                {
                    pr = game.GetChoice(this, prt);

                    if (pr == IPDGame.Choices.C)
                    {
                        _totalCooperateScore += (int)game.GetPast(this, prt);
                    }
                    else
                    {
                        _totalDefectScore += (int)game.GetPast(this, prt);
                    }

                    if (_initialChoices.Count > 0)
                    {
                        return(_initialChoices.Dequeue());
                    }
                    else
                    {
                        return((_totalDefectScore > _totalCooperateScore) ? IPDGame.Choices.D : IPDGame.Choices.C);
                    }
                }
            }
        }