• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Path Check for TD

Status
Not open for further replies.
Hello guys,

After millions of years away from the Hive and map editing, I have come back for a while with a few ideas to try out.

One of them is a TD with dynamic path check. That is, the path will be checked at the moment a player places a tower.

The arena is always rectangular, possibly with obstacles, and divided in 64x64 squares (cells) like the screenshot. I already have means to know the status of each cell (passable or blocked), and now I need an algorithm to find a path (any path) between the start (green !) and the end (orange !).

I have tried some approaches (depth-first, breadth-first, simplified A*) but all of them stops for no reason when the path gets too long. Could the reason be a JASS function limitation (function executed for too long, or too many loop iterations)?

Thanks already
 

Attachments

  • TDStadium 02.jpg
    TDStadium 02.jpg
    358.1 KB · Views: 136
Level 31
Joined
Jul 10, 2007
Messages
6,306
Look in my signature under resources in JASS folder. You'll find something pleasantly surprising =). You'll know it when you see it.

depth-first, breadth-first, and A* massively freeze wc3 when accounting for op limit. You need a more specialier algorithm

A* is ok when there is a path. It's terrible when there isn't one ;P.

A* is meant to find the shortest path, it isn't meant to check if a path exists or not ;).
 
Last edited:
Look in my signature under resources in JASS folder. You'll find something pleasantly surprising =). You'll know it when you see it.

You sure have a lot of things in there o_o

Anyway, I just guess that "IsPathBlocked" might be useful :p
I will try that later, thanks.

I tried those because they were the most straight and common-sense approach, didn't think much about effectiveness... But I should have imagined that they would be too heavy.
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,534
You sure have a lot of things in there o_o

Anyway, I just guess that "IsPathBlocked" might be useful :p
I will try that later, thanks.

I tried those because they were the most straight and common-sense approach, didn't think much about effectiveness... But I should have imagined that they would be too heavy.

Since no one has actually explained the issue as to why your algorithm failed, it's because jass has a strict maximum number of "actions" (operations) that can occur in any given "virtual thread". It's hard to measure how many operations each native takes, but essentially this value is called the op-limit (operation limit of a virtual thread)

You can evade the issue by starting new virtual threads. I suggest using ExecuteFunc.

Again, Nestharus' resource may be the correct solution to the problem, but evading the op-limit is a nice thing to know about.
 
Status
Not open for further replies.
Top