Jump to content

Problem with a python program


Requoter

Recommended Posts

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 = ['*', '*', '#', '#', '*', '#',

'#', '#', '*', '*', '#', '#',

'*', '#', '#', '*', '*', '*',

'*', '*', '#', '#', '#', '#',

'#', '#', '*', '*', '*', '#',

'*', '*', '#', '#', '#', '*']

Link to comment
Share on other sites

room = ['*', '*', '#', '#', '*', '#',

'#', '#', '*', '*', '#', '#',

'*', '#', '#', '*', '*', '*',

'*', '*', '#', '#', '#', '#',

'#', '#', '*', '*', '*', '#',

'*', '*', '#', '#', '#', '*']

 

From python's point of view, that's not a 6*6 grid, that's a 36*1 grid.

 

a 3*3 would look like this (newlines optional):

 

room = [

['#','#','#,'],

['#','#','#,'],

['#','#','#,'],

]

 

or simply ['###','###','*##'], with the dirty room here being refferenced as room[2][0] (the 0th charector in the 2nd list item)

 

every position on a 2d grid (e.g., a list of lists) can be refferenced by room[a], so i assume it'd just be a case of incrimenting/decreasing a or b to move up/down/left/right.

Edited by Dak
6*6 != 32
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.