-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The GUI has been added to the working program. I also added some idea…
…s for a more complex Rabbit agent.
- Loading branch information
pbatzel
authored and
pbatzel
committed
Dec 2, 2009
1 parent
e589999
commit d5d1c1c
Showing
4 changed files
with
71 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import java.util.Random; | ||
|
||
|
||
public class ComplexRabbit extends Agent{ | ||
final int deathFromAge = 20; | ||
Random r = new Random(); | ||
int energy = 75; | ||
int age = 0; | ||
|
||
public void go(){ | ||
|
||
// move(r.nextInt(5),r.nextInt(5)); | ||
move(1,0); | ||
energy = energy - 10; | ||
age++; | ||
|
||
if(energy >= 100){ | ||
reproduce(); | ||
} | ||
|
||
if(age == 20){ | ||
die(); | ||
} | ||
} | ||
|
||
public void reproduce(){ | ||
energy-=25; | ||
} | ||
|
||
public void die(){ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters