Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
recursion, HELP PLEASE....
Old
miogi
Guest
 
Status:
Posts: n/a
Default recursion, HELP PLEASE.... - 11-19-2006, 04:39 PM

hello, I am kinda blind when it comes to programming. I am taking a computer course that has programming in it and I am having great difficult in understanding lots of elements in this Alice Program. We have a big asignment on trying to catch a butterfly with a net and I have to use Recursion. I have tried to understand chapter 8, but feel it is not coming easy.. I was wondering if you could point me in the right direction such as give me a few example worlds or any info I could use to get me started with this. I have to hand my code in very soon a couple of days and I am lost! I am not asking for you to give me the answers, just a way that I could understand it better. a few simple example worlds showing recursion with calling a method and maybe calling a parameter.. Please help if you can...

Lost with Alice.... Miogi
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 11-19-2006, 05:09 PM

Just remember the Geek Dictionary definition:
"Recursion: See Recursion"

The thread http://www.alice.org/community/showthread.php?t=484
may help - it has an example of recursive code I did.

Also try looking up recursion in Wiki - it has a prettly good section.
   
Reply With Quote
Old
Shadow Sovereign
Guest
 
Status:
Posts: n/a
Default 11-19-2006, 06:20 PM

Quote:
Originally Posted by DrJim View Post
Just remember the Geek Dictionary definition:
"Recursion: See Recursion"
I knew there was a Nerd Dictionary, but a Geek Dictionary? Now that's big!
   
Reply With Quote
thanks guys
Old
miogi
Guest
 
Status:
Posts: n/a
Default thanks guys - 11-20-2006, 03:06 AM

hey, just wanted to say thanks, I have actually looked at that file regarding recursion, I dl'd it before, but still trying to understand how to code such a thing and where to start. With everything else going on at School, it is hard to just sit down and give Alice another 15-18 hours of time .. lol, sometimes the biggest thing is to just get started.. My instructor went over it slightly in class, but I feel he went to fast for my brain. He put in some recursion with numbers and generated some hugh number(still dont understand what he did, lol) But anyhow, A code that is done such as Fibonacci is hard to understand. If someone has a small code with recursion that I could look at, just a sample of how to start with it, or even how to start with my butterfly one, that would be great.. Peace to all...

Miogi
   
Reply With Quote
Recursion: See GeekonCall
Old
DrJim
Guest
 
Status:
Posts: n/a
Talking Recursion: See GeekonCall - 11-20-2006, 06:54 PM

You're making it way too hard just because it sounds that way.

I suggest you look at the attached code and run the world a couple of times. Then delete the "if block" and reenter it yourself - you will get a warning from Alice that you are about to make a recursive call, that is, the method is calling itself. Say you know what you are doing (even if you don't ) and run the world again. If you did it right, you should get the same result. If you don't, compare your code back to the original.

Note that you have to have the "if test" there or it will run forever (or at least until your computer wears out or you pull the plug).
Attached Files
File Type: a2w GeekonCall.a2w (899.5 KB, 735 views)

Last edited by DrJim; 11-20-2006 at 06:59 PM.
   
Reply With Quote
Need help with Recursion.
Old
a002329
Guest
 
Status:
Posts: n/a
Default Need help with Recursion. - 09-18-2010, 02:36 AM

Create a sea world with a boat and an island. Position the island some distance
away from the boat, as shown in Figure 8-26. Write a method named sailTo,
which has an Object parameter. The method should cause the boat to move one
meter toward the object and then recursively call itself until the boat has reached
the object. Test the method by calling it and passing the island as the argument
   
Reply With Quote
Sail to Island
Old
bmarh
Guest
 
Status:
Posts: n/a
Default Sail to Island - 09-18-2010, 09:30 AM

My boat do not stop at the island
Attached Files
File Type: a2w Sail.a2w (1.11 MB, 262 views)
   
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.