I'd like to request some A* methods/functions that:
1: don't come with 54 terabyte of comments between the code that make it unreadable, and for me, unusable. See, I don't want to know how the code works, I only want to know how the algo should be used.
2: are completely local, no globals, global arrays, wasted consts etc.
3: are clear about what the input and output formats are.
4: come *only* as one type with methods/functions, I don't want to see any examples that mess the whole thing up, also I don't want any external game-depended stuff in the core pathfinding algo. Only its own startX/Y and endX/Y fields. In fact, who's talking games anyway?
Actually what I'd like to see is a type that looks as follows:
If it's easy to adjust the A* code in the archives to this format then I'd be grateful to the one who does so. :-)
1: don't come with 54 terabyte of comments between the code that make it unreadable, and for me, unusable. See, I don't want to know how the code works, I only want to know how the algo should be used.
2: are completely local, no globals, global arrays, wasted consts etc.
3: are clear about what the input and output formats are.
4: come *only* as one type with methods/functions, I don't want to see any examples that mess the whole thing up, also I don't want any external game-depended stuff in the core pathfinding algo. Only its own startX/Y and endX/Y fields. In fact, who's talking games anyway?
Actually what I'd like to see is a type that looks as follows:
Type TPathfinder Field status:Int ' 0: no possible path, 1:path found Field startX:Int, startY:Int, endX:Int, endY:Int Field diagonals:Int=1 ' true: use diagonal routes in pathfinding Field mapwidth:Int Field mapheight:Int Field map:TBank ' representing a 2d map where 0=walkable and 1=wall Field route:Int[] Method Setmapwidth(width:Int) ' all kinda bounds checks here ' .. ' .. If mapwidth<1 RuntimeError "mapwidth<1" mapwidth=width Mapdimensions End Method Method Setstart(x:Int,y:Int) Assert x>=0 And x<mapwidth "start X out ot range" Assert y>=0 And y<mapheight "start Y out ot range" startx=x; starty=y End Method Method Setend(x:Int,y:Int) Assert x>=0 And x<mapwidth "end X out ot range" Assert y>=0 And y<mapheight "end Y out ot range" endx=x; endy=y End Method Method Mapdimensions() mapheight=BankSize(map)/mapwidth If mapheight<1 RuntimeError "mapheight<1" End Method Method Setmap(bank:TBank=Null) Assert bank<>Null "bank=null" Assert BankSize(bank)>=1 "no dimension in bank" map=bank Mapdimensions End Method Method Findpath() ' resulting path in a 'resliced' route[]. ' as [x0, y0, x1, y1, x2, y2, x3, y3, ..etc. .. xn,yn] ' ^ start ^ end ' End Method End Type ' to use: ' make some bank ' make a pathfind instance ' add bank to instance ' set width and start/emd coords ' find path ' read out path from array ' yay \o/
If it's easy to adjust the A* code in the archives to this format then I'd be grateful to the one who does so. :-)
