TclRobots

TclRobots is a programming game written in, and uses the Tcl language. In TclRobots the idea is to write a Tcl program that controls a robot. Your robot's mission is to seek out and destroy other robots, each running different control programs. TclRobots provides the arena and a library of robot control procedures to scan, drive, fire the cannon, etc.

A sample screen shot is here (15k).

Here is a sample TclRobots control program. This program takes the strategy of finding an opponent, then driving toward and shooting at the target.


#
# TclRobots - sample robot control program
# Tom Poindexter
#
# charger.tr

set dir [rand 360]
set nothing 0
set closest 0
 
# start of main code
 
while {1} {
 
  # look for an opponet
  set rng [scanner $dir 10]
 
  # if found and inrange
  if {$rng > 0 && $rng < 700} {
 
    # begin narrow scan
    set start [expr ($dir+20)%360]
    for {set limit 1} {$limit <= 40} {incr limit} {
      set dir [expr ($start-($limit)+360)%360]
      set rng [scanner $dir 1]
      if {$rng > 0 && $rng < 700} {
        # fire a shell, and backup scan so not to miss a moving target
        set nothing 0
        # charge!
        cannon $dir $rng
        drive $dir 70
        incr limit -4
      }
    }
  } else {
    incr nothing
    if {$rng > 700} {set closest $dir}
  }
 
  drive 0 0
  # check for nothing found in reasonable time
  if {$nothing >= 30} {
    set nothing 0
    drive $closest 100
    after 10000 drive 0 0
  }
 
  set dir [expr ($dir-20+360)%360]
}


The current version is 2.0 released March, 1996, and can be found at ftp://ftp.procplace.com/pub/tcl/sorted/games/tclrobots-2.0/tclrobots-2.0.tar.gz
TclRobots is currently based on Tcl 7.6 and Tk 4.2.

I sponsored a TclRobots tournament on the net September, 1994, and again in May, 1996. Results of the first two TclRobots Challenges are in ftp://ftp.procplace.com/pub/tcl/sorted/misc/TclRobots/


Back to Tom Poindexter's Home Page.
Last updated: December 28, 1999