Quick Java Coding Question

Discussion in 'Computer Games and General Discussion' started by Jamstruth, Mar 28, 2012.

Mar 28, 2012

Quick Java Coding Question by Jamstruth at 9:23 PM (401 Views / 0 Likes) 2 replies

  1. Jamstruth
    OP

    Member Jamstruth Secondary Feline Anthropomorph

    Joined:
    Apr 23, 2009
    Messages:
    3,456
    Location:
    North East Scotland
    Country:
    United Kingdom
    I'm a first year Computer Science student and I've been given a very simple project to improve a Fox and Rabbit simulation. Its basically a grid of Fox and Rabbit object, foxes eat rabbits, breed and die, rabbits just breed and die. The basic running of the program has been provided to me. Basically it originally just consists of a window with no controls with the view of the field showing all the Fox and Rabbit objects.

    Anyway I've coded a simple GUI to control the program and have hit upon a very strange snag. The window is, for some reason, not showing each step as it happens. When I click the button I have coded to run the simulation for 500 steps the program skips straight to the end of the series of steps instead of showing the populations changing over time. I've checked the code for the simulator viewer and there is a repaint method used to redraw the window after each step of the simulation and when i called the system from a main method the window showed the program running through each step. I don't understand how that's any different to me pressing a GUI button to call the same method. Any ideas as to what's going on?
     
  2. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,731
    Country:
    United Kingdom
    How very old school- I have not really seen this taught as a programming exercise in quite a while (biology yes, programming no). I can not help you with the java (it is really not my programming language) but can I advise you to allow extensibility of your program- much like factorials get used to teach recursion (although this is something of a recursion/looping tutorial) the classic week 2 part of this is to say add a meteor strike to kill the grass (and kill the rabbits meaning the foxes have nothing to eat.....) and it is quite easy to paint yourself into a corner here.
     
  3. Jamstruth
    OP

    Member Jamstruth Secondary Feline Anthropomorph

    Joined:
    Apr 23, 2009
    Messages:
    3,456
    Location:
    North East Scotland
    Country:
    United Kingdom
    My current ideas for expanding the program are as follows:
    Adding extra species. Current ideas are Hunters that actively kill the Foxes, Farmers which patrol farm areas and kill foxes that enter them, Chickens which live in areas controlled by farmers and basically act similarly to rabbits (less aggressive breeding though), and Ospreys which farmers and hunters are not allowed to kill (though there are only a max of 3 of these allowed)
    Add Genders. Current breeding is done through a chance mechanic, would like to add an extra factor of must be next to opposite gender object.
    Adding saving to file to allow importing to Excel for data analysis (this would basically be a population breakdown for graphing over time) Possibly add a graph to the system (though i have no idea how to implement this)
    Adding more configurability to the starting conditions. Have the system start with a certain population of Foxes, change the breeding ratio or maximum age etc.

    I did think about adding a small chance of myxamytosis in the rabbit population and if that happens then disease spread mechanic. Pretty tempting to do that now. I never really planned to start this now (this is my over Easter Holidays work) but I just got coding the GUI a couple of nights ago and hit upon this weird bug.
     

Share This Page