示例#1
0
        public static INodeInformation GreedyMoveToFirstClaimable(IAgentUpdateInfo agentUpdate, IGAgent agent)
        {
            List<INodeInformation> possibleNodes =
                NextLevelFirstClaimable(agent.Deck,
                                        new List<INodeInformation>() {agentUpdate.Node},
                                        agentUpdate.Owner.Id,1);

            if (!possibleNodes.Any())
            {
               ICollection<INodeInformation> nodeInformations = agentUpdate.Node.Exits.Values;
               possibleNodes =  NextLevelFirstClaimable(agent.Deck, nodeInformations, agentUpdate.Owner.Id,2);

                if (!possibleNodes.Any())
                {
                    var nextLevel = new List<INodeInformation>();

                    //3rd level
                    foreach (INodeInformation nodeInformation in nodeInformations)
                    {
                     nextLevel.AddRange(nodeInformation.Exits.Values);
                    }

                  possibleNodes =  NextLevelFirstClaimable(agent.Deck, nextLevel, agentUpdate.Owner.Id,3);
                }

            }

               return PickMove(agentUpdate, possibleNodes, agent);
        }
示例#2
0
        public void setup()
        {
            _deck = MockRepository.GenerateMock<IDeck>();
            _agent = MockRepository.GenerateMock<IGAgent>();
            _agent.Stub(x => x.Deck).Return(_deck);

            _owner = MockRepository.GenerateMock<IPlayer>();
            _owner.Stub(x => x.Id).Return(Guid.NewGuid());
            _owner.Stub(x => x.DisplayHandle).Return("owner1");

            _owner2 = MockRepository.GenerateMock<IPlayer>();
            _owner2.Stub(x => x.Id).Return(Guid.NewGuid());
            _owner2.Stub(x => x.DisplayHandle).Return("owner2");

            myPlayer = MockRepository.GenerateMock<IPlayer>();
            myPlayer.Stub(x => x.Id).Return(Guid.NewGuid());
            myPlayer.Stub(x => x.DisplayHandle).Return("player");

            uid = MockRepository.GenerateMock < IPlayer>();
            uid.Stub(x => x.Id).Return(Guid.NewGuid());
            uid.Stub(x => x.DisplayHandle).Return("uid0");
        }
示例#3
0
        private static INodeInformation PickMove(IAgentUpdateInfo agentUpdate, IEnumerable<INodeInformation> possibleNodes, IGAgent agent)
        {
            INodeInformation targetNode;
            if (CanAgentMove(agentUpdate))
            {
              targetNode = possibleNodes.Any() ? possibleNodes.First() : GetRandomNode(agentUpdate,agent.Deck);
              NodeExit exit = agentUpdate.Node.RouteTo(agentUpdate.Node, targetNode.Layer, targetNode.Row, targetNode.Column);

                if (exit != NodeExit.None)
                {
                    agent.Move(agentUpdate.Node.Exits[exit]);
                }
            }
            else
            {
                targetNode = agentUpdate.Node;
            }

            return targetNode;
        }