Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Threshold function with a list. (http://www.alice.org/community/showthread.php?t=3367)

Akusai 11-10-2009 12:17 PM

Threshold function with a list.
 
Hey, I'm trying to make a program in where a shape comes into a Taurus, but there is going to be multiple shapes per Taurus and I want to make a list. Is there any way that I can make the threshold function call up a method whenever ANYTHING in that list comes into the threshold?

x2495iiii 11-10-2009 03:26 PM

You could try a For all in order collision detection method, but that has the potential to mess up the game and lag big time (if your game is simple, you probably don't have to worry about it, but that caused me problems when I was making RP). Go ahead and try making something like:

For all shapes in order:
if item_from_shapes is within (your choice) meters of taurus
(whatever you want to happen when it goes inside the taurus goes here)
else
(do nothing)

If it doesn't work, you'll need to do do them each individually (though you can put them all in a Do together method to speed up the process).

Akusai 11-11-2009 10:26 AM

Yeah, your idea worked beautifully until I applied it to all of the Taurii...

And this is gonna be quite lengthy, but it's the error that I got.

Error during simulation.


Alice version: 2.0.7
os.name: Mac OS X
os.version: 10.5.8
os.arch: i386
java.vm.name: Java HotSpot(TM) Client VM
java.vm.version: 1.4.2-92
user.dir: /Network/Servers/stuag.princeton.k12.mn.us/Volumes/Data/StudentData/2011/ANDERBRI000/Desktop/Alice.app/Contents/Required

Throwable that caused the error:
java.lang.NullPointerException
at edu.cmu.cs.stage3.alice.core.question.IsCloseTo.getValue(IsCloseTo.java:40)
at edu.cmu.cs.stage3.alice.core.question.SubjectObjectQuestion.getValue(SubjectObjectQuestion.java:34)
at edu.cmu.cs.stage3.alice.core.question.SubjectQuestion.getValue(SubjectQuestion.java:35)
at edu.cmu.cs.stage3.alice.core.Property.evaluateIfNecessary(Property.java:380)
at edu.cmu.cs.stage3.alice.core.Property.getValue(Property.java:407)
at edu.cmu.cs.stage3.alice.core.property.BooleanProperty.getValue(BooleanProperty.java:33)
at edu.cmu.cs.stage3.alice.core.property.BooleanProperty.getBooleanValue(BooleanProperty.java:45)
at edu.cmu.cs.stage3.alice.core.property.BooleanProperty.booleanValue(BooleanProperty.java:48)
at edu.cmu.cs.stage3.alice.core.property.BooleanProperty.booleanValue(BooleanProperty.java:56)
at edu.cmu.cs.stage3.alice.core.response.IfElseInOrder$RuntimeIfElseInOrder.prologue(IfElseInOrder.java:51)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.childPrologueIfNecessary(DoInOrder.java:52)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.update(DoInOrder.java:97)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.childUpdate(DoInOrder.java:57)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.update(DoInOrder.java:98)
at edu.cmu.cs.stage3.alice.core.response.CallToUserDefinedResponse$RuntimeCallToUserDefinedResponse.update(CallToUserDefinedResponse.java:86)
at edu.cmu.cs.stage3.alice.core.response.DoTogether$RuntimeDoTogether.update(DoTogether.java:68)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.childUpdate(DoInOrder.java:57)
at edu.cmu.cs.stage3.alice.core.response.DoInOrder$RuntimeDoInOrder.update(DoInOrder.java:98)
at edu.cmu.cs.stage3.alice.core.response.CallToUserDefinedResponse$RuntimeCallToUserDefinedResponse.update(CallToUserDefinedResponse.java:86)
at edu.cmu.cs.stage3.alice.core.behavior.AbstractConditionalBehavior.internalSchedule(AbstractConditionalBehavior.java:103)
at edu.cmu.cs.stage3.alice.core.Behavior.schedule(Behavior.java:225)
at edu.cmu.cs.stage3.alice.core.Sandbox.scheduleBehaviors(Sandbox.java:70)
at edu.cmu.cs.stage3.alice.core.World.scheduleBehaviors(World.java:444)
at edu.cmu.cs.stage3.alice.core.World.schedule(World.java:486)
at edu.cmu.cs.stage3.alice.core.clock.DefaultClock.schedule(DefaultClock.java:94)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool$11.run(AuthoringTool.java:689)
at edu.cmu.cs.stage3.alice.authoringtool.util.DefaultScheduler.simulateOnce(DefaultScheduler.java:115)
at edu.cmu.cs.stage3.alice.authoringtool.util.DefaultScheduler.run(DefaultScheduler.java:76)
at edu.cmu.cs.stage3.scheduler.AbstractScheduler.run(AbstractScheduler.java:45)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:189)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.Dialog$1.run(Dialog.java:542)
at java.awt.Dialog$3.run(Dialog.java:569)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:567)
at java.awt.Component.show(Component.java:1133)
at java.awt.Component.setVisible(Component.java:1088)
at edu.cmu.cs.stage3.swing.DialogManager.showModalDialog(DialogManager.java:58)
at edu.cmu.cs.stage3.swing.DialogManager.showDialog(DialogManager.java:123)
at edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.play(AuthoringTool.java:5087)
at edu.cmu.cs.stage3.alice.authoringtool.Actions$15.actionPerformed(Actions.java:167)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1819)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1872)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:247)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5166)
at java.awt.Component.processEvent(Component.java:4963)
at java.awt.Container.processEvent(Container.java:1613)
at java.awt.Component.dispatchEventImpl(Component.java:3681)
at java.awt.Container.dispatchEventImpl(Container.java:1671)
at java.awt.Component.dispatchEvent(Component.java:3543)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3527)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3242)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3172)
at java.awt.Container.dispatchEventImpl(Container.java:1657)
at java.awt.Window.dispatchEventImpl(Window.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3543)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)



If anybody has a free hour, can you translate that into english for me?

x2495iiii 11-11-2009 03:38 PM

Honestly, 90% of that is fluff code, stuff that doesn't really help you determine the problem. Focus on the top few lines in the second paragraph when reading these error messages.

Oh eew blech yuck, you're using Mac?!? Urp...

Okay, it looks like one of two things:

-one of the objects in question, either one of the taurii or one of the shapes, is undefined when the collision method is called. make sure any variables used have initial values and make sure no action in your world refers to an item in the list of shapes which doesn't exist.

-if you copied the same method repeatedly, Alice has confused them all for the same method and has run into problems because of it. Delete all but the first one, and drag'n'drop a new For all in order tile for each taurus.

Let me know if these work. If they don't (or if they don't apply), go ahead and post your world.

Akusai 11-12-2009 09:32 AM

Yeah, I talked to Ms.Sell and the problem was an undefined variable in 2_List.

And yes, I am working on a mac, it sucks, but when I try to work on one of the windows dinosaurs we have, it lags.

Akusai 11-25-2009 09:44 AM

1 Attachment(s)
Yep, I would up scrapping the Guitar Hero ripoff, and this is what I made.


All times are GMT -5. The time now is 10:26 AM.

Copyright ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.