示例#1
0
        public short GetPlay(GameManager gameManager, ComputerPlayer computerPlayer)
        {
            var node = new EvaluationNode(ref gameManager.GameState, computerPlayer.GetWeights(gameManager.TurnExcludingPasses));

            var indexesAndScores = new List <KeyValuePair <short, float> >();

            //node.ChildNodeReferences.ForEach(x =>
            //                                  {
            //                                      var child = AnalysisNodeCollection.GetAnalysisNode(x);
            //                                      var score = Search(ref child, gameManager.PlayerIndex);
            //                                      indexesAndScores.Add(new KeyValuePair<short, float>(child.PlayIndex, score));
            //                                  });

            var maxDepth = computerPlayer.GetSearchDepth(gameManager.TurnExcludingPasses);

            node.Children.ToList().ForEach(x =>
            {
                var score = computerPlayer.Search(x, new SearchConfig(gameManager.PlayerIndex, 0, maxDepth, computerPlayer.PlayerUiSettings.UseTranspositionTable));
                indexesAndScores.Add(new KeyValuePair <short, float>((short)x.PlayIndex, score));
            });

            var rankedScores = indexesAndScores.OrderByDescending(x => Math.Abs(x.Value));

            return(rankedScores.First().Key);
        }
示例#2
0
        public EvaluationNodeReference AddAnalysisNode(ref EvaluationNode evaluationNode)
        {
            var buffer = GetBuffer();

            var bufferIndex = (ushort)_evaluationNodeBuffers.IndexOf(buffer);

            buffer.Entries[buffer.LowestFreeSlot] = evaluationNode;
            var reference = new EvaluationNodeReference {
                Buffer = bufferIndex, Index = buffer.LowestFreeSlot
            };

            buffer.LowestFreeSlot++;

            return(reference);
        }