Exemple #1
0
 void moveAgent()
 {
     if (startState.state != goalState.state)
     {
         if (!moving && plan.Count > 0)
         {
             action = plan.Pop() as ADAstarAction;
             moving = true;
         }
         else if (moving && plan.Count > 0)
         {
             startObject.transform.Translate(-action.direction);
             startState.state = startObject.transform.position;
             //_moveAgent((-action.direction)/10);
             iteration++;
             if (iteration == 10)
             {
                 iteration = 0; moving = false;
             }
         }
     }
     else
     {
         moving       = false;
         planExecuted = true;
         can_i_plan   = true;
         plan.Clear();
     }
 }
Exemple #2
0
    public override void generatePredecesors(ref DefaultState currentState, ref DefaultState previousState, ref DefaultState idealGoalState, ref List <DefaultAction> transitions)
    {
        List <Vector3> moves = new List <Vector3>();

        moves.Add(new Vector3(1.0f, 0.0f, 0.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, 0.0f));
        moves.Add(new Vector3(0.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(0.0f, 0.0f, -1.0f));
        moves.Add(new Vector3(1.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(1.0f, 0.0f, -1.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, -1.0f));


        ADAstarState curState = currentState as ADAstarState;

        Vector3 obs = new Vector3(3.0f, 0.5f, 0.0f);

        foreach (Vector3 move in moves)
        {
            if (!(curState.state - move).Equals(obs))
            {
                ADAstarAction action = new ADAstarAction();
                action.cost      = 1;
                action.direction = -move;
                ADAstarState st = new ADAstarState(curState.state - move);
                action.state = st;
                transitions.Add(action);
            }
        }
    }
Exemple #3
0
 void moveAgent()
 {
     if(startState.state!=goalState.state)
     {
         if(!moving && plan.Count > 0){
             action = plan.Pop() as ADAstarAction;
             moving = true;
         }
         else if(moving && plan.Count > 0)
         {
             startObject.transform.Translate(-action.direction);
             startState.state = startObject.transform.position;
                 //_moveAgent((-action.direction)/10);
             iteration++;
             if(iteration==10)
             { iteration=0; moving=false;}
         }
     }
     else
     {
         moving = false;
         planExecuted=true;
         can_i_plan = true;
         plan.Clear();
     }
 }
Exemple #4
0
    public override void generateTransitions(ref DefaultState currentState, ref DefaultState previousState, ref DefaultState idealGoalState, ref List<DefaultAction> transitions)
    {
        List<Vector3> moves = new List<Vector3>();
        moves.Add(new Vector3(1.0f, 0.0f, 0.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, 0.0f));
        moves.Add(new Vector3(0.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(0.0f, 0.0f, -1.0f));
        moves.Add(new Vector3(1.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, 1.0f));
        moves.Add(new Vector3(1.0f, 0.0f, -1.0f));
        moves.Add(new Vector3(-1.0f, 0.0f, -1.0f));

        ADAstarState curState = currentState as ADAstarState;

        Vector3 obs = new Vector3(3.0f, 0.5f, 0.0f);

        foreach(Vector3 move in moves)
        {
            if(!(curState.state+move).Equals(obs))
            {
            ADAstarAction action =  new ADAstarAction();
            action.cost = 1;
            action.direction = move;
            ADAstarState st = new ADAstarState(curState.state + move);
            action.state = st;
            transitions.Add(action);
            }

        }
    }