Is your code not working? what do you need help with?
I use A* in my pacman game to find paths, i originally implemented the code from an old friend which was posted as a snippet and can still be found here
https://codes-sources.commentcamarche.net/source/46577-algorithme-aI since got Sreject to rewrite it (or well, reimplement an existing A* algorithm in js) in js, which runs via COM, which is way faster than doing it in mIRC script.
The code is dynamic and can be used for any map:
maptobvar pacservg
noop $jsAStarLoadMap(&map)
var %as $jsAStarSearch(x,y,x1,y1)
where x would be your Q, y would be your 14, x1 S and y1 would be 12, except the letter would be converter to numbers. and it would start at 0 not 1.
It works with binary variable, but there is a function (maptobvar) which convert an hash table to a binvar, which you could use or rewrite to suit your need with the ini.
The binvar needs to represent your map on a single line, where each byte value represent a state, 0 for a square you can go to, and 1 for a square you can't go to. the first byte represent the width of the map.
it would return the list of squares required to reach the end if it's possible, in the form X.Y X1.Y1
Here is the code for the sake of it, but you'll probably need help setting things up, feel free to join the channel in my signature for that.
alias -l comShell return Pacman/jsAStar/Shell
alias -l comEngine return Pacman/jsAStar/JSEngine
alias -l comMap return Pacman/jsAStar/Map
alias -l jsAStarLoadMap {
if ($jsAStarInit) {
return $v1
}
if ($com($comMap)) {
.comclose $v1
}
if (!$com($comEngine, createMap, 1, &bstr, $1, dispatch* $comMap) || $comerr) {
return Failed to load the map
}
}
alias jsAStarSearch {
if (!$com($comMap, search, 1, integer, $1, integer, $2, integer, $3, integer, $4, bool, false) || $comerr) {
echo -s Failed to perform astar search > $1- > $com($comMap).errortext
return
}
return $com($comMap).result
}
alias -l jsAStarInit {
var %error
if ($com($comShell) && $com($comEngine)) return
jsAStarCleanup
.comopen $comShell MSScriptControl.ScriptControl
if (!$com($comShell) || $comerr) %error = Failed to create MSScriptControl.ScriptControl instance
elseif (!$com($comShell, language, 4, bstr, jscript)) %error = Failed to set shell language
elseif (!$com($comShell, AllowUI, 4, bool, $false) || $comerr) %error = Failed to disable js UI
elseif (!$com($comShell, timeout, 4, integer, -1) || $comerr) %error = Failed to unset js timeout
elseif (!$com($comShell, ExecuteStatement, 1, &bstr, $jsAStarScript) || $comerr) %error = Failed to execute js script
elseif (!$com($comShell, Eval, 1, bstr, this, dispatch* $comEngine) || $comerr || !$com($comEngine)) %error = Failed to create reference to the JS engine
else return
jsAStarCleanup
return %error
}
alias -l jsAStarCleanup {
if ($com($comMap)) .comclose $v1
if ($com($comEngine)) .comclose $v1
if ($com($comShell)) .comclose $v1
}
alias -l jsAStarScript {
var %file = $scriptdirmAStar.js
bread $qt(%file) 0 $file(%file).size &jsAStarScript
return &jsAStarScript
}
The js file can be found here
https://www.dropbox.com/s/s70z4gnikfatr57/mastar.js?dl=0