Login | Register

RoboZZle Forums

Forums / General / I made a RoboZZle variant today.

Log in to comment.

Is that supposed to be a sort of a program? Don't get me wrong, it's fine that you play with programming, but why would the rest of the world be interested in whatever it is that you have posted? It's painfully unreadable, and can't be compiled without a library containing all the functions that you use.

eBusiness, 36 months ago.

By the way, there are tab characters in there. Do a "View Source" and the code should be a bit more readable.

GreaseMonkey, 36 months ago.

I got bored, and some crazy idea came up, so I decided to do some Python-fu.

Basically, it's RoboZZle with a (somewhat) simple programming language that you'd bash out in a text editor (or an HTML textarea :D).

The only errors are syntax errors. If you try to, say, call a nonexistant function, it'll just do nothing.

Names and conditions keep lexing until a char which isn't alpha-numeric or an underscore appears, then we continue scanning from that non-alphanumscore char.

For @, ?, and ~, if there is no valid name (it must start with an alpha or underscore char), this ends the block, and we continue scanning from that non-alphascore char. Blocks must match their own symbols, and blocks must be terminated correctly, or we throw an error.

The syntax is as follows.

funct_name
Push a function name onto the stack. Note that all names and conditions take the same characters as C names. Also note that it pushes the name, not a pointer to the function.

@funct_name ... @
Declare a function. Built-in functions cannot be overridden, they are:
gf = go forward
gl = go left (that is, turn)
gr = go right (that is, turn)
pr = paint red
pg = paint green
pb = paint blue

;
Pops off a name, and executes the function with that name.

?cond ... ?
~cond ... ~
Conditional blocks. If you want to return from a function, you'll need to break out of this first. ? is for "if true", ~ is for "if false".
The conditions are:
cr = colour is red
cg = colour is green
cb = colour is blue

/
Pops a function name off the value stack, if not empty.

!
Returns from the function.

-
Pops a function/program counter pair off the execution stack.

Here's an example. It requires a rectangular board, mostly blue, but with a red border. See if you can guess what this does.

@f_fwd
gf;
?cr
gr;gr;
f_rtrace_wrap;
?
@

@f_rtrace_wrap
f_rtrace;
@

@f_rtrace
gf;
~cr
f_rtrace--;
~
?cr
gr;gr;gf;
?
@

@f_main
?cb gl pg ?
~cb gr pb ~
;;
f_fwd;
f_main-;
@

f_main;

GreaseMonkey, 36 months ago.

Previous page (1 / 1) Next page

©2009 Igor Ostrovsky and other contributors. Terms of use