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);
                    }
                }
            }
        }
示例#2
0
        public override IPDGame.Choices Choice(IPDGame game)
        {
            lock (_choiceLock)
            {
                if (game.T == 0)
                {
                    game.HasRandom = _hasRandom;
                    return(_start);
                }

                switch (game.GetPast(this, game.T - 1))
                {
                case IPDGame.Past.T:
                    return(CooperateProbability(_t));

                case IPDGame.Past.R:
                    return(CooperateProbability(_r));

                case IPDGame.Past.P:
                    return(CooperateProbability(_p));

                case IPDGame.Past.S:
                    return(CooperateProbability(_s));
                }

                throw new Exception("How did we get here?");
            }
        }
        public override IPDGame.Choices Choice(IPDGame game)
        {
            if (game.T == 0)
            {
                return(FIRST_CHOICE);
            }

            int i = 0;

            for (int k = 1; k <= _phenome.InputSignalArray.Length / 2; k++)
            {
                IPDGame.Past p = game.GetPast(this, game.T - k);
                //My choice (0 == C, 1 == D)
                _phenome.InputSignalArray[i++] = (p == IPDGame.Past.R || p == IPDGame.Past.S) ? 0 : 1;
                //Opponent choice
                _phenome.InputSignalArray[i++] = (p == IPDGame.Past.T || p == IPDGame.Past.R) ? 0 : 1;
            }

            _phenome.Activate();
            if (!_phenome.IsStateValid)
            {   // Any black box that gets itself into an invalid state is unlikely to be
                // any good, so lets just bail out here.
                return(IPDGame.Choices.R);
            }

            return((_phenome.OutputSignalArray[0] > _phenome.OutputSignalArray[1]) ? IPDGame.Choices.C : IPDGame.Choices.D);
        }
        public override IPDGame.Choices Choice(IPDGame game)
        {
            lock (_choiceLock)
            {
                if (_initialChoices.Count > 0)
                {
                    return(_initialChoices.Dequeue());
                }
                else
                {
                    if (game.GetPast(this, game.T - 1) == IPDGame.Past.S || game.GetPast(this, game.T - 1) == IPDGame.Past.P)
                    {
                        _totalPSScore++;
                    }
                    else
                    {
                        _totalTRScore++;
                    }

                    return((_totalPSScore >= _totalTRScore) ? IPDGame.Choices.D : IPDGame.Choices.C);
                }
            }
        }
示例#5
0
        public override int Evaluate(ref DecisionTree.Iterator iterator, IPDGame game)
        {
            int t = game.T - _k - iterator.K;

            if (t < 0)
            {
                return(DecisionTree.INVOKE_Q);
            }

            if (_x.Contains(game.GetPast(iterator.Player, t)))
            {
                iterator.Alpha += _alphaAdd;
                return(_left);
            }
            else
            {
                iterator.Beta += _betaAdd;
                return(_right);
            }
        }
示例#6
0
 private bool C(IPDGame game, int time)
 {
     return(game.GetPast(this, time) == IPDGame.Past.R || game.GetPast(this, time) == IPDGame.Past.T);
 }