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;     }  } 

AStarNode:

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.

I’m having trouble with SetBool and animations on Unity. Can anyone help me?

I’m trying to get a Skeleton Model to go from its walking animation to its idle animation using a bool that checks for input. Currently, in-game, the skeleton doesn’t leave it’s walking animation and stays in it even when not walking. I’ve posted my code below. I’m kind of stumped so if anyone can give me some guidance it’d be greatly appreciated.

public class SkeletonMove : MonoBehaviour {  private float velocity = 5f;  public bool _isWalking = false;  Vector2 input;  void Update()     {         GetInput();          if (Mathf.Abs(input.x) < 1 && Mathf.Abs(input.y) < 1) return;          // CalculatedDirection();         Rotate();         Move();     }  void GetInput()     {         input.x = Input.GetAxisRaw("Horizontal");         input.y = Input.GetAxisRaw("Vertical");     }  void Move()     {         _controller.Move(transform.forward * velocity * Time.deltaTime);         _anim.SetBool("Walking", _isWalking);           if (input.x != 0 || input.y != 0)         {             _isWalking = true;         }          if (input.x == 0 && input.y == 0)         {             _isWalking = false;         }            //transform.position += transform.forward * velocity * Time.deltaTime;     } 

Help with settings for Verified list please

I have in excess of 500k of verified sitelist_Blog Comment-General Blogs. With a lot of do-follows
I want to attempt to post a comment to all the do-follows, and I don’t care about keyword matching etc. I’m doing some parasite linking. When I try to set it up, it goes through the list eventually but only posts to about 100. I just don’t get it. In Scrapebox you can just import a list of good urls and an post to them. How do I do that with GSA ?

The number of threads keeps decreasing. Help me.

My vps are fine. cpu usage is within 10% and ram usage is 200mb.

I bought this from Solidseo
I bought 50 Private proxy products from Solidseo and I am using them.

At first, when threads set 100, it goes back and forth between 90 and 100.
But after 9 hours, he goes back and forth between 30 and 40.

I’m using a catchall emil and I’m using three.

Also, I am using the list of serverified lists. I do not use scape

Help! My PCs polymorphed my boss enemy! What do I do?

Our Druid has recently gotten access to the polymorph spell and has started polymorphing the opponents I so lovingly crafted for our (well, mostly my) enjoyment. (So far, he has been turning them into rabbits, not yet killer whales.)

Now, the canonical response to a polymorph is to reduce the polymorphed creature to 0 HPs, upon which it will transform back. Or to attempt to break the spellcaster’s concentration.

However, polymorph is a 4th level spell, not a cantrip. It does not seem all that likely the target’s allies know the spell, can connect the dots when their friend suddenly turns into a bunny, and start to attack the bunny, or the spellcaster. It seems more likely that they will just blink upon seeing their friend transformed into a bunny, shrug, write him off, and continue battling the PCs as before. Which would essentially take the target out of the fight.

I have been thinking about allowing the target’s allies an Arcana check each, against some reasonable DC (e.g., 14, which is 10 plus the spell level of polymorph). On a success, they recall hearing about the Polymorph spell and about the two possible remedies. On a failure, they don’t. In which case the target will remain polymorphed, until it gets hit by a stray fireball or some such. I might even allow the target itself an Arcana check, and on a success, it will try reducing its own HPs. Well, this might at least make for some fun.

It looks to me like polymorph might be a bit overpowered against opponents whose allies only consist of non-spellcasters, because they will likely not know what steps to take to break the effect. Is there a better way to role-play what happens to a polymorphed enemy?

Help needed with several engines use case

We are developing an app, aprox 50k RPM read, 1k RPM write, it ask via key and get a JSON. The search is always made by key. I’m inclined to use one MySQL 8 table with a Id field and JSON field with innodb. Seems simple, cheap and fast accessing by index. Each index can have n rows (30 max), total size of table less than 100gb. Response time is important, I think 2-10ms are achievable on MySQL. The other, more expensive options that I have are DynamoDB and ElasticSearh (can’t use another tool). Can’t find a comparison for this use case to help me know if I’m in the correct path. Do you see any cons of using MySql or I’m missing something? Thanks!!

Help me understand the REAL deal about SMM Panels

So I have been involved in online advertising to clients across the globe for almost 20 years off and on. My most recent return was about 6 weeks ago hoping to build a viable business again but it was after about large break. When I left; interstitial ads, keyword traffic,desktop ads were the hot items with mobile and social on the horizon. I come back to SMM and organic and API driven options. In research I see many options with SMM Panels to obtain deep discount prices almost lower than…

Help me understand the REAL deal about SMM Panels

Need help with gravity simulation in 2D game engine

I’m writing a 2D game engine using C++ and SDL2 and started implementing a rigidbody component similar to that of unity to my gameobjects. I have a method in the rigidbody class called AddForce which takes a 2D vector force as a parameter and calculates the velocity vector using F = M*A, I use this function to move the character left and right using the keyboard arrows. Now my question is, how do I manage the gravity with this and how do I calculate the resultant force of the gravity and the force applied when pressing either keyboard arrows. Here is the rigidbody class.

#ifndef RIGIDBODY_H #define RIGIDBODY_H  //Game engine libraries #include "gameEngine/Game.h" #include "gameEngine/GameObject.h" #include "gameEngine/Component.h" #include "gameEngine/components/Transform.h"  //GlM library #include "glm/glm.hpp"  class RigidBody : public Component { private:     Transform* m_transfrom; private:     float m_mass;     float m_acceleration;     glm::vec2 m_forceApplied;     glm::vec2 m_velocity; private:     float m_deltaTime;  public:     RigidBody(float mass)     {         m_name = "RigidBody";         m_mass = mass;         m_acceleration = 0;         m_forceApplied = glm::vec2(0,0);         m_velocity = glm::vec2(0,0);      } public:      void AddForce(glm::vec2 force, float deltaTime)      {            float forceMagnitude;         m_deltaTime = deltaTime;         m_forceApplied = force;          forceMagnitude = glm::length(force);         m_acceleration = forceMagnitude / m_mass;       }      private:      glm::vec2 CalculateVelocity()      {          float velocityMagnitude;          static glm::vec2 newVelocity = glm::vec2(0,0);           velocityMagnitude = m_acceleration * m_deltaTime;           if(m_forceApplied.x != 0 || m_forceApplied.y != 0)              newVelocity = glm::normalize(m_forceApplied);          else            newVelocity = glm::vec2(0,0);           newVelocity = newVelocity * velocityMagnitude;           return newVelocity;       }   public:     void Initialize() override     {         m_transfrom = m_owner->GetComponent<Transform>("Transform");     }     void Update(Game instance, float deltaTime) override     {         m_velocity += CalculateVelocity();         m_transfrom->position.x += m_velocity.x * deltaTime;         m_transfrom->position.y += m_velocity.y * deltaTime;     }     void Render() override     {      }  };   #endif