adamleesaintfrancis / spacewar

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

GoToPointAction.java throwing NullPointerException #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the GoToPointAction from GoToPointAction.java in 
RandomGeneticAgent.java

What is the expected output? What do you see instead?
GoToPoint initializes path to null.

private transient Vertex[] path = null;

But isDone() dependend on path before its initialized in goToPoint().

What version of the product are you using? On what operating system?
revision 182

Please provide any additional information below.

This can be corrected by checking for a null value at every point where
path is used or initializing path to an empty Vertex[] instead of null.

As parts of GoToPointAction depend on path being null, I would suggest just
adding a check for path being null in isDone. 

/**
     * Returns the status of this high-level action: true if it is done.
     */
    public boolean isDone() {
        if(pathAction == null){
            pathAction = new FollowPathAction();
        }
        if(path != null)
        {

            if(path[0].isGoal()){
                return pathAction.isDone();
            }
        }
        return false;
    }

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

Original issue reported on code.google.com by lokim...@gmail.com on 20 Mar 2008 at 9:32

GoogleCodeExporter commented 9 years ago
This was reported by Lawrence

Original comment by lokim...@gmail.com on 20 Mar 2008 at 9:33

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

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

GoogleCodeExporter commented 9 years ago
Closing out as it is nonpublished

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