|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
Artificial life evolution program in Borland C++ ObjectWindows, WinHelp source fileThe WAdapt.rtf source file is compiled by the Windows Help Compiler to produce the WAdapt.hlp Windows 3.1 WinHelp file for the WADAPT project that experiments with evolution in an artificial life cell colony. This RTF file describes features specific to WAdapt's calculations and commands. A second RTF file (sdibwin.rtf) is compiled along with this one. It describes the graphics features that are common to several of my programs. If you use Microsoft Word, these WinHelp source files are based on the helpfile.dot template, which you might find useful. The RTF file in the zip file appears to have some text left over from the "WShowfs" IFS fractal project where it began. It's possible I planned to implement some of those features here, or not. I can't tell. Out of caution, I left the text in, but removed most of it from this web page listing. This page also has a listing of the WAdapt.RC Windows resource file and a variety of screenshots. WShowfs.RTF# $ K + WAdapt Help Contents This Help file is from another application (wshowfs), and has not been completely modified for this one. Some sections are irrelevant to this program. OverviewHID_OVERVIEW # $ K + Overview Brief: WAdapt creates a number of imaginary animals (shown as dots) that move around the screen according to self-contained programs, eating and mating with each other. Their programs evolve by a genetic method according to which programs are most effective at either obtaining food or producing offspring. It's hoped that methods used here for implementing a "virtual machine" with its own programming language (the agent's program within this program) will be useful in determining how to "evolve" more complicated systems. Detail: The WADAPT screen shows a number of imaginary animals (shown as screen dots). Each cell has a number of attributes, such as its stored energy (obtained by eating other cells), and the angle along which it is looking and travelling. Cells are capable of performing a number of very basic activities, such as moving, as well as a number of basic computations relating to aspects of its environment, such as whether another cell is in its current line of sight. Each cell has its own self-contained program that determines which actions or computations it will perform, and in what order, each time it gets a turn to act. Initially, this self-contained program is generated randomly. That is, there is no pre-determined order to what it will do. When two cells meet, one can attack the other or they can mate. When an attack occurs, the stronger cell eats the weaker and absorbs all its energy. When they mate, a child is produced. The program of the new child cell consists entirely of program steps from its two parents, spliced together at random. So the child is completely derived from its parents, but its behavior may be much different from that of either parent. A cell whose program is ineffective at finding either food or a mate will grow weak and die or get eaten by another cell. Thus, the most effective programs are more likely to survive and propagate. It is this process, natural selection, that the program is designed not to imitate, but to demonstrate. That is, for the cells the WAdapt program is their environment, and their own survival within it is entirely determined by how well their internal programs function within it. ---------------------------------------------------------------------------- Requirements and Usage Tips: ----------------------------------------------------------------------------
# $ K + Files and File Formats Files Used with the Program Suggest using letters A-Z for project names. File Extensions:
All files are text files, and can be edited with any text editor. # $ K + File Menu Commands New There is no File | New command because the program requires that every open file have a name (i.e. not "Untitled"). To create a new file, Use File | Open and provide the name of a file that does not yet exist. The new colony will start out with all random agents with programs of length 1. To restart a run from from scratch using an existing file, empty the .AGS file manually. To specify the length of new agents (greater than the default 1), manually seed .AGS with 1 agent (using the proper format) with the desired number of program steps. Any opcode (e.g. 0) can be used. A starting program length of 1 (actually 2: 1 real one and a 0 as terminating delimiter) seems the most realistic because it is the simplest possible, and any complexity that develops must grow from there. However, a starting program length of > 1 can produce interesting and humorous effects. The program steps are randomly assigned and might contain any combination of turning and moving, so some of the starting agents will run around in circles, or squares, or jiggle back and forth. This makes for more interesting displays than when the program is running in "normal" mode. Open Allows you to specify one or more files to display. Opens a new display window for each file. You can also specify filenames on the command line when you start the program. For example: WADAPT.EXE A.AGS B.AGS... You can also open files using Drag and Drop from FileManager. Save Save the current set of agent programs to the file ADAPT.PGM in a section labeled "Interim," and continue with same set. Save as .BMP Saves the currently-displayed design (in the size it occupies in the currently displayed window) and its color palette to disk as a .BMP file. You can then import the file into a bitmap editor. To create a design with a specific size or proportions, size the display window as needed, wait for the design to be sufficiently filled in, and then Save as .BMP. Exit Closes all open files and exits the program. The name of the currently logged disk directory is saved to WSHOWFS.INI, so that it is your default starting directory the next time you run the program. # $ K + Colors Menu Commands Set Monochrome Color Displays a dialog box in which you can specify the color to use when drawing in monochrome mode. It also automatically switches to monochrome mode and turns AutoRandomizeColorsHID_VIEWMENUCOMMANDS OFF, so that the color you selected remains the drawing color until you change the color or change the point coloring mode or turn AutoRandomizeColors on again. Editing Colors with the Mouse You can redefine any color displayed on the screen. Position the cursor over an example of the color you want to change, and Right-Click. A dialog box will open in which you can specify a new color to use. It can be difficult to position the cursor over a dot of exactly the color you want to edit, so be sure to check the color initially displayed in the dialog box to make sure it is the right one. # $ K + View Menu Commands Options (all)... (Dialog Box) Allows you to set a number of parameters simultaneously. Trails When ON, each cell leaves a trail in a randomly assigned color. Use Sound (Beep) Toggles the use of sound in the application (not much used, anyway, however). When agents eat, mate, or die, the PC speaker beeps to let you know that one of those events occurred. Line of Sight Toggles whether to automatically display the line of sight (and thus direction of travel) of each agent. Slows processing down considerably. Passes between Screen Erase If 0, the screen is never erased automatically. If any other number, it is erased automatically each time that many complete passes have been made through the agent array. View Information about Selected Cells using the Mouse Use the Left Mouse Button to drag a rectangle around cells whose information you want to view. Information about the selected cells will be sent to COM1. # $ K + Designing Programs # $ K + For Further Reading Books:
|
These are the Windows resource definitions for WAdapt.
/*
wadapt.rc 01-19-02
This file is part of the WADAPT project.
Copyright (C)1999-2002 Steven Whitney.
Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
Initially published by http://25yearsofprogramming.com.
*/
#include "wadapt.rh"
MAINMENU MENU
{
POPUP "&File"
{
MENUITEM "&Open...", CM_FILEOPEN
MENUITEM "&Save...", CM_FILESAVE
MENUITEM "Save as .&BMP...", CM_FILESAVEAS
MENUITEM SEPARATOR
MENUITEM "E&xit", CM_FILEEXIT
}
POPUP "&Colors"
{
MENUITEM "&Randomize", CM_COLORSRANDOMIZE
}
POPUP "&View"
{
MENUITEM "&Options (all)...\tO", CM_VIEWOPTIONS
MENUITEM "&Report\tR", CM_VIEWSTATUS
MENUITEM SEPARATOR
MENUITEM "&Clear Screen\tC", CM_CLRSCR
MENUITEM "&Peek\tP", CM_PEEK
MENUITEM "&Fit (stretch) to Window\tW", CM_VIEWFITTOWINDOW
}
POPUP "&Window"
{
MENUITEM "&Cascade", CM_CASCADECHILDREN
MENUITEM "&Tile", CM_TILECHILDREN
MENUITEM "Arrange &Icons", CM_ARRANGEICONS
MENUITEM "C&lose All", CM_CLOSECHILDREN
}
POPUP "&Help"
{
MENUITEM "&Index\tF1", CM_HELPINDEX
MENUITEM SEPARATOR
MENUITEM "&About...", CM_HELPABOUT
}
}
STRINGTABLE
{
MAINMENU, "string"
CM_FILENEW, "Creates a new document"
CM_FILEOPEN, "Open an .AGS file to load cell data from"
CM_FILESAVE, "Save cell data to ADAPT.PGM, labeled as Interim."
CM_FILECLOSE, "Closes this document"
CM_EXIT, "Quits the application, prompts to save documents"
CM_VIEWOPTIONS, "Set viewing and calculation options"
CM_VIEWSTATUS, "Send status info to MSWord document or COM1"
CM_VIEWFITTOWINDOW, "Stretch agent display area to fill window"
CM_HELPINDEX, "Go to Help Contents page"
CM_HELPABOUT, "Information about this application"
CM_CLRSCR, "Erase trails, etc. and redraw just the agents"
CM_PEEK, "Peek once during invisible calculation"
CM_CASCADECHILDREN, "Cascades open windows"
CM_TILECHILDREN, "Tiles open windows"
CM_ARRANGEICONS, "Arranges iconic windows along bottom"
CM_CLOSECHILDREN, "Closes all open windows"
}
MAINMENU ACCELERATORS
{
"o", CM_VIEWOPTIONS
"O", CM_VIEWOPTIONS
VK_F1, CM_HELPINDEX, VIRTKEY
"p", CM_PEEK
"P", CM_PEEK
"r", CM_VIEWSTATUS
"R", CM_VIEWSTATUS
"w", CM_VIEWFITTOWINDOW
"W", CM_VIEWFITTOWINDOW
"c", CM_CLRSCR
"C", CM_CLRSCR, ASCII
}
OPTIONSDIALOG DIALOG 73, 44, 216, 184
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Program Options"
FONT 8, "MS Sans Serif"
{
AUTOCHECKBOX "&Trails Shown", IDC_TRAILS, 6, 9, 72, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
AUTOCHECKBOX "&Sound Enabled", IDC_BEEPON, 6, 21, 72, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
AUTOCHECKBOX "&Fit (stretch) to Window", IDC_FITTOWINDOW, 6, 33, 108, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
AUTOCHECKBOX "&Cell Display On", IDC_DISPLAYON, 101, 9, 72, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
AUTOCHECKBOX "&Line of Sight", IDC_LOOKON, 101, 21, 72, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
LTEXT "&Dib size (width height)", -1, 7, 52, 87, 12, WS_GROUP
EDITTEXT IDC_DIBSIZE, 91, 52, 45, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
LTEXT "Opcodes &run per turn", -1, 7, 66, 81, 12, WS_GROUP
EDITTEXT IDC_STEPMAX, 91, 66, 30, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
LTEXT "Ma&ximum Population", -1, 6, 87, 72, 12, WS_GROUP
EDITTEXT IDC_MAXPOP, 90, 87, 30, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
LTEXT "&Optimum Population", -1, 6, 101, 72, 12, WS_GROUP
EDITTEXT IDC_OPTPOP, 90, 101, 30, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
LTEXT "Mi&nimum Population", -1, 6, 115, 72, 12, WS_GROUP
EDITTEXT IDC_MINPOP, 90, 115, 30, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
LTEXT "&Passes Between Screen Erase", -1, 9, 136, 105, 12, WS_GROUP
EDITTEXT IDC_PASSLIMIT, 114, 136, 18, 12, WS_BORDER | WS_GROUP | WS_TABSTOP
DEFPUSHBUTTON "OK", IDOK, 28, 158, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
PUSHBUTTON "Cancel", IDCANCEL, 82, 158, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON "Help", IDHELP, 136, 158, 50, 14, WS_GROUP | WS_TABSTOP
LTEXT "Normal = 50", -1, 128, 68, 69, 11
LTEXT "Normal 160 100 8:5 ratio best", -1, 142, 46, 69, 21
LTEXT "Normal = 16000", -1, 127, 89, 69, 11
LTEXT "Normal = 1000", -1, 127, 103, 69, 11
LTEXT "Normal = 50", -1, 127, 117, 69, 11
LTEXT "Normal = 4", -1, 138, 138, 63, 11
}
TRANSFILEEDITOR DIALOG 193, 80, 186, 173
STYLE WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Transform File Editor"
FONT 10, "courier new"
{
EDITTEXT IDC_TRANSEDIT, 3, 20, 180, 150, ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK", IDOK, 3, 3, 30, 14
PUSHBUTTON "Cancel", IDCANCEL, 37, 3, 30, 14
PUSHBUTTON "Help", IDHELP, 71, 3, 30, 14
}
CM_FILEOPEN BITMAP "open.bmp"
CM_FILESAVE BITMAP "save.bmp"
CM_HELPINDEX BITMAP "help.bmp"
CM_TILECHILDREN BITMAP "tilevert.bmp"
Screenshots1) The OPTIONSDIALOG DIALOG defined above:
2) The WAdapt screen while it's running. This was an evolved population, so their trails are more purposeful than those in the screenshot of the MSDOS version of this program. You can adjust the size of the cells from a single pixel (which I normally use) to quite large. These are enlarged somewhat to increase their visibility. The cell with the circle around it is the strongest in the colony. You can obtain data about any cell(s) by using the mouse to drag a rectangle around it/them.
3) Status reports in Microsoft Word. At timed intervals, a report about the colony is produced, showing: pass number; current, lowest, and highest populations; birth count; timestamp; shortest and longest cell programs; how many cells have run their internal programs; errors; and the speed at which cell programs are running (5.9 cells/second). Then a report about the strongest agent and a "representative" agent with program steps each of which is the statistical mode of all agent programs for that pgm location. Then I dragged a selection box around cell #6792, and its data was sent to this screen: its ID#; (x,y) location in a DIB of size (x,y); its heading in degrees counterclockwise from East=0 degrees; its energy; how many it has eaten; how many children it has produced; its color in RGB; its AX value (last result code); whether it is currently looking at another cell as a potential mate or meal; and its internal program translated to English for readability. The * shows the current location of its IP (instruction pointer). The + shows the highest step in the program that has ever been executed. Based on its data, this cell is newly born and has never run its program, confirmed by its energy of 1e6, which is the starting default.
4) A worksheet in Adapt.xls where you can view two cell pgms, translated to English, side by side:
|
|
|
|
|
|
Copyright ©2012 Steven Whitney. Last modified Sun 07/29/2012 11:14:36 -0700. |
||