Solved

Simulation

Posted on 2004-04-28
3
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
null output 3 55
difference between sorce folder and folder in eclipise 3 62
jmeter usage 4 57
Netbeans and org.apache.commons.lang3 issue 3 51
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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

738 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