The_Programmer-'s Profile
Reputation: 23
Tradesman
- Group:
- Members w/DIC++
- Active Posts:
- 560 (0.97 per day)
- Joined:
- 24-October 11
- Profile Views:
- 3,278
- Last Active:
May 16 2013 12:07 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Who Cares
- Favorite Browser:
- Chrome
- Favorite Processor:
- AMD
- Favorite Gaming Platform:
- Playstation
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Latest Visitors
-
modi123_1 
16 May 2013 - 10:37 -
no2pencil 
05 Apr 2013 - 12:32 -
CharlieMay 
05 Apr 2013 - 07:12 -
Curtis Rutland 
05 Apr 2013 - 06:09 -
tlhIn`toq 
04 Apr 2013 - 23:41 -
SarumanTheWhite 
22 Mar 2013 - 09:55 -
burakaltr 
25 Feb 2013 - 20:22 -
UNKNOWN2 
20 Feb 2013 - 12:01 -
Gorian 
05 Jan 2013 - 18:35 -
darek9576 
29 Dec 2012 - 04:14
Posts I've Made
-
In Topic: ChameleonKid Actors are not moving
Posted 16 May 2013
I figured it out. I had to see if the location was valid, not if it was null. Thanks for the help! -
In Topic: ChameleonKid Actors are not moving
Posted 16 May 2013
I must be doing something wrong or I do not know how to check if the location id valid. I get the same exact error as before. This is my edited ChameleonKid class:
import info.gridworld.actor.Actor; import info.gridworld.grid.Location; import java.util.ArrayList; public class ChameleonKid extends ChameleonCritter { public ArrayList<Actor> getActors() { ArrayList<Actor> actors = new ArrayList<Actor>(); Actor a1 = (getLocation().getAdjacentLocation(Location.NORTH) != null ? getGrid().get(getLocation().getAdjacentLocation(Location.NORTH)) : null); Actor a2 = (getLocation().getAdjacentLocation(Location.SOUTH) != null ? getGrid().get(getLocation().getAdjacentLocation(Location.SOUTH)) : null); if (a1 != null) actors.add(a1); if (a2 != null) actors.add(a2); return actors; } } -
In Topic: ChameleonKid Actors are not moving
Posted 16 May 2013
Ah. Sorry, I completely forgot!
java.lang.IllegalArgumentException: Location (10, 8) is not valid at info.gridworld.grid.BoundedGrid.get(BoundedGrid.java:88) at ChameleonKid.getActors(ChameleonKid.java:13) at info.gridworld.actor.Critter.act(Critter.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at info.gridworld.gui.MenuMaker$MethodItem.actionPerformed(MenuMaker.java:380) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.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(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown 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.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
-
In Topic: ChameleonKid Actors are not moving
Posted 16 May 2013
Okay. I fixed it but now whenever I hit the edge of the grid, the Chameleon throws and error because it is trying to move outside the grid. I checked to make sure the location is valid but it still throws the error.
import java.awt.Color; import java.util.ArrayList; import info.gridworld.actor.Actor; import info.gridworld.actor.Critter; import info.gridworld.grid.Location; public class ChameleonCritter extends Critter { public ChameleonCritter() { super(); } public void processActors(ArrayList<Actor> actors) { int n = actors.size(); if (n == 0) { Color c = getColor(); int red = (int) (c.getRed() * (1 - 0.15)); int green = (int) (c.getGreen() * (1 - 0.15)); int blue = (int) (c.getBlue() * (1 - 0.15)); setColor(new Color(red, green, blue)); } else { int r = (int) (Math.random() * n); Actor other = actors.get(r); setColor(other.getColor()); } } public void makeMove(Location loc) { if (getGrid().isValid(loc)) { setDirection(getLocation().getDirectionToward(loc)); super.makeMove(loc); } else { this.setDirection(this.getDirection() + Location.HALF_RIGHT); } } }
import info.gridworld.actor.Actor; import info.gridworld.grid.Location; import java.util.ArrayList; public class ChameleonKid extends ChameleonCritter { public ArrayList<Actor> getActors() { ArrayList<Actor> actors = new ArrayList<Actor>(); Actor a1 = getGrid().get(getLocation().getAdjacentLocation(Location.NORTH)); Actor a2 = getGrid().get(getLocation().getAdjacentLocation(Location.SOUTH)); if (a1 != null) actors.add(a1); if (a2 != null) actors.add(a2); return actors; } } -
In Topic: ChameleonKid Actors are not moving
Posted 16 May 2013
java.lang.NullPointerException at ChameleonCritter.processActors(ChameleonCritter.java:28) at info.gridworld.actor.Critter.act(Critter.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at info.gridworld.gui.MenuMaker$MethodItem.actionPerformed(MenuMaker.java:380) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.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(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown 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.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
I can't find any variable that might be null. Also, the bugs will not move for some reason which is weird because I have not edited the Bug class.
My Information
- Member Title:
- Death Scythe
- Age:
- 16 years old
- Birthday:
- August 1, 1996
- Gender:
-
- Location:
- Springfield, OR
- Interests:
-
Programming(Java, maybe MySQL, VB.NET), Reading, Gardening, herbology, Hunting. My PSN is The_Programmer-
If you need to e-mail me, do so at kensclark15@ymail.com or kensclark15@gmail.com - Full Name:
- Kenneth Stanley Clark
- Years Programming:
- 5
- Programming Languages:
- Java, PHP, Javascript, VB.NET.
Contact Information
- E-mail:
- Click here to e-mail me
- Website URL:
-
http://kensclark.com/
- Yahoo:
-
kensclark15@ymail.com
- Skype:
-
kensclark15
- Facebook:
- https://www.facebook.com/kennysc12
- Twitter:
- kensclark15
Friends
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
burakaltr
05 Feb 2013 - 18:40