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)); }
public VandalAgent(VandalAgent other) : this(other.Id, other.Position, other.Delay, other.Waiting, other.Blocking) { }