Page 1 of 1

aStar on JavaScript

Posted: 30 Mar 2021, 20:13
by Prot
A* Implementation on JavaScript
astar.wz
(5.34 KiB) Downloaded 152 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

Re: aStar on JavaScript

Posted: 05 May 2021, 13:59
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

Re: aStar on JavaScript

Posted: 05 May 2021, 17:36
by Cyp
How does that Ascii renderer perform compared to the current OpenGL/OpenGLES/Vulkan/Metal/DirectX renderers?

Re: aStar on JavaScript

Posted: 05 May 2021, 21:09
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: