Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.osn.de!diablo2.news.osn.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 24 Feb 2013 09:04:37 -0600 Date: Sun, 24 Feb 2013 15:04:35 +0000 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: BlueJ don't know what i did wrong References: <638ed624-9eba-44eb-bcbf-68466e5bb5f1@googlegroups.com> <42d76fca-d365-4030-ae8c-07a806eab87c@googlegroups.com> In-Reply-To: <42d76fca-d365-4030-ae8c-07a806eab87c@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 59 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-rszZ6TFR9FlOKwlEug86xVOtGLqJ0+vB46j/7BlxLUhfhxdYs/46ViLFVtY/81AV0da38Lxzgn9W7RI!eLlCHrXyc6QpCm/G2P/E3oPJ86RE7uP+u2MerQXPmWTSV3A6X/w4iUV6dduw60nVunkUqsfaa9I= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3139 Xref: csiph.com comp.lang.java.programmer:22479 On 24/02/13 10:27, marvin.radke@htp-tel.de wrote: > I hope that is what you meant by making it easierr to read: I loaded your code into the eclipse debugger and discovered the following The problem occurs randomly at lines 734 and 735 (your line numbers may vary) 734: int whohelps = (int) (((Math.random() * assisting[k]) +1) + helpstillyet[k]); 735: if (stillthere[help[whohelps]]!=0&&whohelps!=assisting[k]+1+helpstillyet[k]) If I change line 735 to the following code if(true) the program runs to completion. Further analysis: The program gets to a point where the whohelps computation returns a value that apparently causes the conditional test to continually fail, it seems to switch between 2 seemingly random values, in other words you get into a infinite loop at 732: while(chanceofhelpunit<7 && assisting[k]>0 && pointsuntilnow < pointsperPlayer) I would therefore assume that something inside the final if statement is responsible for modifying the expression in the if but as the program gets to a point where code inside the if is never executed the program loops forever. There is also lots of random number generation going on which can cause all sorts of unexpected results. The code is quite hard to read, you can make it easier to read by generating interim values and storing them in variables, you can then place a watch on the variables to make it easier to figure out whats going on. So, to give you a starting point, change 735: if (stillthere[help[whohelps]]!=0&&whohelps!=assisting[k]+1+helpstillyet[k]) to if(true) and look at the output. and remember, "first make it right, then make it fast" lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun