Solved

Simulation

Posted on 2004-04-28
3
414 Views
Last Modified: 2010-03-31
Hello, I'm how to build a simulation that would simulate an ocean with sea animals it. Within the simulation I want certain ocean critters to eat each other, reproduce, and die. Now my question is I want to use threads in order to do this but I was wondering if there is another way to do this in Java. My intial design centered around a random generator to produce random critters in a ocean which is displayed in a GUI. What would the best way to implement a simulation like this in Java?
0
Comment
Question by:DancingFighterG
3 Comments
 
LVL 4

Accepted Solution

by:
john-at-7fff earned 50 total points
Comment Utility
DancingFighterG --

It sounds like you want general advice, so here it is:

A solution using threads would be very elegant. You would have each animal get positioned on a grid, and it would, on a timer, check its surroundings and make changes in its own state. For instance, if it detected another animal one square away, it might called a "bite" method on the other animal.

The other way to do this is to create a grid, put your animals on it, and then traverse the grid and apply your various "rules" regarding the changes in the animals.

Some of the classic implementations of these kinds of simulations concern John Conway's "Game of Life." Here's an example:

http://www.bitstorm.org/gameoflife/

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now