Python Vacuum Robot Script
3 posters
Page 1 of 1
Python Vacuum Robot Script
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
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- Grandmaster (2000 posts)
Re: Python Vacuum Robot Script
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
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- Grandmaster (2000 posts)
Re: Python Vacuum Robot Script
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 ?
Broeder- Grandmaster (2000 posts)
Re: Python Vacuum Robot Script
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)
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)
Re: Python Vacuum Robot Script
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
bs merchants- Forum Fanatic (1000 posts)
Similar topics
» Python code
» Stuck on a python program
» AHK Minecraft Script
» Selective Ignore Script
» IRC Script (Tool): Mass Voice/Devoice
» Stuck on a python program
» AHK Minecraft Script
» Selective Ignore Script
» IRC Script (Tool): Mass Voice/Devoice
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|