NAME EGGHUNT: A simulator to aid the development of "robotic Easter Egg Hunters," as described on http://www.xs4all.nl/~sbolt/Other/e-EasterEggHunt.html Copyright (C) 1999, Pitronics This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Pitronics can be reached by email: sbolt@xs4all.nl DESCRIPTION I wrote this little simulator package to study the possibilities of my own Egg Hunter (Jaws), which uses weighted random search patterns. Compared to the (also simulated) baseline behaviour - - just a random bounce away from Playground border, Obstacles and gathering corner - the simulated Jaws now finds the five Eggs in about one third of the time. Over 100% better than what I started with! Ben Hitchcock added simulations of his Psyclone and an idealised long range Egg sensing `bot called Spoof. I hope others will find this package useful for simulating the behaviour of their own Egg hunters. Of course that means writing a little C(++), but things are organized to make that easy. There are sources for two different graphics libraries (grx for 32-bit Dos and Linux/X11, Turbo-C graphics for 16-bit Dos). If you have to use some other graphics library, only the files botgraph.h and botgraph.cc(cpp) need to be changed. Botgraph.cc(cpp) also contains the functions which automatically read the files `obstacle' end `egg', when the program starts. These files define the positions and sizes of the Obstacles and Eggs on the Playground. The other three source files are identical for all versions; differences between Dos and Linux are taken care of in lnx.h and the makefiles. Bot.cc(cpp) and bot.h contain low level functions, such as collision and Egg detection. The higher behaviour is done in jaws.cc(cpp), which you'll have to rewrite (and rename :) to represent your Egg Hunter. Basically rewrite the main() in jaws.cc(cpp), and add any separate functions you write to to bot.cc(cpp) and bot.h. That's all there is to it. On a LinuxBox with gcc and grx22 (or higher) installed, going to the source directory and typing make -f makefile.lnx Will recompile the all three `bots into dynamically linked executables weighing about 90K. In Dos or a Windows Dosbox with djgpp and grx22 (or higher) installed, you go to the source directory and type make -f makefile.dos To create statically linked executables weighing some 236K. If you have Turbo-C installed, use the 16-bit package and merely type make This results in 16-bit execuatables weighing 57K, statically linked. NOTE: To build just one of the executables, simply type its name behind the make command, for instance: make -f makefile.lnx jaws THE SIMULATED JAWS Is a much simplified representation of the real thing. But it does, I hope, catch the essence of his kind of Egg Hunt. The weights in his randomized search pattern make him somewhat conscious of the fact that the Playground is twice as long as it is wide. He orients himself on the IR beacon, turning more or less parallel to the long or short axis, taking the long one (left or right) twice as often as the short one (up or down). If the search pattern doesn't result in finding an Egg within a certain period, Jaws fiddles with the weights, in the hope of locating areas which are in the `shade' of Obstacles. Check the source to find out what exactly happens. SYNOPSIS Jaws - OPTIONS Type the name of the sim and an `h' on the command line to display a usage message: spoof -h You can run all three simulations with different time/steps and random seeds, like: Psyclone -t 20 -s 7 In the case of Jaws, a mode number determines the type of behaviour and (when non-zero) the number of time steps between re-orientations on the IR beacon. By setting mode to zero, you switch the sim to baseline behaviour, which is just a random bounce off Obstacles and borders. When mode is non-zero, a text line above the simulated Playground shows Jaws' current orientation and a number which determines how often he switches that orientation between up, down, left and right. This number changes when finding an Egg takes too long. AND THE REAL `BOT? A real Playground is presently being built to acommodate the real Jaws (hardware and most embedded software already finished); results appear on http://www.xs4all.nl/~sbolt/Other/e-EggHuntProgress.html FILES botgraph.cc(cpp) Interface with the graphics library you are using; Grx for the Linux and Dos 32-bit versions, Borland Turbo-C graphics for the 16-bit version. You need to change this file only if you want to use another graphics library. bot.cc(cpp) Low level functions, such as collision and Egg detection. jaws.cc(cpp) `Higher' behaviour functions for my own Egg Hunter, called Jaws. psyclone.cc(cpp) `Higher' behaviour functions for Ben Hitchcock's Psyclone. spoof.cc(cpp) `Higher' behaviour functions for an Egg Hunter using an ideal Egg Sensor, by Ben Hitchcock. botgraph.h Header file for the graphics. bot.h Header file for the low level functions. os_lnx.h, Take care of the differences between the Linux, os_mac.h, Mac, and Dos versions, which share the same os_dosgc.h, bot.cc(cpp), bot.h and jaws/psyclone/spoof.cc(cpp) os_dostc.h files. egavga.obj 16-bit version only: the graphics driver. This is a Borland support file which may be distributed only as part of a software package which bears a valid copyright notice. makefile.dos Makefile to compile the 32-bit source into a Dos executable, using djgpp. makefile.lnx Makefile to compile the 32-bit source into a Linux executable, using gcc. obstacle Defines the position and diameter of the ten Obstacles. Format: ten lines containing x, y and radius, separated by spaces. The values are in centimeters * 5, because the simulated Playground measures 500 * 250 pixels, while the real one is 100 * 50 centimeters. egg Defines the position and diameter of the five Eggs. Format: five lines containing x, y and radius, separated by spaces. The x and y values are in centimeters times five, but the radius is exagerated (the real Eggs have a diameter between 1 and 1.5 cm). licence.txt The GNU general public license readme.txt This file COMPATIBILITY The 32-bit protected mode executable compiled for MS-DOS uses "DPMI" (the DOS Protected Mode Interface) to allow DOS/BIOS calls from protected mode. It will run in MS-DOS, in a Windows-3.X Dosbox and in a Windows-9X Dosbox. The 16-bit executable runs in the same environments, but doesn't need DPMI. The precompiled Linux executable is suitable for Linux/X11. INSTALLATION If you want to run the 32-bit Dos executable on plain MS-DOS or something like it without a DPMI host, you must also put CWSDPMI.EXE (found in EGGHUNT\CSDPMI\BIN) in your PATH. ACKNOWLEDGEMENTS The protected mode executable found in the 32-bit Dos version was compiled with gcc 2.8.1, as found in the DJGPP packages. You can obtain a copy of this excellent compiler from any SimTel.NET mirror in the pub/simtelnet/gnu/djgpp/ subdirectory, or from one of the CCT mirrors, world-wide. For instance: ftp://ftp.euro.net/d5/simtelnet/gnu/djgpp/ (in The Netherlands). In many of the locations mentioned above you will also find the grx graphics library, used for graphical part of the EggHunt sim. Try for instance: ftp://ftp.euro.net/d5/simtelnet/gnu/djgpp/v2tk Or: http://www.gnu.de/software/GRX/ This product includes software developed by the University of California, Berkeley and its contributors. BUGS & BOTHER Please report them to the authors.