Hello everybody!
First of all, I'm not native english-speaker, but I try to make you understand me
My computer sciences-teacher gave us the task to create a labyrinth (maze?) in which there is an object, placed anywhere in the maze, and a goal for the object. Furthermore, the user is not allowed to help the object (but you have to start it with a click on e.g. the green flag) and the object is not allowed to cross the borders of the maze. When we have finished, our teacher will change the maze so that he can see that our script works in any other maze.
Okay, that far I got along pretty well, but my object needs very long to get to the goal and it's making detours. My question is now, how can I optimize the program, so that the object doesn't make any detours and goes straight to the goal? I would be very grateful for a script that I could try.
Thank you for helping me
greetings, babs
Last edited by babsibraun (2008-04-23 14:48:53)
Offline
babsibraun wrote:
Hell everybody!
First of all, I'm not native english-speaker, but I try to make you understand me
My computer sciences-teacher gave us the task to create a labyrinth (maze?) in which there is an object, placed anywhere in the maze, and a goal for the object. Furthermore, the user is not allowed to help the object (but you have to start it with a click on e.g. the green flag) and the object is not allowed to cross the borders of the maze. When we have finished, our teacher will change the maze so that he can see that our script works in any other maze.
Okay, that far I got along pretty well, but my object needs very long to get to the goal and it's making detours. My question is now, how can I optimize the program, so that the object doesn't make any detours and goes straight to the goal? I would be very grateful for a script that I could try.
Thank you for helping me
greetings, babs
If touching (the colour of the walls) change x/y -5?
Not sure if it'll help.
Oh, try to greet everyone will hello, not hell
regards
sonicpops
Offline
Thanks, I changed my "hell" into hello ^^ Unfortunately I cannot use the x/y-thing because it has to work for each maze you can think of...Here is my script:
<when green flag clicked>
<move( 50 )steps>
<repeat until><touching[ sprite3 ]>
<if><touching color[ black ]>
<move( -50 )steps>
<turn cw( 45 )degrees>
<move( 50 )steps>
<else>
<move( 50 )steps>
Last edited by babsibraun (2008-04-23 14:55:26)
Offline
Check out Canthiar's project at http://scratch.mit.edu/projects/Canthiar/13498
Offline
there's a block<glide( 1 )secs to x 99)y 100that might help you
Offline
<glide( 1 )secs to x 1 )y 1 )
Offline
Offline
That won't work, because if you draw a new maze and change where the the goal is, the object will go to the old spot and cut lines.
Offline
N-Wear, that's exactly my problem...Hmm, my computer sciences-teacher wanted the program yesterday, so I gave him the one I've done. We'll see how it'll work and how the other students have solved the problem I will definitely post the solution, maybe it's interesting for you, too.
Greeting, babs
Offline
then just keep making more of them like this<glide( 1)secs to x 1 )y 1 then make another one<glide( 1 )secs to x:(202 )y 23 and keep make them ^^
Offline
The way to do it would be to have a "sensor sprite" travel the maze first, at high speed, laying down a trail with the pen tool - but when it has to retrace its steps it detects the trail it laid and erases it. That way, when it reaches the goal there will only be a trail for the correct path through the maze. Then your "real" sprite can follow that trail.
Offline