O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

TclRobots

TclRobots, written by Tom Poindexter, is a test of programming prowess. The goal is to program a robot that battles other robots and hopefully, survives to become the victor. How well a robot performs depends mostly on the Robot Control Program (RCP) you write. As in real life, there is randomness built into the contest, so even the best RCP is occasionally defeated.

The TclRobots arena is a square, 1,000 meters on each side. Robots, identical other than their controlling RCPs, have drive mechanisms that move them each in a given direction at a given velocity within the arena, scanners for seeking out enemy robots, and cannons for firing at the enemy. A contest involves two, three, or four robots, each trying to outlast the others. In Figure 20-4, two robot scanners have targeted enemies, complex.tr has taken a severe hit, and a cannon shot is in mid-flight.

A TclRobots contest

Figure 20-4.  A TclRobots contest

tclrobots starts a robot instance by execing a new wish interpreter,[3] then uses send to customize it. First, it transmits specially crafted subroutines that implement the RCP command set (commands such as drive, scan, and cannon). These commands define the RCP application programming interface (API), and they use send to invoke subroutines in tclrobots. Next, tclrobots sends the Tcl RCP source code to the robot and starts it running. (There’s actually a lot more detail behind the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required