Index
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Python Vacuum Robot Script

3 posters

Go down

Python Vacuum Robot Script Empty Python Vacuum Robot Script

Post by Broeder 5/11/2012, 2:17 pm

http://pastebin.com/gqy1shKT

So i sent in this script, and it works as it should. But now i hear that i need to change things because:
"References to objects go wrong, robots have another robot instead of a room, because of this roomfunctions are being called at a robotobject"

and for 1. i dont know exactly what that means, and 2. i dont see what i should change since the script works.

The part of the script they are most likely talking about is probably at problem 2. But since i dont see anything going wrong i dont know what i should change


Last edited by Broeder on 15/11/2012, 8:15 pm; edited 1 time in total
Broeder
Broeder
Grandmaster (2000 posts)
Grandmaster (2000 posts)


Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Swadq 5/11/2012, 2:40 pm

What exactly are you stuck with?
Swadq
Swadq
Grandmaster (2000 posts)
Grandmaster (2000 posts)


http://swadq.com

Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Broeder 5/11/2012, 2:51 pm

Its kind of hard to just pinpoint it in the script since its a lot of different aspects,

but for instance the standard robot:

in a 5x5 room it has to clean 25 tiles so it also says it takes 25 time steps, but thats only in the ideal situation and would never actually happen. It should actually be close to 150 time steps to completely clean a 5×5 room
Broeder
Broeder
Grandmaster (2000 posts)
Grandmaster (2000 posts)


Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Swadq 5/11/2012, 3:06 pm

What do you think is causing the error and what have you tried?
Swadq
Swadq
Grandmaster (2000 posts)
Grandmaster (2000 posts)


http://swadq.com

Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Broeder 15/11/2012, 8:16 pm

Ok so i fixed the earlier error and handed it in around a week ago, and today i got back feedback and i editted the opening post. I was wondering if i could get some more help on it Smile?
Broeder
Broeder
Grandmaster (2000 posts)
Grandmaster (2000 posts)


Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Swadq 16/11/2012, 9:06 am

I'm not sure if they're saying the your script has an error, or if that is task 3, to fix it.

Because Python isn't strongly typed, it's possible for objects to be passed which aren't of the type you're expecting. This is fine when you're in full control of your code, or in instances where you need that sort of functionality without having them extend another class. However, if you were to write a library, for example, it's possible that you might be given an object you weren't expecting. You need to handle this gracefully, probably throwing an exception, making sure that the method doesn't completely normally. Often, this will happen naturally, but it's possible that two objects have methods which are named the same, which could result in a function completing normally but returning unexpected values.

What they're saying is that a robot object has a pointer to a room object - but for some reason, that pointer is actually to another robot object. So you need to do something - first, I'd figure out whether that's already a problem with your code, and then fix it gracefully. If it's not a problem, make it a problem, fix it gracefully, and then revert it back to normal (keeping the changes to any functions)
Swadq
Swadq
Grandmaster (2000 posts)
Grandmaster (2000 posts)


http://swadq.com

Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by bs merchants 16/11/2012, 9:52 pm

From what Swadq was saying, sounds like you need some serious type-checking. It's a pain, I know from my Javascripting experiences, but ultimately it prevents horrible things from happening Razz
bs merchants
bs merchants
Forum Fanatic (1000 posts)
Forum Fanatic (1000 posts)


Back to top Go down

Python Vacuum Robot Script Empty Re: Python Vacuum Robot Script

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum