This site requires JavaScript, please enable it in your browser!
Greenfoot back
BJanssen
BJanssen wrote ...

2020/1/16

Bee simulation

BJanssen BJanssen

2020/1/16

#
Hello everybody, I have to make a school project about a bee simulation. I have to simulate how the bees find a flower and go back to their beehive. The bees will dance at the beehive to indicate where the flower is. We don't really know how to do this. Can someone help us!
danpost danpost

2020/1/16

#
BJanssen wrote...
I have to make a school project about a bee simulation. I have to simulate how the bees find a flower and go back to their beehive. The bees will dance at the beehive to indicate where the flower is. We don't really know how to do this.
You will probably need a field that will indicate whether the bee is dancing or not. The bee won't dance forever, so an int timer field will probably do best. Maybe something like the following:
/** instance field */
private int dancing; // = 0 (by default)

/** action code */
if (hasNectar()) toHive();
else if (dancing > 0) dance();
else if (atHive() && beesDancing()) toFlower();
else findFlower();

/** in dance method */
dancing--;
// dance movement codes
My main concern here was how the field was to be used. When reaching home with nectar, the dancing field should be given some positive value approx. 60 per second of dancing time. More can be added to have the bee find a position near the hive to dance at (so all do not dance so close to each other).
You need to login to post a reply.