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

            newState.UpdateAgent(newAgent);

            var position = newState.Graph.Vertex(Position);
            var paths    = newState.Graph.Dijkstra(position);

            var selectedPath = Passengers > 0 ? FindShelter(paths, oldState) : FindPeople(paths, oldState);

            if (selectedPath.Count <= 1)
            {
                return(new NoOp(oldState, newState, Id));
            }

            return(new Traverse(oldState, newState, Id, selectedPath.Vertices[1].Id));
        }
Example #2
0
 public GreedyAgent(GreedyAgent other) : base(other.Id, other.Position, other.Passengers, other.PeopleSaved)
 {
 }