Exemple #1
0
        public void Initialize(PlayerNumber[] numbers, GameSimulator simulator)
        {
            var self     = numbers.First(n => n.PlayerId == Id);
            var opponent = numbers.First(n => n.PlayerId == Id.Opponent);

            Candidates = GameRules.GetCandidates(self).Select(Variable).ToArray();
            Knowledge  = Xor(Candidates);

            if (Candidates.Length <= 1)
            {
                return;
            }

            // 特定のプレイヤーの思考の中で無限ループになる場合、「わからない」と結論付けます (知識を追加しない)。
            foreach (var v in Candidates.Where(c => c.Statement.Number < opponent.Number))
            {
                var simulationResult = simulator.Start(new[] { self, v.Statement }, Id.Opponent);
                var r = Knowledge.GetOrCreateVariable(simulationResult);
                Knowledge &= Imply(v, simulationResult.Value == true ? r : !r);
            }
        }
Exemple #2
0
        public void Initialize(int selfNumber)
        {
            var self = new PlayerNumber(Id, selfNumber);

            Candidates = GameRules.GetCandidates(self).Select(Variable).ToArray();
            Knowledge  = Xor(Candidates);

            if (Candidates.Length <= 1)
            {
                return;
            }

            var simulator = new GameSimulator();

            foreach (var v in Candidates)
            {
                var simulationResult = simulator.Start(new[] { self, v.Statement }, Id.Opponent);
                var r = Knowledge.GetOrCreateVariable(simulationResult);
                Knowledge &= Imply(v, simulationResult.Value == true ? r : !r);
            }
        }