Digital Spy

Search Digital Spy
 

DS Forums

 
 

Any Java/programming buffs here?


Reply
Thread Tools Search this Thread
Old 22-11-2012, 20:54
November_Rain
Guest
 
Join Date: Feb 2010
Posts: 8,506

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
November_Rain
Guest
 
Join Date: Feb 2010
Posts: 8,506
Problem solved, you can ignore this thread now.
November_Rain is offline   Reply With Quote
Old 22-11-2012, 21:47
Maxatoria
Forum Member
 
Join Date: Apr 2011
Posts: 5,431
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
whoever,hey
Forum Member
 
Join Date: Mar 2006
Posts: 29,780
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
tealady
Forum Member
 
Join Date: Apr 2005
Location: colchester
Posts: 10,518
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 19:03.