Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simulation

Posted on 2004-04-28
3
Medium Priority
?
439 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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…
Suggested Courses

722 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