Rik's Treehouse > Babbling in Binary > NQC Scripts for Lego Mindstorms

NQC Scripts for Lego Mindstorms

Lego Mindstorms robot kits are so fun! You put them together like normal Lego, attach motors and sensors, and then program them to act and react to their surroundings! Add to that Dave Baum's powerful programming language NQC (Not Quite C) and you've got a definite winner! Here are some of my contributions.

 

tagger.nqc
tagger.nqc
2.33 KB
Apr 3, 2005
tagger.nqc version 1.0 for NQC
Play tag with other bots. This program will cause a bot to chase any other bots it sees. Tags are not implemented and must be judged by a referree (ie. a real person). Use in conjunction with taggee.nqc. (Requires randomWalkLRFB.nqh and botDetect.nqh.)
Freeware

 

taggee.nqc
taggee.nqc
2.32 KB
Apr 3, 2005
taggee.nqc version 1.0 for NQC
Play tag with other bots. This program will cause a bot to run away from any other bots it sees. Tags are not implemented and must be judged by a referree (ie. a real person). Use in conjunction with tagger.nqc. (Requires randomWalkLRFB.nqh and botDetect.nqh.)
Freeware

 

randomWalkLRFB.nqh
randomWalkLRFB.nqh
4.31 KB
Apr 3, 2005
randomWalkLRFB.nqh version 1.0 for NQC
Performs a random walk for a bot with left/right (LR) outputs and front/back (FB) bumpers. (Requires motorP.nqh and randP.nqh. Required by tagger.nqc and taggee.nqc.)
Freeware

 

botDetect.nqh
botDetect.nqh
3.78 KB
Apr 3, 2005
botDetect.nqh version 1.0 for NQC
Detects the proximity of other bots which are also running botDetect. If another bot has recently been detected will set the global variable botDetected to a positive value, otherwise it will be negative (or zero). (Requires randP.nqh. Required by tagger.nqc and taggee.nqc.)
Freeware

 

motorP.nqh
motorP.nqh
3.32 KB
Apr 3, 2005
motorP.nqh version 1.0 for NQC
Redefines the output functions so they support priorities. This is an unsophisticated solution to the problem of controlling outputs in a multitasking environment. I've seen better solutions but this has the advantage of being conceptually simple. (Required by randomWalkLRFB.nqh.)
Freeware

 

randP.nqh
randP.nqh
8.81 KB
Apr 3, 2005
randP.nqh version 1.1 for NQC
A (fast) pseudo-random number generator with a genuine random seed. The built-in function Random() is unsuitable for multiple bots because it always begins with the same seed so each bot generates the same sequence of random numbers. (Required by botDetect.nqh and randomWalkLRFB.nqh.)
What's new:
No longer depends on bitshift.nqh. If using NQC v2.4+ then uses more efficient form of bitshifting with operators instead of function calls.
Freeware

 

randG.nqh
randG.nqh
5.77 KB
Apr 3, 2005
randG.nqh version 1.1 for NQC
A (slow) genuine random number generator. The built-in function Random() is unsuitable for multiple bots because it always begins with the same seed so each bot generates the same sequence of random numbers.
What's new:
No longer depends on bitshift.nqh. If using NQC v2.4+ then uses more efficient form of bitshifting with operators instead of function calls.
Freeware

 

bitshift.nqh
bitshift.nqh
1.41 KB
Apr 3, 2005
bitshift.nqh version 1.0 for NQC
Older versions of NQC (v2.3-) do not support bitshifting with variable operands, so the following two functions are defined to do the job:
bitshiftLeft(in, bits, out); // out = in << bits
bitshiftRight(in, bits, out); // out = in >> bits

Freeware

Top of page
[Rik's Office Hours] [Contact Rik]
Last updated: Sun Apr 3 2005, 4:47am