![]() |
|
#1
|
|||
|
|||
Problem with an assignmentI have an assignment where I'm supposed to implement a simple vacuum cleaner agent with a randomized agent function. Basically there's a world with 36 rooms in a 6 x 6 grid. The vacuum cleaner determines which square is it in and whether there is dirt in the square. It can choose to move left, move right, suck up the dirt, or do nothing.
I'm new to python and I'm having really hard time to figure out what to do and how to do this. This is all I've done so far and I kind of have a mental block on what do do next. Specifically how would I implement the simulations of sucking dirt or perform the movements left, right, up, or down. If anyone can push me in the right direction I'd appreciate it. # vacuum cleaner DIRTY = '*' CLEAN = '#' NUM_ROOMS = 36 room = ['*', '*', '#', '#', '*', '#', '#', '#', '*', '*', '#', '#', '*', '#', '#', '*', '*', '*', '*', '*', '#', '#', '#', '#', '#', '#', '*', '*', '*', '#', '*', '*', '#', '#', '#', '*'] |
|||
|
#2
|
||||
|
||||
Re: Problem with an assignmentIs this similar to the Knight's Tour problem, where you have to go to every room? Is this supposed to be a graphical "game" showing the vacuum as it moves or is it text? For example, is it supposed to display a grid like you have above or does is simply spit out lines to the console like "Moving to room 24. There is dirt present."?
__________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#3
|
|||
|
|||
Re: Problem with an assignmentQuote:
No. Quote:
Yes |
|
#4
|
||||
|
||||
Re: Problem with an assignmentIn pseudocode, here are some options:
Code:
Code:
There are several ways to consider position. For example, you could assign each room a numerical value 1-36 or you could give it a tuple based on it's x and y coordinates. Personally I was say a tuple is easier because you can eassily determine whether the vaccuum is next to wall by looking at one of the tuple values. Then all you have to do is update the tuple each time the vaccuum moves. When it's ready to move again, you look at whether it's next to a wall; if so, you eliminate that direction as a movement option. __________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A class problem, very confused!! | allenfanwenyuan | C++ Forum | 2 | 16-Sep-2007 06:13 |
| Torrents Download Problem | chandeep | Computer Software Forum - Linux | 7 | 09-Oct-2006 23:37 |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 13:31 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 08:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The