Any Java/programming buffs here? |
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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. |
|
|
|
|
Please sign in or register to remove this advertisement.
|
|
|
#2 |
|
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.
|
|
|
|
|
|
#3 |
|
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
|
|
|
|
|
|
#4 |
|
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 |
|
|
|
|
|
#5 |
|
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.
|
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
|
All times are GMT +1. The time now is 02:57.



