james-marshall314 / ecosystem

Ecosystem group project for Intro to JAVA
0 stars 1 forks source link

Structure Discussion #2

Open james-marshall314 opened 10 years ago

james-marshall314 commented 10 years ago

Posting this again to make sure it gets seen.

Hey, The project on here is just a sketch of some of my initial ideas for the project so that we have something on here to help get us started with a single project file on here. I didn't mean to give the impression that this was the finite program structure.

I agree with Sofia that the plant and animal classes are not needed, we'd just end up writing methods that would need to be overridden in the subclasses. Keeping everything under a basic Organism class should be fine for our needs.

The grid - Initially my idea was to have the zones maintain an organism list, and the simulation would iterate through the zones, and the zones through their organisms. I think a better idea though, is to have the sim class have a list of Organisms and a list of Zones. the zones would simply store, as you said, a basic view of what they have in them as well as a Zone number, to identify them in the grid.

james-marshall314 commented 10 years ago

Thinking about this again, I think that zone should still hold lists of actual object references, since this will make it easier for implementing a deer eating a grass object or a tree killing a grass object so it can reproduce. It will still also store and update a general view of itself as well.

james-marshall314 commented 10 years ago

Sofia, I merged your pull request and have since committed a finished idea for the Zone class to the main project. I opened a second issue thread about the creation of an organism super class. In your pull request you removed Deer class and Plant class. I would like to propose that the subclasses for organism be Tree, Grass, and Deer instead of Animal. If there is a reason you think we should have an animal instead of a Deer class, let me know.

As for structure this would leave us with:

Simulator Class - This class holds a list of Zone and a list of Organism. It will have all the methods for running the sim. Organism objects, which will hold a reference to the simulator class that created them, can interact with the simulator class in order obtain info to move about the grid.

Zone Class - Zone holds a list of all of the Organism objects currently in Zone. It contains methods for adding and removing an Organism from the zone. These will be used by Organism objects, which store a reference to the Zone they currently reside in. Zone also keeps track of its fire status, has a record of which zone it is within the grid (a zone number), and has methods for updating and relaying its current state.

Organism Class - A superclass defining traits shared by all organisms. Organism class stores a reference to the Simulation class that created it, Its current Zone, and whether it is alive or dead. Organism also stores a list of its offspring.

Deer, Tree, and Grass classes - Organism subclasses that describe traits specific to their type.

This structure should be sufficient to successfully program the logical side of our project.

sedeh commented 10 years ago

So the idea is to have Organism superclass and let Deer, Grass and Tree inherit from it. Ideally, we want to have Vegetation (or Plant) and Animal in between but I can live with this middle ground. It will help to simplify our codes and structure. James and Sofia, where can I jump in?

james-marshall314 commented 10 years ago

Hey Samuel,

The decision to leave skip a plant and animal class is purely practical. For what we need to accomplish, adding them will not save us from much code duplication, and it certainly wont save us time.

We still need to decide how we want to implement our UI. If you want, fork a version of the project and start adding in some classes to the diagram that you think would be useful for a graphic interface.

james-marshall314 commented 10 years ago

Samuel,

I like where you're headed with that start button implementation. What I was meaning though, is that if we are shooting for a complete program that launches independently, accepts user input, and displays the sim (grid with deer grass and tree), we are still missing key classes in the diagram. Speaking in terms of M-V-C, we have the model worked out already, now our view and controller pieces need to be worked in. The way I see it we need something similar to what sofia had in her diagram - Main module, InputMonitor, SimulatorDisplay etc.

sedeh commented 10 years ago

I also have SimulatorView in the sketch I drew up. I think we need a display for the grids and to show the organisms. But we also need a way for the user to initiate the program. This latter part is what I was shooting for in the User GUI. Are you suggesting combining the User GUI and the Display GUI? I think that is cool. I have no clue how to do that right now but will play around.

sedeh commented 10 years ago

So we would need a 12 x 12 grid that will make the field and then a GUI to display the simulation. Perhaps we could adapt the simple model below.


import javax.swing.JFrame;

// Displays a frame containing a grid,
// each cell containing a value given in the input array, data
public class DisplayFrame extends JFrame {
    private GridPanel grid;

    // accepts string title,
    // x: # of columns and
    // y: # of rows
    public DisplayFrame(String title, int x, int y) {
        setTitle(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        grid = new GridPanel(y, x);
        add(grid);

        pack();
        setVisible(true);
    }

    // Sets grid cells to values in array, data
    public void setGrid(char[][] data) {
        for (int i = 0; i < data.length; i++) {
            for (int j = 0; j < data[i].length; j++) {
                grid.setGrid(i, j, data[i][j]);
            }
        }
    }
}

Notice the display invokes the grid panel.

http://www.dreamincode.net/forums/topic/204603-predator-prey-simulation-ants-doodlebugs/

angchalmers commented 10 years ago

Hi Guys,
I'm posting here as well as the esc.moodle site. Hopefully you see one of them. I heard back from the instructor/client regarding the program specs. (I posted a gif with the specs earlier this week.)

The specs I provided have been approved and he answered the following questions: NOTE answers to #1 and #6 - have specific answers regarding programming.

2-5 are up to you, but it should perform as you design.

If you have any other questions, please let me know. - Angelica

Questions:

  1. Plants choose randomly where to reproduce – if the chosen square is full, does the plant end reproduction for the turn, or randomly select another square until it is successful or there is no room left? SELECT ADJACENT SQUARE
  2. When organisms reach a reproduction turn, if they do not reproduce, does the count reset or do they continue to try each following turn until successful? PROGRAMMERS DECIDE AND TESTERS TEST TO MAKE SURE IT MAKES SENSE
  3. Is there a max number of deer per square? PROGRAMMERS DECIDE AND TESTERS TEST TO MAKE SURE IT MAKES SENSE
  4. If there is a max number of deer per square, during reproduction, if the occupied square and adjacent squares are full, does the deer still reproduce? Or are there any negative actions? (Deer dies)PROGRAMMERS DECIDE AND TESTERS TEST TO MAKE SURE IT MAKES SENSE
  5. Are there any specific parameters for fire, or would you like the team to decide? (Likelihood of fire (%), number of squares a fire takes up, location of fire, how often a fire might occur, etc.)PROGRAMMERS DECIDE AND TESTERS TEST TO MAKE SURE IT MAKES SENSE
  6. In what order would you like the entities to process a turn? (deer, tree, plant, fire) GRASS, TREE, DEER, FIRE