public override bool isAGoalState(ref DefaultState state, ref DefaultState idealGoalState) { ADAstarState currentState = state as ADAstarState; ADAstarState goalState = idealGoalState as ADAstarState; return(Vector3.Distance(currentState.state, goalState.state) < 1); }
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); } } }
// Use this for initialization void Start() { startState = new ADAstarState(startObject.transform.position); goalState = new ADAstarState(goalObject.transform.position); plan = new Stack <DefaultAction>(); }
// Use this for initialization void Start() { startState = new ADAstarState(startObject.transform.position); goalState = new ADAstarState(goalObject.transform.position); plan = new Stack<DefaultAction>(); }
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); } } }