Gaming Quick Java Coding Question

Jamstruth

Secondary Feline Anthropomorph
OP
Member
Joined
Apr 23, 2009
Messages
3,462
Trophies
0
Age
31
Location
North East Scotland
XP
710
Country
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?
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,375
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.
 

Jamstruth

Secondary Feline Anthropomorph
OP
Member
Joined
Apr 23, 2009
Messages
3,462
Trophies
0
Age
31
Location
North East Scotland
XP
710
Country
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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Psionic Roshambo @ Psionic Roshambo:
    hmmm 360 even lol
  • Psionic Roshambo @ Psionic Roshambo:
    Well I was getting a discount so 320 is probably right
  • BigOnYa @ BigOnYa:
    That is cheap, I used to pay $100 for a tine.
  • Psionic Roshambo @ Psionic Roshambo:
    Tine? One gram?
  • BigOnYa @ BigOnYa:
    Sixteenth
  • Psionic Roshambo @ Psionic Roshambo:
    Also it was literally out of a kilo when I got it off the boat so absolutely pure
  • Psionic Roshambo @ Psionic Roshambo:
    Holy shiz that's a lot
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    I was getting 3.5 Grams for 320 could have stepped on it and doubled my money easy lol
    +1
  • BigOnYa @ BigOnYa:
    I'd be afraid to it nowdays, my heart would explode prob. I just stick beers n buds nowdays.
  • Psionic Roshambo @ Psionic Roshambo:
    I would get to drive from tarpon springs to like Miami a thousand bucks lol do that twice a week and back in 92 that was good money
  • Xdqwerty @ Xdqwerty:
    @BigOnYa,
    @Psionic Roshambo what are you guys talking about?
  • Psionic Roshambo @ Psionic Roshambo:
    Blew it on women and muscle cars lol
    +1
  • BigOnYa @ BigOnYa:
    @Xdqwerty Hamster food, its pricey nowadays to keep PCs running.
    +2
  • Psionic Roshambo @ Psionic Roshambo:
    I don't do anything except cigarettes and gotta stop eventually lol
    +1
  • BigOnYa @ BigOnYa:
    I'd do shrooms again if could find, and I was outside camping/fishing, and had a cooler full of beer.
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    I wouldn't mind some LSD, laughing until my face hurt sounds fun lol
    +1
  • BigOnYa @ BigOnYa:
    You ever try soaper powder/qauludes? I did once and like a dumbass drank beer on top of taking, I woke up laying in my backyard in the pouring rain, it knocked me out. I have not seen it around in many many years.
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    No never tried a lot of things but never that lol
  • Psionic Roshambo @ Psionic Roshambo:
    I did pass out one time on a floor after taking a bunch of Ambien lol thought it would help me sleep and did it lol
  • Psionic Roshambo @ Psionic Roshambo:
    Girlfriend was working at a pharmacy and stole like 500 of them, was and still is the biggest pill bottle I have ever seen lol
  • K3Nv2 @ K3Nv2:
    Ativan is pretty legit
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    The last time I had to take something to help me sleep, I was prescribed Trazadone it was pretty OK to be honest.
  • Psionic Roshambo @ Psionic Roshambo:
    Not something I need at all these days, doing a lot better lol
    Psionic Roshambo @ Psionic Roshambo: Not something I need at all these days, doing a lot better lol