示例#1
0
        /// <summary>
        /// Gets a dictionary mapping TimedMoves to the agents that already made them
        /// and returns a list of agents this TimedMove collides with.
        /// </summary>
        /// <param name="timedMovesToAgentNumLists"></param>
        /// <returns></returns>
        public IReadOnlyList <int> GetColliding(ConflictAvoidanceTable timedMovesToAgentNumLists)
        {
            List <int> ans = null;

            Move.Direction saveDirection = this.direction;
            Direction[]    directions;
            if (Constants.ALLOW_DIAGONAL_MOVE)
            {
                directions = Move.validDirections;
            }
            else
            {
                directions = Move.validDirectionsNoDiag;
            }
            foreach (var direction in directions) // TEMP FIX! Need to get rid of the whole NO_DIRECTION SHTICK! It breaks transitivity!
            {
                this.direction = direction;
                if (timedMovesToAgentNumLists.ContainsKey(this))
                {
                    if (ans == null)
                    {
                        ans = new List <int>(timedMovesToAgentNumLists[this]);
                    }
                    else
                    {
                        ans.AddRange(timedMovesToAgentNumLists[this]);
                    }
                }
            }
            this.direction = saveDirection;

            if (Constants.ALLOW_HEAD_ON_COLLISION == false)
            {
                this.setOppositeMove();
                if (timedMovesToAgentNumLists.ContainsKey(this)) // Check direction too now
                {
                    if (ans == null)
                    {
                        ans = new List <int>(timedMovesToAgentNumLists[this]);
                    }
                    else
                    {
                        ans.AddRange(timedMovesToAgentNumLists[this]);
                    }
                }
                this.setOppositeMove();
            }

            if (ans != null)
            {
                return(ans);
            }
            else
            {
                return(TimedMove.emptyList);
            }
        }
示例#2
0
 /// <summary>
 /// Updates the conflictCount member according to given CATs. Table may be null.
 /// </summary>
 /// <param name="CAT"></param>
 public void UpdateConflicts(ConflictAvoidanceTable CAT)
 {
     if (this.prev == null)
     {
         return;
     }
     if (CAT != null)
     {
         for (int i = 0; i < allSteps.Length; i++)
         {
             if (CAT.ContainsKey(allSteps[i].move))
             {
                 conflictCount += CAT[allSteps[i].move].Count;
             }
         }
     }
 }