PDA

View Full Version : Having trouble calling a method


kcoder
05-15-2009, 05:35 PM
I have been doing some Alice projects on the side, and I recently started a new one. I put an object on the stage, and, while the simulation is running, the update() method in the world class should be called. All I have in that method (so far) is car.moveAtSpeed(etc). This causes an error that I can't decipher because I don't know Alice's underlying design structure. However, if I put car.moveAtSpeed(etc) in the events where the update() call was, it works perfectly fine. I've done this in several other projects. This is in Alice 2.0. I've done a project in Alice 2.2, then I realized I had a bug with creating Position objects, which I needed for collision detection, so I've been using 2.0 ever since. =P Anyways, here's the error message if anyone wants it:

Error during simulation.




Alice version: 2.0 04/05/2005

os.name: Windows XP

os.version: 5.1

os.arch: x86

java.vm.name: Java HotSpot(TM) Client VM

java.vm.version: 1.3.1_10-b03

user.dir: C:\Documents and Settings\Administrator\Desktop\Alice\Required



Throwable that caused the error:

java.lang.ArrayIndexOutOfBoundsException: -1 not in range [0,1)

at edu.cmu.cs.stage3.alice.core.Behavior$Fork.getNext (Behavior.java:113)

at edu.cmu.cs.stage3.alice.core.Behavior$RuntimeStack .top(Behavior.java:55)

at edu.cmu.cs.stage3.alice.core.Behavior.stackLookup( Behavior.java:269)

at edu.cmu.cs.stage3.alice.core.Property.evaluateIfNe cessary(Property.java:367)

at edu.cmu.cs.stage3.alice.core.Property.getValue(Pro perty.java:407)

at edu.cmu.cs.stage3.alice.core.property.BooleanPrope rty.getValue(BooleanProperty.java:33)

at edu.cmu.cs.stage3.alice.core.property.BooleanPrope rty.getBooleanValue(BooleanProperty.java:45)

at edu.cmu.cs.stage3.alice.core.property.BooleanPrope rty.booleanValue(BooleanProperty.java:48)

at edu.cmu.cs.stage3.alice.core.behavior.ConditionalB ehavior.preSchedule(ConditionalBehavior.java:36)

at edu.cmu.cs.stage3.alice.core.Sandbox.scheduleBehav iors(Sandbox.java:69)

at edu.cmu.cs.stage3.alice.core.World.scheduleBehavio rs(World.java:444)

at edu.cmu.cs.stage3.alice.core.World.schedule(World. java:486)

at edu.cmu.cs.stage3.alice.core.clock.DefaultClock.sc hedule(DefaultClock.java:94)

at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToo l$11.run(AuthoringTool.java:681)

at edu.cmu.cs.stage3.alice.authoringtool.util.Default Scheduler.simulateOnce(DefaultScheduler.java:115)

at edu.cmu.cs.stage3.alice.authoringtool.util.Default Scheduler.run(DefaultScheduler.java:76)

at edu.cmu.cs.stage3.scheduler.AbstractScheduler.run( AbstractScheduler.java:45)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)

at java.awt.Dialog.show(Unknown Source)

at edu.cmu.cs.stage3.swing.DialogManager.showModalDia log(DialogManager.java:58)

at edu.cmu.cs.stage3.swing.DialogManager.showDialog(D ialogManager.java:123)

at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToo l.play(AuthoringTool.java:5073)

at edu.cmu.cs.stage3.alice.authoringtool.Actions$15.a ctionPerformed(Actions.java:167)

at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)

at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)






UPDATE: The moveAtSpeed function was wrapped in a doTogether clause, but when I took it out, everything was dandy. Other methods handle the doTogether clause fine. For example, I made another method (let's call it methodA) that had a doTogether clause in it, and called it from within the update method. That worked fine. Also, I can call the new method (methodA) from the event without problems, unlike the update. Any ideas?

Scott300
05-15-2009, 07:33 PM
Upload a copy of the world please.