예제 #1
0
        protected override IAction CalculateMove(IState oldState)
        {
            var newState = oldState.Clone();
            var newAgent = new VandalAgent(this);

            newState.UpdateAgent(newAgent);

            if (Waiting < Delay)
            {
                newAgent.Waiting = Waiting + 1;
                return(new NoOp(oldState, newState, Id));
            }

            newAgent.Waiting  = 0;
            newAgent.Blocking = !Blocking;

            var neighbors = newState.Graph.Vertex(Position).Neighbors;

            if (neighbors.Count == 0)
            {
                return(new NoOp(oldState, newState, Id));
            }

            var minimal = neighbors.Aggregate(neighbors[0], (min, next) =>
                                              newState.Graph.EdgeWeight(Position, next) < newState.Graph.EdgeWeight(Position, min) ? next : min);

            if (Blocking)
            {
                return(new Block(oldState, newState, Id, minimal));
            }

            return(new Traverse(oldState, newState, Id, minimal));
        }
예제 #2
0
 public VandalAgent(VandalAgent other) : this(other.Id, other.Position, other.Delay, other.Waiting, other.Blocking)
 {
 }