Solved

Simulation

Posted on 2004-04-28
3
426 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
table example 4 32
Opening PDF on button click and fill new document 2 47
Java syntax, or is it Selenium 6 30
Need Help! Getting a syntax error and don't understand why 3 31
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

808 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