Skip to main content
deleted 6 characters in body
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

I had to write a little function thethat would find a key in a dictionary given a value, since when backtracking we know the id of the room we are trying to get to, but not which door to use to get to it.

I had to write a little function the would find a key in a dictionary given a value, since when backtracking we know the id of the room we are trying to get to, but not which door to use to get to it.

I had to write a function that would find a key in a dictionary given a value, since when backtracking we know the id of the room we are trying to get to, but not which door to use to get to it.

changed algorithm description to list.
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

Each time the agent enters a room it searches its knowledge dictionary for information on the room. If there are no entries for this room then it creates a new RoomKnowledge and adds this to it's knowledge dictionary.

It checks to see if the current room is the target room, if so then it returns.

If there are doors in this room we haven't visited, we go through the door and store where it lead to. We then continue the loop.

If there weren't any unvisited doors, we backtrack through the rooms we have visited to find one with unvisited doors.

  • Each time the agent enters a room it searches its knowledge dictionary for information on the room. If there are no entries for this room then it creates a new RoomKnowledge and adds this to it's knowledge dictionary.

  • It checks to see if the current room is the target room, if so then it returns.

  • If there are doors in this room we haven't visited, we go through the door and store where it lead to. We then continue the loop.

  • If there weren't any unvisited doors, we backtrack through the rooms we have visited to find one with unvisited doors.

The backtracking isn't very efficient - in the worst case scenario it could go through every room to get to an adjacent room, but backtracking is fairly rare - in the above tests it only backtracks three times. I've avoided putting exception handling in to keep the code concise. Any comments on my Python appreciated :)

Each time the agent enters a room it searches its knowledge dictionary for information on the room. If there are no entries for this room then it creates a new RoomKnowledge and adds this to it's knowledge dictionary.

It checks to see if the current room is the target room, if so then it returns.

If there are doors in this room we haven't visited, we go through the door and store where it lead to. We then continue the loop.

If there weren't any unvisited doors, we backtrack through the rooms we have visited to find one with unvisited doors.

The backtracking isn't very efficient - in the worst case scenario it could go through every room to get to an adjacent room, but backtracking is fairly rare - in the above tests it only backtracks three times. Any comments on my Python appreciated :)

  • Each time the agent enters a room it searches its knowledge dictionary for information on the room. If there are no entries for this room then it creates a new RoomKnowledge and adds this to it's knowledge dictionary.

  • It checks to see if the current room is the target room, if so then it returns.

  • If there are doors in this room we haven't visited, we go through the door and store where it lead to. We then continue the loop.

  • If there weren't any unvisited doors, we backtrack through the rooms we have visited to find one with unvisited doors.

The backtracking isn't very efficient - in the worst case scenario it could go through every room to get to an adjacent room, but backtracking is fairly rare - in the above tests it only backtracks three times. I've avoided putting exception handling in to keep the code concise. Any comments on my Python appreciated :)

added 63 characters in body, I was using two meanings of the word map, so I replaced some with dictionary.
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39

In this case the agent should be able to query the environment for the id of the room it is in, it should be able to get a count of the doors in a particular roomin the room it is in (note this is not the id's of the rooms the doors lead to!) and he should be able to move through a door by specifying a door index. Anything else an agent knows has to be figured out by the agent itself.

In this case the agent should be able to query the environment for the id of the room it is in, it should be able to get a count of the doors in a particular room (note this is not the id's of the rooms the doors lead to!) and he should be able to move through a door by specifying a door index. Anything else an agent knows has to be figured out by the agent itself.

In this case the agent should be able to query the environment for the id of the room it is in, it should be able to get a count of the doors in the room it is in (note this is not the id's of the rooms the doors lead to!) and he should be able to move through a door by specifying a door index. Anything else an agent knows has to be figured out by the agent itself.

added 63 characters in body, I was using two meanings of the word map, so I replaced some with dictionary.
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39
Loading
Source Link
CiscoIPPhone
  • 5.3k
  • 3
  • 34
  • 39
Loading