Alice Community  

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

Reply
 
Thread Tools Display Modes
Counting steps
Old
Laur07
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jun 2011
Default Counting steps - 06-14-2011, 07:59 PM

I am having difficulty with the "increment" function. So for my project :Your program must also count the number of steps it took for the wolf to catch the bunny. If it took more than 10 steps, the wolf should say "That was tough, but this bunny was worth it!" or something similar, after it eats the bunny, otherwise the wolf should say "That was too easy, give me a challenge next time!"
I created a new variable in the "world properties" called steps because i need to be able to count how many steps the wolf takes but i don't really know the next steps to make it actually count and in order to make the "IF" statement in the end .... Anyone have an idea how this works? I really appreciate all the help i have been getting!
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 06-14-2011, 08:35 PM

Well in in your walking method at the very end of the method(after the wolf has taken a step) you would increment the variable you have created. Next you would put an if statment that checked to see:

Code:
if(world.steps==some number)
{
  //That was easy.
}
else if(world.steps==some other number)
{
//That was easy.
}
else
{
//do nothing.
}
You would also have to change the number of times the bunny steps so the wolf could catch it; I don't know if you already know what your going to do for that.


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
Reply With Quote
Reply

Thread Tools
Display Modes

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 ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.