aStar on JavaScript

Did you create a mod, map, music, or a tool? Present them here and earn feedback!
Note: addon requests do not belong here.
Note, everything uploaded to this forum, MUST have a license!
Post Reply
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

aStar on JavaScript

Post by Prot »

A* Implementation on JavaScript
astar.wz
(5.34 KiB) Downloaded 147 times
Worked only on Warzone2100 ver 4.0+
This mod will not work on the lastest stable warzone2100 ver 3.4.1

This mod file shows how the new version of the game should load mods, their hierarchy of directories and includes.
The file contains the A* functions, as well as a test minimod that draws a line of the calculated path from the beacon to beacon in a game match.

After the start of the match, just brost two beacons (Ctrl+H) and A* will calculate the distance of the full path, including obstacles, as well as water crossability.
And will throw result in STDOUT through debug() builtin function, and also will draws a red line inside the game.

Overall, it's pretty fast
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: aStar on JavaScript

Post by Prot »

New features and fixes

Get here: https://github.com/EuPhobos/astar

- Now edges of the map are surrounded by impassability to fix the "impossible" workaround
- Added the ability to build a diagonal path
- Added game objects that are returned as an array of coordinates if destructible and encountered on the way
- Destructible game objects the algorithm tries to bypass by default, but if the workaround is too long, it builds a path through the objects and returns the interfering objects in a separate array
- Now the graphs can be "hotly" reinitialized by changing the algorithms of the "diagonal or not" path during the match of the game
- Added new symbols to the schematic map
- The schematic map can be disabled with the flag, during initialization
map.png
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: aStar on JavaScript

Post by Cyp »

How does that Ascii renderer perform compared to the current OpenGL/OpenGLES/Vulkan/Metal/DirectX renderers?
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: aStar on JavaScript

Post by Prot »

From JS, using new static array mapTiles[] added by pastdue in 4.0 release.
Just compiled variable and put to debug() function to stdout.
here variables "pic": https://github.com/EuPhobos/astar/blob/ ... ar.js#L417
Its useful for me as debugging pathfinding. I'm not trying to create a dwarf fortress :lol2:
Post Reply