CBOTS Copyright 1994 Bharat Mediratta Bharat.Mediratta@Eng.Sun.Com WHAT IS CBOTS? Cbots is a programming game, loosely based upon a game called Crobots by Tom Poindexter. To play Cbots you must program a robot to survive armed combat in a virtual arena. The robot is equipped with a cannon, a scanner, and a drive. The goal is to survive by running and fighting until your robot is the only one left running and is declared the winner. HOW DOES CBOTS WORK? Cbots is designed to use the Unix scheduler and shared memory system to allow Unix to handle the multitasking of the different robots. This system is easy to create, but has inherent problems; There are some systems without shared memory and there might be systems slow enough that scheduler might be too inefficient to schedule the robots properly. Currently Cbots has only been tested on a SPARCstation running Solaris 5.3. HOW DO I PROGRAM MY CBOT? To program your robot, you simply need to use the libcbot library (function prototypes and definitions below) to set up your robot. Also provided are some parameters for the simulator. Arena Stats ----------- Arena Size: 1,000 units. Max Number of Robots: 4 Robot Stats ----------- Max Speed: 100 units per second Scanning Accuracy: +/- 10 degrees Scanning Time: 1 update (75,000 microseconds) Max Number of Missiles: 3 Max Scanning Distance: 75% of arena Max Turning Speed: 33 Acceleration: 25 units per second squared Missiles Stats -------------- Max Speed: 300 Max Distance: 60% of arena Max Damage: 10 pts. Launching Time: .25 of a second Functions: CB_init(char *name) This is the only mandatory function. You must use this before any other CB_xxx() function call to initialize your robot. You also provide the name of your robot here. CB_dir(int angle) Angle is from 0 to 360. The coordinate system looks like this: 0 | 270 ----+---- 90 | 180 If your robot is doing the maximum turn speed (or less) the robot will immediately change direction. Otherwise, the robot will change direction when it's speed drops below that threshold. CB_scan(int angle, int resolution) This function scans the given angle for an enemy. It returns the distance to the enemy (or 0 if no enemy was found). Resolution is the amount of deviation you would like for your scan. For example if your scan was 3 degrees off of the enemy, but your resolution is 3 or greater, you will spot the enemy. This is useful in doing quick low-resolution scans to locate the enemy and then high-resolution scans to pinpoint him. This function also consumes a small amount of time (given above). CB_plot(int angle, int range) Plots a crosshair on the map at the given and the given range. The crosshair will remain on that spot for 2 seconds (unless superceded by another CB_plot call). This is mainly used for debugging robots. CB_drive(int speed) This function sets the desired speed for the robot. The robot accelerates or decelerates up to this speed based upon the acceleration given above. This speed can be negative, causing the robot to move backwards. Max speed is also given above. CB_launch(int angle, int range) This function launches a missile in the specified angle fused to explode at the specified range. This function also consumes a small amount of time (given above). CB_status(int flag) This function returns information about the robot. Specify the appropriate flag: ROBOT_X: ROBOT_Y: These return the absolute X and Y locations of the robot in the arena (origin is top left corner). ROBOT_DIR: ROBOT_SPEED: These return the robots direction and speed. These are the actual values, not the desired values. For example, if the robot is travelling above the turn speed at 45 degrees, you request a direction change to 90 degrees (which will not take place until the robot slows down) and then request ROBOT_DIR, you will get 45 degrees. ROBOT_DAMAGE: This returns the percentage of damage the robot has taken. All these flags return an integer. INSTALLATION AND DEMO - You will need to compile Cbots. Since Cbots has not been tested under many environments, you may need to hack up the Makefile and perhaps some of the source files to handle different architectures. Type 'make' to compile the cbots and cwatch binaries. Then cd to the 'robots' directory and type 'make' to make up the sample robots. - Run cbots from the main directory. Use the -x flag for an Xwindows display or -c for a curses display. The cwatch program must be in the same directory as cbots for you to observe the match. Sample: cbots -x robots/circle robots/hunter robots/run robots/hk - To run match play you need perl. Simply type 'match' followed by the number of matches and then the names of the robots you wish to play. If you wish to see tournament matches while they are playing, simply type 'Watch' ACKNOWLEDGEMENTS Thanks to Tom Poindexter for the idea behind the original CROBOTS. If he doesn't own them outright, he certainly shares the intellectual property rights to Cbots. Thanks also to Mike Neilly and Keith Hargrove for their extensive alpha and beta testing. Thanks especially to Mike for writing the X interface.