adamleesaintfrancis / spacewar

Automatically exported from code.google.com/p/spacewar
0 stars 0 forks source link

ArrayOutof Bounds Exception in MyState when less than 3 obstacles are left in State #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the simulation with spaceships that fire at obstacles
2. Wait until less than 2 obstacles remain
3. Program should then hang and produce error message.

What is the expected output? What do you see instead?
 java.lang.reflect.InvocationTargetException
     [java]     at java.awt.EventQueue.invokeAndWait(Unknown Source)
     [java]     at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
     [java]     at edu.ou.mlfw.World.runGUI(World.java:181)
     [java]     at edu.ou.mlfw.World.main(World.java:304)
     [java] Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
     [java]     at nonpublish.objects.MyState.<init>(MyState.java:88)
     [java]     at gagn5037.DJGeneticAgent.endAction(DJGeneticAgent.java:103)
     [java]     at
edu.ou.spacewar.mlfw.clients.AbstractShipClient.endAction(AbstractShipClient.jav
a:42)
     [java]     at edu.ou.mlfw.World.endActions(World.java:251)
     [java]     at edu.ou.mlfw.World.step(World.java:225)
     [java]     at edu.ou.mlfw.World.access$100(World.java:30)
     [java]     at edu.ou.mlfw.World$3.run(World.java:184)
     [java]     at java.awt.event.InvocationEvent.dispatch(Unknown Source)
     [java]     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     [java]     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
Source)
     [java]     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown
Source)
     [java]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
     [java]     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     [java]     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     [java]     at java.awt.EventDispatchThread.run(Unknown Source)

What version of the product are you using? On what operating system?
I am using the latest version of spacewar on Windows XP.

Please provide any additional information below.
The problem seems to be in myState because there is a for loop that checks
the distances to obstacles and it always looks for 3 obstacles no matter
how many obstacles are in the simulation.  Since the asteroid destruction
and splitting reduction was implemented, it is now possible to eliminate
most of the asteroids within the five-minute running time of the game.  To
fix this, the only thing that needs to be done is having the
obstacles.length being compared with 3 and using obstacles.length if it is
less than 3.

Also, please cc: jfager on any new issues that are opened!  Thank you!

Thank you,
David John Gagne II

Original issue reported on code.google.com by DVader...@gmail.com on 12 Mar 2008 at 10:04

GoogleCodeExporter commented 9 years ago
Where is MyState.java coming from?  That doesn't exist in the spacewar codebase.

Original comment by jfa...@gmail.com on 13 Mar 2008 at 2:47

GoogleCodeExporter commented 9 years ago
It is code for Project 2 in Dr. McGovern's AI class that we were given 
separately. 
It isn't in the main codebase but was provided by her, and she told me to post 
the
bug on the code page when I contacted her about it.

Original comment by DVader...@gmail.com on 13 Mar 2008 at 2:56

GoogleCodeExporter commented 9 years ago
Assigning to Dr. McGovern; I don't have access to this code.

Original comment by jfa...@gmail.com on 25 Mar 2008 at 10:46

GoogleCodeExporter commented 9 years ago
I thought we had decided the final answer to this was that the students needed 
to change MyState anyway so the 
bug fix was not going up?  If this is still an issue, let me know.

Original comment by dramymcg...@gmail.com on 26 Mar 2008 at 2:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Moving to accepted so I can close this out.

Original comment by dramymcg...@gmail.com on 28 Apr 2008 at 5:28

GoogleCodeExporter commented 9 years ago
Closing it out.

Original comment by dramymcg...@gmail.com on 28 Apr 2008 at 5:28