A* First Test

Friday, July 24, 2009

So i started playing around, trying to implement A* into haxegui (AStar is a shortest-path finding algorithm, look here for probably the easiest tutorial about it), the good news are that sitnarf already wrote aPath is its easily imported and very generic, just give it a grid, mark the nodes and you're good to go. Bad news are that the benchmarks don't look that good, see the video below.

The drawing code does slow things down, but i had to visualize it somehow :) Here's a snippet, all this is done before the path calculation:
var container = this.getParentContainer();
container.redraw();

var s = Haxegui.gridSpacing;
var hs = s>>1;

var w = (container.box.width/s);
var h = (container.box.height/s);

var engine = new aPath.Engine();
engine.generateMap(w,h);

for(i in 0...w)
 for(j in 0...h) {
   // get top-most object
   var o = container.getObjectsUnderPoint(new flash.geom.Point(hs+i*s, hs+j*s)).pop();

   // mark it unwalkable if its a widget
   if(o!=container && !Std.is(o, toys.Socket) ) {
container.graphics.beginFill(Color.BLUE, .5);
container.graphics.drawRect(i*s, j*s, s, s);
container.graphics.endFill();

engine.map[i][j].close = true;
    }
   ...
   ...
Seen on the video, a 10x10px grid takes more than 3.5sec to be marked (this includes drawing "unwalkable" blue tiles, which is expensive, it takes about 0.55sec without, still not fast enough) I guess the most expensive is the getObjectsUnderPoint() but i'll need better profiling to be sure... The next step would be to get the target node, before doing all this, so i could minimize the gridded area to be checked. Any A*\haXe tips and optimizations will be more than welcome, have a great weekend!

Signal \ Slot experiments

Thursday, July 23, 2009

A Short screencast showing how widgets can be visually connected, i've always liked node-based or "graphical programming" software like PureData, it allows even non-programmers an easy entry point, and saves time typing, besides the obvious eye-candy. Next step would either be the A* algorithm, so "patch cables" would go around widgets, or maybe use curves and drop-shadows to fake them being "on-top" (check this link for a cool sample)

Couple of changes

Sunday, July 19, 2009

Changed the logo on the blog, started working on better documentation (the doc system itself and the commenting in the source) check the link above, its full of goodies! please leave any comments and have a great day!

Comparision of coding styles

Wednesday, July 15, 2009

this link has a tutorial for writing an analog clock in actionscript. I've ported it to haxe using two coding styles, one is pure haxe, the other in xml&hscript, to show you they are equally powerful, and the choice is completely yours. two things to note, clocks start ticking once loaded, from the time of creation, so the xml has the initialization offset of the all the xml parsing, its not a bug, as they could represent different time-zones. Secons, is that had this not been a demonstration, i would have probably gone with a 3rd hybrid coding style, using hscript in the haxe .hx file, instead of multiple classes...

haxegui screencast on youtube

Saturday, July 11, 2009

Screencast of an earlier version

haxegui SVN

this is how the current svn looks like: press "`" (Backtick) to pop up the console. more info can be found at http://code.google.com/p/haxegui/ please comment below, have fun!