An example (tested, use the top-left 99x99 area of the board and put the robot elsewhere):
commands = 10000;
funct rand(local2, local3) local
{
robotic
{
set "local" random "local2" "local3"
}
}
sub wall(xp, yp)
{
robotic
{
put c07 Solid p00 "xp" "yp"
}
}
sub blank(xp, yp)
{
robotic
{
put c07 Space p00 "xp" "yp"
}
}
y = 0;
while(y <= 98)
{
loop(98)
{
wall(loopcount,y);
}
y += 1;
}
y = 0;
while(y <= 98)
{
x = 0;
while(x <= 98)
{
vis@x@_@y@ = 0;
blank(x,y);
x += 2;
}
y += 2;
}
cx = rand(0,49)*2;
cy = rand(0,49)*2;
cc = 50*50-1;
vis@cx@_@cy@ = 1;
while(cc > 0)
{
u = rand(0,1)*2-1*2;
v = rand(0,1)*u;
u -= v;
nx = cx+u;
ny = cy+v;
robotic { * "~f&nx&,&ny& &cc&" }
if((nx >= 0) & (nx <= 98) & (ny >= 0) & (ny <= 98))
{
if(vis@nx@_@ny@ == 0)
{
tx = u/2+cx;
ty = v/2+cy;
blank(tx, ty);
vis@nx@_@ny@ = 1;
cc -= 1;
}
cx = nx;
cy = ny;
}
}
robotic { * "done" }
gmzc, of course, stands for "GreaseMonkey's Zukes Compiler".
The compiler spews a crapton of debug info as I haven't worked out how to point out lines yet.
Also, there are bugs, although the only ones I'm aware of are with respect to escaping strings (you'll have to do \\\" instead of \" if you want double-quotes for now, otherwise it'll spew out bad Robotic) and possibly one related to small blocks (the situation i'm thinking of is "sub foo(bar) if(baz) { }").
There's a bunch of notes in syntax.txt.
Some of you might not want to build it. Well, good news everyone: I've included binary builds for FreeBSD 8 and NetBSD 5!
EDIT: Found a bug.
At the end of save_rob_if_true, it should read (note the != instead of the =):
} else {
save_rob_expr_calls(tree->l, FALSE);
fprintf(fp, "if ");
save_rob_expr(tree, TRUE);
fprintf(fp, " != 0 \"_%s%i\"\n", label_name, label_idx);
}
}
void save_rob_if_false(struct syn_tree *tree, char *label_name, int label_idx)
{
And same deal with same_rob_if_false, but with = instead of !=.
Will fix that Zukes code soon.
EDIT 2: Done.
Attached File(s)
-
gmzc-0.1.zip (48.87K)
Number of downloads: 182
This post has been edited by iamgreaser: 22 July 2010 - 10:02 AM

Help




















