Forums
 

Any Java/programming buffs here?


Reply
 
Thread Tools Search this Thread
Old 22-11-2012, 20:54   #1
November_Rain
Forum Member
 
Join Date: Feb 2010
Location: South Wales
Services: Virgin Media, Freesat HD, Giffgaff, Talkmobile, Netflix
Posts: 6,325
Any Java/programming buffs here?

I'm really struggling with a university assignment and I would appreciate some help.

Basically, I've been asked to recreate the text-only strategy game Hamurabi. For anyone who is not familiar with the game, essentially you have so many bushels of grain, and the purpose of it is to allocate those bushels between feeding the population of Sumeria, buying/selling acres of land and planting seeds for the following year. There is a version of it here if you want to get a better understanding of the game.

My problem is that my version of the game keeps saying X people have starved when this shouldn't be the case. For instance, here the game was telling me 68 people had starved, even though I had allocated enough bushels for every citizen.

Clearly this is a problem in my coding but I can't work out what it is. Is there anyone who can understand programming languages that could take a look at my coding and find out where I'm going wrong?

A copy of my coding can be found here.

I know it's a long shot but any help would be greatly appreciated.
November_Rain is offline   Reply With Quote
Please sign in or register to remove this advertisement.
Old 22-11-2012, 21:33   #2
November_Rain
Forum Member
 
Join Date: Feb 2010
Location: South Wales
Services: Virgin Media, Freesat HD, Giffgaff, Talkmobile, Netflix
Posts: 6,325
Problem solved, you can ignore this thread now.
November_Rain is offline   Reply With Quote
Old 22-11-2012, 21:47   #3
Maxatoria
Forum Member
 
Join Date: Apr 2011
Services: Old Boilers
Posts: 3,003
The general rule is to print off every variable every time it changes so you can see where something goes wrong as i cant be bothered checking for subtle errors due to brackets etc
Maxatoria is offline   Reply With Quote
Old 23-11-2012, 12:18   #4
whoever,hey
Forum Member
 
Join Date: Mar 2006
Services: A hoover or some other generic vacuum cleaning machine.
Posts: 27,599
I dont know about your bug, but this comment is wrong
Code:
int cost_per_acre = 17 + (int)(Math.random()*24);         //This generates a random number from 17 to 24
Wrong comments are worse than no comments at all tbh.
whoever,hey is offline   Reply With Quote
Old 23-11-2012, 12:47   #5
tealady
Forum Member
 
Join Date: Apr 2005
Location: colchester
Services: freeview fvrt200, broadband 4Mb, 2Kw solar pv array
Posts: 7,424
Don't think this really meets "good academic practice". You also have your name in the .rtf file.
tealady is offline   Reply With Quote
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search

 
Forum Jump


All times are GMT +1. The time now is 02:57.