Solved

Simulation

Posted on 2004-04-28
3
421 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
ID: 10942869
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 196
varialbe initialization 11 33
login form jsp example 2 26
String array comparison 4 34
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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