A* algorithm: need help fixing path that come in contact with obstacle

I am using A* as a pathfinding technique for my AI; it works fine until it gets close to an obstacle (in my case rocks). Right now it just continues the loop if it finds a neighbor thats a rock. It should not actually do this. It should check it.

Allowed Moves: FORWARD,LEFT,RIGHT (LEFT & RIGHT at diagonals) turns are basically two phases: FORWARD, turn face then FORWARD (counts as one move with no additional cost)

The AI should know to turn left or right on the rock in the direction of the goal while also taking other rocks into account.

The line that checks for rocks is: if(at == 1 || at == 2) continue;

I guess you could use the neighborlist to check the sides of the ship.

However it shouldn’t always check it. Only when it comes in contact with a rock

Scenario 1: (ship should turn left (one move) once then continue on path) enter image description here

Scenario 2: (ship should either turn left or right twice (two moves) to unblock itself) enter image description here

Scenario 3: (ship should turn left or right depending on which path is shorter: doing two lefts will hit rock twice but distance is shorter than if it went right by 1 tile)

enter image description here

In each of these scenarios the face of the ship is the only thing that changes; unless its a forward move into the rock then there is no change. If right/left were used in any other situation (regular tiles) it would change position also.

public class AStarSearch {          private ServerContext context;     private List<AStarNode> openList;     private List<AStarNode> closedList;          private double ORTHOGONAL_COST = 1.0;     private double DIAGONAL_COST = ORTHOGONAL_COST * Math.sqrt(2.0);          public AStarSearch(ServerContext context) {         this.context = context;     }      private Comparator<AStarNode> nodeSorter = new Comparator<AStarNode>() {          @Override         public int compare(AStarNode n0, AStarNode n1) {             if(n1.fCost < n0.fCost) return 1;             if(n1.fCost > n0.fCost) return -1;             return 0;         }              };      public List<AStarNode> findPath(Player bot, Position goal){         openList = new ArrayList<AStarNode>();         closedList = new ArrayList<AStarNode>();         List<AStarNode> neighbors = new ArrayList<AStarNode>();         AStarNode current = new AStarNode(bot, bot.getFace(), MoveType.NONE, null, 0, bot.distance(goal));         openList.add(current);          while(openList.size() > 0) {             Collections.sort(openList, nodeSorter);             current = openList.get(0);             if(current.position.equals(goal)) {                 List<AStarNode> path = new ArrayList<AStarNode>();                 while(current.parent != null) {                     path.add(current);                     current = current.parent;                 }                 openList.clear();                 closedList.clear();                 Collections.reverse(path);                 return path;             }             openList.remove(current);             closedList.add(current);                          int x = current.position.getX();             int y = current.position.getY();             switch (current.face) {                 case NORTH:                     neighbors.add(new AStarNode(new Position(x, y), VesselFace.NORTH, MoveType.NONE,current,0,0));                     neighbors.add(new AStarNode(new Position(x, y+1), VesselFace.NORTH, MoveType.FORWARD,current,0,0));                     neighbors.add(new AStarNode(new Position(x-1, y+1), VesselFace.WEST, MoveType.LEFT,current,0,0));                     neighbors.add(new AStarNode(new Position(x+1, y+1), VesselFace.EAST, MoveType.RIGHT,current,0,0));                     break;                 case EAST:                     neighbors.add(new AStarNode(new Position(x, y), VesselFace.EAST, MoveType.NONE,current,0,0));                     neighbors.add(new AStarNode(new Position(x+1, y), VesselFace.EAST, MoveType.FORWARD,current,0,0));                     neighbors.add(new AStarNode(new Position(x+1, y+1), VesselFace.NORTH, MoveType.LEFT,current,0,0));                     neighbors.add(new AStarNode(new Position(x+1, y-1), VesselFace.SOUTH, MoveType.RIGHT,current,0,0));                     break;                 case SOUTH:                     neighbors.add(new AStarNode(new Position(x, y), VesselFace.SOUTH, MoveType.NONE,current,0,0));                     neighbors.add(new AStarNode(new Position(x, y-1), VesselFace.SOUTH, MoveType.FORWARD,current,0,0));                     neighbors.add(new AStarNode(new Position(x-1, y-1), VesselFace.WEST, MoveType.RIGHT,current,0,0));                     neighbors.add(new AStarNode(new Position(x+1, y-1), VesselFace.EAST, MoveType.LEFT,current,0,0));                     break;                 case WEST:                     neighbors.add(new AStarNode(new Position(x, y), VesselFace.WEST, MoveType.NONE,current,0,0));                     neighbors.add(new AStarNode(new Position(x-1, y), VesselFace.WEST, MoveType.FORWARD,current,0,0));                     neighbors.add(new AStarNode(new Position(x-1, y+1), VesselFace.NORTH, MoveType.RIGHT,current,0,0));                     neighbors.add(new AStarNode(new Position(x-1, y-1), VesselFace.SOUTH, MoveType.LEFT,current,0,0));                     break;             }             for(AStarNode neighborNode : neighbors) {                 // Compute the cost to get *to* the action tile.                 double costToReach = current.position.distance(neighborNode.position);                  int at = context.getMap().getTile(neighborNode.position.getX(), neighborNode.position.getY());                 if(at == 1 || at == 2) continue; // this is the line where it checks if tile is rock or not                  double gCost = current.gCost + costToReach;                 double hCost = heuristicDistance(neighborNode.position,goal);                 AStarNode node = new AStarNode(neighborNode.position, neighborNode.face,neighborNode.move, current, gCost, hCost);                 if(positionInList(closedList, neighborNode.position) && gCost >= node.gCost) continue;                 if(!positionInList(openList, neighborNode.position) || gCost < node.gCost) openList.add(node);             }         }         closedList.clear();         return null;     }          private double getActionCost(Position node, int currentTile) {         if(currentTile > 3 && currentTile < 11) {             return 0.2;         }else {             return 1;            }     }      private double heuristicDistance(Position current, Position goal) {         int xDifference = Math.abs(goal.getX() - current.getX());         int yDifference = Math.abs(goal.getY() - current.getY());          int diagonal = Math.min(xDifference, yDifference);         int orthogonal = xDifference + yDifference - 2 * diagonal;          return orthogonal * ORTHOGONAL_COST + diagonal * DIAGONAL_COST;     }          private boolean positionInList(List<AStarNode> list, Position position) {         for(AStarNode n : list) {             if(n.position.equals(position)) return true;         }         return false;     }  } 


public class AStarNode {      public Position position;     public VesselFace face;     public MoveType move;     public AStarNode parent;     public double fCost, gCost, hCost;          public AStarNode(Position position, VesselFace face, MoveType move, AStarNode parent, double gCost, double hCost) {         this.position = position;         this.face = face;         this.move = move;         this.parent = parent;         this.gCost = gCost;         this.hCost = hCost;         this.fCost = this.gCost + this.hCost;     }    }   

There will be no additional cost of running into a rock as long as its a shorter route. Also, if a ship tries to turn left or right from its current position; but there is a rock at that tile it will move up one tile and changes its direction.

The overall question/goal: How do I fix my current code to account for these situations; please provide an implementation or instructions.

Problem with URL path when I applied SEO friendly URL

I was working on PHP project and making SEO friendly URL Like,

OLD : http://example.com/list_product?q=men-top-wear

New : http://example.com/list_product/men-top-wear

Here is my .htaccess file:

RewriteEngine on Options -MultiViews  RewriteCond %{ENV:REDIRECT_STATUS} ^$   RewriteCond %{QUERY_STRING} ^q=(.*)$   RewriteRule ^list_product$   /list_product/%1? [R=301,L]   RewriteRule ^list_product/(.*)$   list_product.php?q=$  1 [L]   RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$   /$  1.php [NC,L] 

It’s working well but my link path has been changed to: http://example.com/list_product/images/logo.png

But I need this to be: http://example.com/images/logo.png

It adds list_product, but it’s not working. Does anyone know why this is happening?

How do Path of War stances work out of combat?

In Dreamscarred Press’s Path of War (a 3rd Party supplement to Pathfinder), it’s unclear to me what can(‘t) be done out of combat, especially with regard to stances.

Lines like this (from System & Use) imply one might be in a stance all day long:

A stance remains in effect indefinitely and is never expended. The benefit of your chosen stance continues until you change to another stance you know as a swift action.

Though this implies there could be some limit, or at least that they’re intended for combat more than out of combat:

A stance is a type of fighting method that you maintain from round to round. So long as you stay in a stance, you gain some benefit from it. A martial disciple who performs a kata and assumes a specific posture as he prepares to fight is using a stance.

Lets take as an example this stance from the Shattered Mirror discipline (which was just released in the Harbinger PDF but isn’t yet on the PFSRD).

Silvered Mirror Stance (Su): When you assume this stance, choose a single non-personal range power, psi-like ability, spell, or spell-like ability affecting you. While you maintain this stance, allies within 30 feet of you also gain the benefits of the chosen effect for as long as it is affecting you

This would be an amazing way to share buffs out of combat, e.g. casting Overland Flight or Stoneskin on the Harbinger and getting it for free on any ally within 30′. What are the limits to this?

Can a Magus use spellstrike with Path of war’s maneuvers?

I would really like to know or will maneuvers conflict with the use of spellstrike?

Pathfinder and path of war. My friends and I are planning a pathfinder game. I had intended to play a Magus and one of my friends wanted to play a Warden from Path of war. The gm ok’ed him using it and he started to talk about the maneuvers the three classes of path of war get and that there were feats to allow the original classes from path finder to use them. martial training feats. While lets say a fighter can use them with no problem, just get a few of the matrial training feats and you are good to go. I was thinking into investing some of my feats to use the maneuvers and take advantage of stances.

Path of War Defense conundrum?

Path of War has Strike, Boost, Counter, and Stance.

Strike – usually an attack and extra damage and some effects

Boost – extra damage usually

Counter – repost, dodge, reaction

Stance – at will mods to certain aspects of combat

So my friend and I got in to a bit of a debate. Some Strikes and Boost can catch a target Flat-Footed. But if said target has a Counter,…can they counter the Strike/Boost while Flat-Footed? Specially if they don’t have Uncanny Dodge?

Range Touch Attacks, and Path of War Maneuvers?

Using Adamant Entertainment’s Warlock class School Ability – Arcane Bolt, a ranged touch attack.

Arcane Bolt (Su): You can make a ranged touch attack that does 1d6 points of damage, +1d6 for every two warlock levels. The warlock may choose whether the damage is acid, cold, electricity, or fire. The range on an Arcane Bolt is 100ft. + 10ft./level.

Can it be used with interchangeably between melee and ranged attack maneuvers with the Path of War rules or is it strictly a ranged attack? If ranged only do I still need Point-Blank Shot and Precise Shot and Defensive Shot/Casting vs AOOs?

Calculate min number of moves (no path involved)

I’m looking to implement an algorithm that will calculate the minimum number of moves based on the rules below.

Let’s say that we have a grid (NxM), as exampled in the image below.

enter image description here

Each cell will be the sum based on the row and column and I can subtract 1 unit from one cell and add it to a neighbour. For example, on the image above, the minimum number of moves on Initial will be 2 and on Initial – 2 will be 4.

Can an 8th level Monk/Barbarian (Path of the beast) really make 5 attacks per turn?

In Tasha‘s Cauldron of Everything, WotC released a new Primal Path for the babarian, the "Path of the Beast" which has the following rage feature:

Until the rage ends, you manifest a natural weapon. It counts as a simple melee weapon for you, and you add your Strength modifier to the attack and damage rolls when you attack with it, as normal. You choose the weapon’s form each time you rage:[…]

Claws. Each of your hands transforms into a claw, which you can use as a weapon if it’s empty. It deals 1d6 slashing damage on a hit. Once on each of your turns when you attack with a claw using the Attack action, you can make one additional claw attack as part of the same action.

Combined with 5 monk levels to get Extra attack and flurry of blows, could such a monk barbarian make 5 attacks in one round like:

1st round:

  • rage (bonus action)
  • 2 attacks (action) with claws
  • 1 extra claw attack (from "claws" feature)

2nd round:

  • 2 attacks (action) with claws
  • 1 extra claw attack (from "claws" feature)
  • 2 more attacks (bonus action flurry of blows)

Or am I missing a restriction that prevents this?