aimacode / aima-javascript

Javascript visualization of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
http://aimacode.github.io/aima-javascript/
MIT License
544 stars 219 forks source link

Adds Erratic Vacuum World Problem Diagram #86

Closed Rishav159 closed 7 years ago

Rishav159 commented 7 years ago

This commit adds a visualization for Erratic Vacuum World under 'Searching with non-deterministic actions' in chapter 4. The world has 5 states, unlike the book. The reader is presented with a random state from the state space. He/She can record a sequence of actions that can solve the problem. The sequence is executed in the erratic world.

redblobgames commented 7 years ago

Hey this is pretty cool!

Since the world is erratic I'd like to be able to set up a sequence of actions, then run it on the world to see how it performs, then run the same sequence again on the world to see how it performs. If I press Play again, it's not very useful, because it's comparing the same sequence on a different world state. If I press Restart, it's not very useful for evaluating my sequence because it erases the sequence.

I think it'd be useful to reset the world state when you press Play. That way you can see how that sequence would behave under the same conditions, but with different erratic behavior.

redblobgames commented 7 years ago

I think to make the world state the same you'd need a way to generate a random world state (robot position and dirty floor array) and then set the Erratic Vacuum World to that state. Then when you Restart, it could generate a new initial state, and then when you press Play it would let you run your chosen sequence on that same state.

redblobgames commented 7 years ago

Put a different way:

I think the idea is that

  1. You look at the world state (randomness type 1)
  2. You make a plan
  3. You watch the robot execute the plan (randomness type 2)

It's hard to evaluate the plan when both types of randomness happen with the Play button. I think if you can separate the two types of randomness (by saving type 1 in a state variable, and resetting to that each time) the Play button could be used to see how randomness type 2 affects the situation, without randomness type 1 mixed in.

Rishav159 commented 7 years ago

@redblobgames I am slightly confused about what you said. I understood the part about the play button. The diagram plays the recorded sequence when the play button is pressed. But if it is pressed again, it actually runs on the state resulting from the previous actions which is not useful. So you want me to reset the state back to the initial state and run the sequence again if the play is used. Right? I am confused about the Restart Button. Currently, it erases the sequence and generates a completely new random state. Is that behavior fine? It looks good to me.

Rishav159 commented 7 years ago

I have updated the Play button to reset the state to the initial state. Also added a clear button that allows the user to clear the recorded sequence and then record a new one for the same initial state. As before, the restart button simply clears everything and generates a new random initial state.

redblobgames commented 7 years ago

Great! I think it gives me a good way to evaluate how my schedule performs.