GIDForums  

Go Back   GIDForums > Computer Programming Forums > Python Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Oct-2008, 14:56
Requoter Requoter is offline
Awaiting Email Confirmation
 
Join Date: Mar 2005
Posts: 11
Requoter is on a distinguished road

Problem with an assignment


I 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  
Old 04-Oct-2008, 08:37
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,635
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Problem with an assignment


Is 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  
Old 04-Oct-2008, 11:24
Requoter Requoter is offline
Awaiting Email Confirmation
 
Join Date: Mar 2005
Posts: 11
Requoter is on a distinguished road

Re: Problem with an assignment


Quote:
Originally Posted by crystalattice
Is this supposed to be a graphical "game" showing the vacuum as it moves

No.

Quote:
is it supposed to display a grid like you have above...?

Yes
  #4  
Old 04-Oct-2008, 22:32
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,635
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Problem with an assignment


In pseudocode, here are some options:
Code:
if floor dirty: change icon from "*" to "#" else: ignore

Code:
get random number convert to integer value from 1-4 if value is equal to 1: move up else if value is equal to 2: move right else if value is equal to 3: move down else if value is equal to 4: move left

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 GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 13:18.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.