[avida-cvs] avida(Sherri) CVS commits: /current COPYING NEWS bootstrap configure.in /current/doc environment.html /current/source defs.hh /current/source/cpu cpu_memory.cc cpu_stack.hh hardware_4stack.cc hardware_4stack.hh hardware_base.hh hardware_cpu.cc hardware_cpu.hh hardware_util.cc hardware_util.hh head.cc head.hh test_cpu.cc test_cpu.hh /current/source/event cPopulation.events cPopulation_construct_event_auto.ci cPopulation_descr.ci cPopulation_enums_auto.ci cPopulation_event_list cPopulation_name2enum_auto.ci cPopulation_process_auto.ci /current/source/main Makefile.am analyze.cc avida.cc callback_util.cc callback_util.hh config.cc config.hh environment.cc environment.hh genome.hh inst_set.cc inst_set.hh inst_util.cc organism.cc organism.hh phenotype.cc phenotype.hh pop_interface.cc pop_interface.hh population.cc population.hh population_cell.cc population_cell.hh reaction.cc reaction.hh reaction_result.cc reaction_result.hh /current/source/qt-viewer Makefile.am event_chooser.cpp event_chooser.h event_list_editor.cpp event_list_editor.h godbox.cpp godbox.h map_view.cc map_view.hh map_view_widget.cc map_view_widget.hh plot_select_dia.cpp plot_select_dia.h population_cell_wrapper.hh qt-viewer.pro setup_avida.cc wizard.ui /current/source/qt-viewer/exp avd_widget_list.hh avd_widget_list_item.hh avd_widget_list_item_container.hh /current/source/support genesis /current/source/third-party/trio-1.9 example.c regression.c strio.h trio.c trio.h triodef.h trionan.c trionan.h triop.h triostr.c triostr.h /current/source/third-party/trio-1.9/doc doc.h doc_dynamic.h doc_printf.h doc_register.h doc_scanf.h doc_static.h /current/source/tools datafile.cc
goingssh
avida-cvs at alife.org
Tue Aug 19 18:49:34 PDT 2003
goingssh Tue Aug 19 10:49:34 2003 EDT
Modified files: (Branch: Sherri)
/avida/current COPYING NEWS bootstrap configure.in
/avida/current/doc environment.html
/avida/current/source defs.hh
/avida/current/source/cpu cpu_memory.cc cpu_stack.hh
hardware_4stack.cc hardware_4stack.hh
hardware_base.hh hardware_cpu.cc
hardware_cpu.hh hardware_util.cc
hardware_util.hh head.cc head.hh
test_cpu.cc test_cpu.hh
/avida/current/source/event cPopulation.events
cPopulation_construct_event_auto.ci
cPopulation_descr.ci
cPopulation_enums_auto.ci
cPopulation_event_list
cPopulation_name2enum_auto.ci
cPopulation_process_auto.ci
/avida/current/source/main Makefile.am analyze.cc avida.cc
callback_util.cc callback_util.hh
config.cc config.hh environment.cc
environment.hh genome.hh inst_set.cc
inst_set.hh inst_util.cc organism.cc
organism.hh phenotype.cc phenotype.hh
pop_interface.cc pop_interface.hh
population.cc population.hh
population_cell.cc population_cell.hh
reaction.cc reaction.hh
reaction_result.cc reaction_result.hh
/avida/current/source/qt-viewer Makefile.am event_chooser.cpp
event_chooser.h
event_list_editor.cpp
event_list_editor.h godbox.cpp
godbox.h map_view.cc map_view.hh
map_view_widget.cc
map_view_widget.hh
plot_select_dia.cpp
plot_select_dia.h
population_cell_wrapper.hh
qt-viewer.pro setup_avida.cc
wizard.ui
/avida/current/source/qt-viewer/exp avd_widget_list.hh
avd_widget_list_item.hh
avd_widget_list_item_container.hh
/avida/current/source/support genesis
/avida/current/source/third-party/trio-1.9 example.c regression.c
strio.h trio.c trio.h
triodef.h trionan.c
trionan.h triop.h
triostr.c triostr.h
/avida/current/source/third-party/trio-1.9/doc doc.h doc_dynamic.h
doc_printf.h
doc_register.h
doc_scanf.h
doc_static.h
/avida/current/source/tools datafile.cc
Log:
updating my branch to be current with head branch
-------------- next part --------------
Index: avida/current/COPYING
diff -u avida/current/COPYING:1.6 avida/current/COPYING:1.6.4.1
--- avida/current/COPYING:1.6 Wed May 1 13:43:32 2002
+++ avida/current/COPYING Tue Aug 19 10:49:28 2003
@@ -26,3 +26,66 @@
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.
+
+---------------------------------------------------------------------
+
+Avida uses version 1.9 of the very nice third-party package 'Trio'.
+
+Trio is a package with portable string functions, including printf()
+clones and others, and is released under the following MIT-like license:
+
+****
+
+README -- trio
+
+Trio is a package with portable string functions. Including printf() clones
+and others.
+
+ Copyright (C) 1998-2001 by Bjorn Reese and Daniel Stenberg.
+
+ Permission to use, copy, modify, and distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
+ CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
+
+Trio is intended to be an integral part of another application, so we
+have not done anything to create a proper installation.
+
+Compile with 'make' (edit the Makefile if you want a release build)
+
+Test the package with 'make test'
+
+Install by copying trio.h, triop.h, and libtrio.a (and man/man?/* if
+you want documentation) to the appropriate directories.
+
+Catch some usage examples in example.c
+
+Send feedback and patches to the mailing list, subscription and other
+information is found here:
+
+ http://lists.sourceforge.net/lists/listinfo/ctrio-talk
+
+Enjoy!
+
+Trio web page
+
+ http://daniel.haxx.se/trio/
+
+---------------------------------------------------------------------
+
+Avida for Windows uses version 2.6 of PDCurses, a wonderful third-party
+port of System VR4 curses for multiple platforms which has been released
+to the Public Domain, although small portions of the package are subject
+to various copyright conditions. Visit the PDCurses webpage for more
+details:
+
+ http://pdcurses.sourceforge.net/
+
+The PDCurses package (and its predecessors) have had various
+maintainers over the years. The maintainer of version 2.6 is
+Mark Hessling - M.Hessling at qut.edu.au
+
Index: avida/current/NEWS
diff -u avida/current/NEWS:1.23 avida/current/NEWS:1.23.2.1
--- avida/current/NEWS:1.23 Sat May 17 03:13:36 2003
+++ avida/current/NEWS Tue Aug 19 10:49:28 2003
@@ -4,16 +4,144 @@
[B] = Bug fix; something that used to work wrong will now be correct.
[M] = Major change; avida will function differently in certain circumstances.
+For version 2.0 beta 3:
+
+June, 03
+[F] Avida now runs and builds on Windows. Many minor changes were made for this,
+ .pro files were added to be used with qmake, the way the configure script searches
+ for the ncurses library was modified, pdcurses was incorporated instead of ncurses,
+ trio was added to fix some string problems, and some very minor code changes were
+ implemented to allow for some differences in the visual studio compiler.
+
+[F] new 4 stack hardware is implemented but not yet fully functional. It's compatible
+ with primitive and ncurses modes, however will cause qt-viewer to crash if used.
+ No functionality associated with the original hardware has been changed.
+
+[B] set up constant time slicer to skip over empty cells, this had been throwing an assert
+ error in debug mode.
+
+[B] removed Visual Studio.net support files as they are out of date and no longer work properly.
+
+May, 03
+[F] introduced new 4 Stack CPU model. Removed 3 registers in CPU and replaced with
+ 4 stacks. Added 4th NOP which allows use of all 4 stacks. Also changed complement system
+ for nops. Pairs are now as follows: A,C; B,D; C,A; D,B;
+
+[B] newer C++ compilers want scoping on templates defined inside class definition, event
+ if they are only used inside the class.
+
+[B] fixed problem with incorrect copying of instruction libraries when one instruction set was
+ initialized to another one.
+
+[F] set up Avida to pring out a genesis file if none exists.
+
+[I] working on setting up Avida to generate an instruction set file in none exists. Attached
+ 60 character or less descriptions to each of the default instructions, and attached a flag to all
+ instructions declaring they are default.
+
+[I] added default event files in C++ that are generated from perl so Avida can be compiled in Windows
+ without running perl script by hand as long as no new events are created or modified.
+
+[B] updated .pro files so don't have to change any properties in Visual Studio to compile
+
+[B] The hardware factory has always been creating CPU's of type cHardwareCPU even if everything else
+ was assuming cHardware4Stack. This all works properly now.
+
+[I] added pdcurses.h and curses.lib to Avida so one doesn't have to actually check out the whole
+ pdcurses suite to run on Windows.
+
+[I] added third party suite "Public Domain Curses" for Win32 compatability.
+
+[F] added event print_genotype_map that prints a Matlab file of the genotype IDs to a default file
+ "genotype_map.m"
+
+[B] added empty directory aclocal to CVS so don't have to create it by hand every time build Avida
+ from scratch
+
+[I] update .pri files for Windows builds
+
+[F] added Visual Studio.net support files for ncurses viewer, primitive mode, and qt-viewer.
+
+[I] cHardware4Stack now hooked into Avida and working properly
+
+[I] added new hardware type cHardware4Stack. Not hooked into rest of Avida yet...
+
+[I] re-engineered cFile class to work based off of arrays instead of linked lists. Each line is
+ now stored as part of a structure which has other info associated with it, such as line numbers
+ for better error reporting. Not being used yet, but available...
+
+[I] added HARDWARE_TYPE to genesis file and setup config to load it into Avida, it's not being used yet.
+
+[I] modified test_cup.cc to improve the default inputs in the test CPUs so they are more similar
+ to those in the environment, and ideally give more accurate answers.
+ Serup the default instruction set to be hooked in with a proper instruction library so that
+ they can be used outside of a population (i.e. in analyze mode)
+
+[B] fixed bug in testCPU
+
+[I] changed cInstLib to cInstSet and cInstSuperLib to cInstLib. Renamed inst_lib.{cc,hh} to
+ inst_set.{cc,hh} and inst_superlib.hh to inst_lib.hh. Updated other files accordingly to
+ reflect this change
+
+[I] included instruction which injects a parasite into it's own thread. Also changed count.dat
+ so that info regarding parasites is appended to the end of the file. Removed previous parasite
+ info which is now obsolete.
+
For version 2.0 beta 1:
-[F] Improved cross-platform compatibility; can now build on Linux,
- Mac OS X, and Windows XP (although this last is pretty rough).
- Qt qmake can now be used to generate both Windows Visual Studio.net
- project files and Mac OS X Project Builder project files.
-
-[I] Hardware_cpu now has a static instruction superlibrary containing
- all available functions and instruction names. Instruction
- libraries now index into the superlibrary tables. Windows
- compatibility required the change away from the old code.
+[B] edited Makefile.am to reflect the fact that built event source file depends are build-tree relative
+ but cpu source file depends are source-tree relative
+
+[I] removed unused sourcecode from beneath qt subdirectory
+
+[I] introduced cInstSuperLib to contain a complete library of available instructions corresponding to
+ a given hardware class. cInstLib now indexes into arrays provided by cInstSuperLib
+
+[B] mkdir() is not defined in win32 so added win32_mkdir_hack.hh to define it as a macro so can
+ use in windows version
+
+[B] modified namespaces, adding 'using namespace std' appropriately throughout Avida to allow
+ compilation on Windows
+
+[I] set up qt builds to be performed using qmake on seperately maintained .pro files
+
+[B] fixed error in new tasks, now cast int to double before taking log
+
+[I] added code to allow spatial resources
+
+[I] allow long lines in an input file to be split across multiple physical lines by use of
+ a \ character at the end of the line as a continuation marker
+
+[F] added two routines to aid the printing of spatial resource data:
+ writeblock - allows for the output of individual grid points
+ writeraw - allows any line to be written anywhere in an output file
+
+April, 03
+[F] added event kill_rectangle which allows user to kill all organisms in a rectangle
+ described by points (X1, Y1) and (X2, Y2).
+
+[B] no longer crashes when population dies out.
+
+[I] added version of Max function with type double. added function Neighbor
+ that works with population and spatial resource arrays to find the current neighboring
+ cells (even at edge of matrix).
+
+[B] fixed time slicer problem where drastic drop in maximum merit would slow down a run
+ considerably. Added warning when analyze mode tries to load in a string sequence
+ thats supposed to represent a genome, but maximum char goes beyond instruction set size.
+
+[I] previous runs can no longer be replicated even when a random seed used is known
+ due to extensive reorganization of portions of code that handle divides.
+
+[F] initial implementation of sex. Now exists divide-sex and divide-asex commands,
+ former facilitating recombination between two offspring by swapping a region of
+ their code.
+
+[B] fixed hardware getting incorrect info as to if it lived through birth process.
+
+[B] removed mutation rate drifting options and old style crossovers.
+
+[I] assembled framework for sexual divides. Mostly involved pushing some of the
+ final offspring creation to the population and out of the organism.
For version 2.0 beta 0:
[I][O][F][B][M]
Index: avida/current/bootstrap
diff -u avida/current/bootstrap:1.8.2.1 avida/current/bootstrap:1.8.2.2
--- avida/current/bootstrap:1.8.2.1 Wed Jun 4 09:36:26 2003
+++ avida/current/bootstrap Tue Aug 19 10:49:28 2003
@@ -12,7 +12,7 @@
# helps bootstrapping, when checked out from CVS
# requires GNU autoconf and GNU automake
#
-# $Id: bootstrap,v 1.8.2.1 2003/06/04 16:36:26 goingssh Exp $
+# $Id: bootstrap,v 1.8.2.2 2003/08/19 17:49:28 goingssh Exp $
# this is not meant to be exported outside the source tree
Index: avida/current/configure.in
diff -u avida/current/configure.in:1.27 avida/current/configure.in:1.27.2.1
--- avida/current/configure.in:1.27 Tue May 20 05:07:54 2003
+++ avida/current/configure.in Tue Aug 19 10:49:28 2003
@@ -8,7 +8,7 @@
dnl ****************************************
dnl Package name and version
dnl ****************************************
-AM_INIT_AUTOMAKE(avida, 2.0b1)
+AM_INIT_AUTOMAKE(avida, 2.0b4)
dnl ****************************************
@@ -51,7 +51,7 @@
dnl debugging/profiling
AC_ARG_ENABLE(debug,
[ --enable-debug: Compile with debugging symbols],
- [CPPFLAGS="-g -DDEBUG"; qmake_debug="debug"],
+ [CPPFLAGS="-g -Wall -pedantic -DDEBUG"; qmake_debug="debug"],
[CPPFLAGS="-O3 -ffast-math"; qmake_debug="release"])
AC_ARG_ENABLE(gnu-debug,
Index: avida/current/doc/environment.html
diff -u avida/current/doc/environment.html:1.2.2.2 avida/current/doc/environment.html:1.2.2.3
--- avida/current/doc/environment.html:1.2.2.2 Wed Jun 4 09:36:29 2003
+++ avida/current/doc/environment.html Tue Aug 19 10:49:28 2003
@@ -279,6 +279,9 @@
<tr><td><font color="#0000AA">conversion</font>
<td>The conversion rate to by-product resource
<td>1.0
+<tr><td><font color="#0000AA">lethal</font>
+ <td>Whether the cell dies after performing the process
+ <td>0
</table>
<p>
Index: avida/current/source/defs.hh
diff -u avida/current/source/defs.hh:1.27.2.1 avida/current/source/defs.hh:1.27.2.2
--- avida/current/source/defs.hh:1.27.2.1 Fri May 23 12:05:36 2003
+++ avida/current/source/defs.hh Tue Aug 19 10:49:28 2003
@@ -18,14 +18,6 @@
#define HTMLDIR "../work/doc_html/"
#endif
-/*
-When defined, instruction sets, instruction libraries, hardware use new
-instruction set code. The old code remains, and will be used if the
-following is not defined.
-*/
-/* XXX remove after regression tests */
-#define USE_INST_SET_CODE
-/**/
// -= Various view modes =-
#define VIEW_NEWVIEWER
@@ -83,7 +75,7 @@
// the macro VERSION is defined by automake (in the file 'configure.in' in
// the top-level directory).
#ifndef VERSION
- #define VERSION "2.0b"
+ #define VERSION "2.0b4"
#endif
#define AVIDA_VERSION VERSION
Index: avida/current/source/cpu/cpu_memory.cc
diff -u avida/current/source/cpu/cpu_memory.cc:1.9 avida/current/source/cpu/cpu_memory.cc:1.9.2.1
--- avida/current/source/cpu/cpu_memory.cc:1.9 Sat May 17 02:48:07 2003
+++ avida/current/source/cpu/cpu_memory.cc Tue Aug 19 10:49:29 2003
@@ -239,4 +239,3 @@
genome[i + pos] = in_genome[i];
}
}
-
Index: avida/current/source/cpu/cpu_stack.hh
diff -u avida/current/source/cpu/cpu_stack.hh:1.3.2.1 avida/current/source/cpu/cpu_stack.hh:1.3.2.2
--- avida/current/source/cpu/cpu_stack.hh:1.3.2.1 Thu May 29 11:20:59 2003
+++ avida/current/source/cpu/cpu_stack.hh Tue Aug 19 10:49:29 2003
@@ -35,7 +35,7 @@
inline int Pop();
inline int Get(int depth=0) const;
inline void Clear();
- inline int& Top();
+ inline int Top();
void Flip();
bool OK();
@@ -74,7 +74,7 @@
stack_pointer = 0;
}
-inline int& cCPUStack::Top()
+inline int cCPUStack::Top()
{
return stack[stack_pointer];
}
Index: avida/current/source/cpu/hardware_4stack.cc
diff -u avida/current/source/cpu/hardware_4stack.cc:1.2.4.4 avida/current/source/cpu/hardware_4stack.cc:1.2.4.5
--- avida/current/source/cpu/hardware_4stack.cc:1.2.4.4 Wed Jun 4 09:36:29 2003
+++ avida/current/source/cpu/hardware_4stack.cc Tue Aug 19 10:49:29 2003
@@ -1,4 +1,3 @@
-
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2003 California Institute of Technology //
// //
@@ -6,12 +5,14 @@
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
+
#include <iomanip>
#include "hardware_method.hh"
#include "hardware_4stack.hh"
#include "../tools/string_util.hh"
+#include "../tools/random.hh"
#include "../main/config.hh"
#include "../main/inst_set.hh"
@@ -43,13 +44,12 @@
{
id = _id;
if (id == -1) id = in_thread.id;
- for (int i = 0; i < NUM_REG_4STACK; i++) {
- reg[i] = in_thread.reg[i];
+ for (int i = 0; i < NUM_LOCAL_STACKS; i++) {
+ local_stacks[i] = in_thread.local_stacks[i];
}
for (int i = 0; i < NUM_HEADS; i++) {
heads[i] = in_thread.heads[i];
}
- stack = in_thread.stack;
input_pointer = in_thread.input_pointer;
}
@@ -58,13 +58,12 @@
void cHardware4Stack_Thread::operator=(const cHardware4Stack_Thread & in_thread)
{
id = in_thread.id;
- for (int i = 0; i < NUM_REG_4STACK; i++) {
- reg[i] = in_thread.reg[i];
+ for (int i = 0; i < NUM_LOCAL_STACKS; i++) {
+ local_stacks[i] = in_thread.local_stacks[i];
}
for (int i = 0; i < NUM_HEADS; i++) {
heads[i] = in_thread.heads[i];
}
- stack = in_thread.stack;
input_pointer = in_thread.input_pointer;
input_buf = in_thread.input_buf;
output_buf = in_thread.output_buf;
@@ -74,11 +73,9 @@
{
id = _id;
- for (int i = 0; i < NUM_REG_4STACK; i++) reg[i] = 0;
- for (int i = 0; i < NUM_HEADS; i++) heads[i].Reset(in_hardware);
+ for (int i = 0; i < NUM_LOCAL_STACKS; i++) local_stacks[i].Clear();
+ for (int i = 0; i < NUM_HEADS; i++) heads[i].Reset(0, in_hardware);
- stack.Clear();
- cur_stack = 0;
cur_head = HEAD_IP;
input_pointer = 0;
input_buf.Clear();
@@ -94,9 +91,9 @@
assert(fp.good());
fp << "cHardware4Stack_Thread" << endl;
- // registers
- for( int i=0; i<NUM_REG_4STACK; ++i ){
- fp<<reg[i]<<endl;
+ // stacks (NOT WORKING! -law)
+ for( int i=0; i<NUM_STACKS; ++i ){
+ local_stacks[i].SaveState(fp);
}
// heads (@TCC does not handle parasites!!!)
@@ -104,10 +101,7 @@
fp<<heads[i].GetPosition()<<endl;
}
- stack.SaveState(fp);
-
fp<<"|"; // marker
- fp<<cur_stack;
fp<<cur_head;
fp<<input_pointer;
fp<<endl;
@@ -129,9 +123,9 @@
fp >> foo;
assert( foo == "cHardware4Stack_Thread");
- // registers
- for( int i=0; i<NUM_REG_4STACK; ++i ){
- fp>>reg[i];
+ // stacks (NOT WORKING! -law)
+ for( int i=0; i<NUM_STACKS; ++i ){
+ local_stacks[i].LoadState(fp);
}
// heads (@TCC does not handle parasites!!!)
@@ -141,23 +135,12 @@
heads[i].AbsSet(pos);
}
- // stack
- stack.LoadState(fp);
-
char marker; fp>>marker; assert( marker == '|' );
- /* YIKES! data loss below: */
-#ifdef USE_INST_SET_CODE
- char the_cur_stack = cur_stack;
+ /* YIKES! data loss below: */
char the_cur_head = cur_head;
char the_input_pointer = input_pointer;
- fp.get(the_cur_stack);
fp.get(the_cur_head);
fp.get(the_input_pointer);
-#else /* USE_INST_SET_CODE */
- fp.get((char)cur_stack);
- fp.get((char)cur_head);
- fp.get((char)input_pointer);
-#endif /* USE_INST_SET_CODE */
// IO buffers
input_buf.LoadState(fp);
@@ -169,7 +152,6 @@
}
-#ifdef USE_INST_SET_CODE
///////////////
// cInstLib4Stack
///////////////
@@ -225,13 +207,11 @@
const cInstruction & GetInstDefault(){ return inst_default; }
const cInstruction & GetInstError(){ return inst_error; }
};
-#endif /* USE_INST_SET_CODE */
///////////////
// cHardware4Stack
///////////////
-#ifdef USE_INST_SET_CODE
const cInstruction cInstLib4Stack::inst_error(255);
const cInstruction cInstLib4Stack::inst_default(0);
cInstLibBase *cHardware4Stack::GetInstLib(){ return s_inst_slib; }
@@ -244,10 +224,10 @@
int nop_mod;
};
static const cNOPEntry4Stack s_n_array[] = {
- cNOPEntry4Stack("Nop-A", REG_AX),
- cNOPEntry4Stack("Nop-B", REG_BX),
- cNOPEntry4Stack("Nop-C", REG_CX),
- cNOPEntry4Stack("Nop-D", REG_DX),
+ cNOPEntry4Stack("Nop-A", STACK_AX),
+ cNOPEntry4Stack("Nop-B", STACK_BX),
+ cNOPEntry4Stack("Nop-C", STACK_CX),
+ cNOPEntry4Stack("Nop-D", STACK_DX),
};
struct cInstEntry4Stack {
@@ -262,7 +242,7 @@
cInstEntry4Stack("Nop-B", &cHardware4Stack::Inst_Nop),
//3
cInstEntry4Stack("Nop-C", &cHardware4Stack::Inst_Nop),
- //4 - not implemented yet...
+ //4
cInstEntry4Stack("Nop-D", &cHardware4Stack::Inst_Nop),
//5
cInstEntry4Stack("Nop-X", &cHardware4Stack::Inst_Nop),
@@ -271,155 +251,67 @@
//7
cInstEntry4Stack("Val-Shift-L", &cHardware4Stack::Inst_ShiftL),
//8
- cInstEntry4Stack("Val-Nand", &cHardware4Stack::Inst_Nand),
+ cInstEntry4Stack("Val-Nand", &cHardware4Stack::Inst_Val_Nand),
//9
- cInstEntry4Stack("Val-Add", &cHardware4Stack::Inst_Add),
+ cInstEntry4Stack("Val-Add", &cHardware4Stack::Inst_Val_Add),
//10
- cInstEntry4Stack("Val-Sub", &cHardware4Stack::Inst_Sub),
+ cInstEntry4Stack("Val-Sub", &cHardware4Stack::Inst_Val_Sub),
//11
- cInstEntry4Stack("Val-Mult", &cHardware4Stack::Inst_Mult),
+ cInstEntry4Stack("Val-Mult", &cHardware4Stack::Inst_Val_Mult),
//12
- cInstEntry4Stack("Val-Div", &cHardware4Stack::Inst_Div),
+ cInstEntry4Stack("Val-Div", &cHardware4Stack::Inst_Val_Div),
//13
- cInstEntry4Stack("SetMemory", &cHardware4Stack::Inst_MaxAlloc),
+ cInstEntry4Stack("SetMemory", &cHardware4Stack::Inst_SetMemory),
//14
- cInstEntry4Stack("Divide", &cHardware4Stack::Inst_HeadDivide),
+ cInstEntry4Stack("Divide", &cHardware4Stack::Inst_Divide),
//15
cInstEntry4Stack("Inst-Read", &cHardware4Stack::Inst_HeadRead),
//16
cInstEntry4Stack("Inst-Write", &cHardware4Stack::Inst_HeadWrite),
//keeping this one for the transition period
- cInstEntry4Stack("Inst-Copy", &cHardware4Stack::Inst_HeadCopy),
+ //cInstEntry4Stack("Inst-Copy", &cHardware4Stack::Inst_HeadCopy),
//17
- cInstEntry4Stack("If-Equal", &cHardware4Stack::Inst_IfEqu),
+ cInstEntry4Stack("If-Equal", &cHardware4Stack::Inst_IfEqual),
//18
- cInstEntry4Stack("If-Not-Equal", &cHardware4Stack::Inst_IfNEqu),
+ cInstEntry4Stack("If-Not-Equal", &cHardware4Stack::Inst_IfNotEqual),
//19
cInstEntry4Stack("If-Less", &cHardware4Stack::Inst_IfLess),
//20
- cInstEntry4Stack("If-Greater", &cHardware4Stack::Inst_IfGr),
+ cInstEntry4Stack("If-Greater", &cHardware4Stack::Inst_IfGreater),
//21
cInstEntry4Stack("Head-Push", &cHardware4Stack::Inst_HeadPush),
//22
cInstEntry4Stack("Head-Pop", &cHardware4Stack::Inst_HeadPop),
//23
- cInstEntry4Stack("Head-Move", &cHardware4Stack::Inst_MoveHead),
+ cInstEntry4Stack("Head-Move", &cHardware4Stack::Inst_HeadMove),
//24
- cInstEntry4Stack("Search", &cHardware4Stack::Inst_HeadSearch),
+ cInstEntry4Stack("Search", &cHardware4Stack::Inst_Search),
//25
- cInstEntry4Stack("Push-Next", &cHardware4Stack::Inst_PushA),
+ cInstEntry4Stack("Push-Next", &cHardware4Stack::Inst_PushNext),
//26
- cInstEntry4Stack("Push-Prev", &cHardware4Stack::Inst_PushB),
+ cInstEntry4Stack("Push-Prev", &cHardware4Stack::Inst_PushPrevious),
//27
- cInstEntry4Stack("Push-Comp", &cHardware4Stack::Inst_PushC),
- //28 - Not implemented yet...
- //cInstEntry4Stack("Val-Delete", &cHardware4Stack::Inst_ValDelete
+ cInstEntry4Stack("Push-Comp", &cHardware4Stack::Inst_PushComplement),
+ //28
+ cInstEntry4Stack("Val-Delete", &cHardware4Stack::Inst_ValDelete),
//29
- cInstEntry4Stack("Val-Copy", &cHardware4Stack::Inst_CopyStack),
+ cInstEntry4Stack("Val-Copy", &cHardware4Stack::Inst_ValCopy),
//30
cInstEntry4Stack("ThreadFork", &cHardware4Stack::Inst_ForkThread),
//31
- cInstEntry4Stack("if-label", &cHardware4Stack::Inst_IfLabel),
+ //cInstEntry4Stack("if-label", &cHardware4Stack::Inst_IfLabel),
//32
- cInstEntry4Stack("Val-Inc", &cHardware4Stack::Inst_Inc),
+ cInstEntry4Stack("Val-Inc", &cHardware4Stack::Inst_Increment),
//33
- cInstEntry4Stack("Val-Dec", &cHardware4Stack::Inst_Dec),
+ cInstEntry4Stack("Val-Dec", &cHardware4Stack::Inst_Decrement),
//34
cInstEntry4Stack("Val-Mod", &cHardware4Stack::Inst_Mod),
//35
cInstEntry4Stack("ThreadKill", &cHardware4Stack::Inst_KillThread),
-
- /*
- cInstEntry4Stack("nop-A", &cHardware4Stack::Inst_Nop),
- cInstEntry4Stack("nop-B", &cHardware4Stack::Inst_Nop),
- cInstEntry4Stack("nop-C", &cHardware4Stack::Inst_Nop),
-
- cInstEntry4Stack("NULL", &cHardware4Stack::Inst_Nop),
- cInstEntry4Stack("nop-X", &cHardware4Stack::Inst_Nop),
- cInstEntry4Stack("if-equ-0", &cHardware4Stack::Inst_If0),
- cInstEntry4Stack("if-not-0", &cHardware4Stack::Inst_IfNot0),
- cInstEntry4Stack("if-n-equ", &cHardware4Stack::Inst_IfNEqu),
- cInstEntry4Stack("if-equ", &cHardware4Stack::Inst_IfEqu),
-
- cInstEntry4Stack("if-bit-1", &cHardware4Stack::Inst_IfBit1),
- cInstEntry4Stack("jump-f", &cHardware4Stack::Inst_JumpF),
- cInstEntry4Stack("jump-b", &cHardware4Stack::Inst_JumpB),
- cInstEntry4Stack("jump-p", &cHardware4Stack::Inst_JumpP),
- cInstEntry4Stack("jump-slf", &cHardware4Stack::Inst_JumpSelf),
- cInstEntry4Stack("call", &cHardware4Stack::Inst_Call),
- cInstEntry4Stack("return", &cHardware4Stack::Inst_Return),
-
- cInstEntry4Stack("pop", &cHardware4Stack::Inst_Pop),
- cInstEntry4Stack("push", &cHardware4Stack::Inst_Push),
- cInstEntry4Stack("swap-stk", &cHardware4Stack::Inst_SwitchStack),
- cInstEntry4Stack("swap", &cHardware4Stack::Inst_Swap),
- cInstEntry4Stack("copy-reg", &cHardware4Stack::Inst_CopyReg),
-
- cInstEntry4Stack("shift-r", &cHardware4Stack::Inst_ShiftR),
- cInstEntry4Stack("shift-l", &cHardware4Stack::Inst_ShiftL),
- cInstEntry4Stack("bit-1", &cHardware4Stack::Inst_Bit1),
- cInstEntry4Stack("set-num", &cHardware4Stack::Inst_SetNum),
- cInstEntry4Stack("inc", &cHardware4Stack::Inst_Inc),
- cInstEntry4Stack("dec", &cHardware4Stack::Inst_Dec),
- cInstEntry4Stack("minus-18", &cHardware4Stack::Inst_Minus18),
-
- cInstEntry4Stack("add", &cHardware4Stack::Inst_Add),
- cInstEntry4Stack("sub", &cHardware4Stack::Inst_Sub),
- cInstEntry4Stack("mult", &cHardware4Stack::Inst_Mult),
- cInstEntry4Stack("div", &cHardware4Stack::Inst_Div),
- cInstEntry4Stack("mod", &cHardware4Stack::Inst_Mod),
- cInstEntry4Stack("nand", &cHardware4Stack::Inst_Nand),
- cInstEntry4Stack("nor", &cHardware4Stack::Inst_Nor),
-
- cInstEntry4Stack("copy", &cHardware4Stack::Inst_Copy),
- cInstEntry4Stack("read", &cHardware4Stack::Inst_ReadInst),
- cInstEntry4Stack("write", &cHardware4Stack::Inst_WriteInst),
-
- cInstEntry4Stack("compare", &cHardware4Stack::Inst_Compare),
- cInstEntry4Stack("if-n-cpy", &cHardware4Stack::Inst_IfNCpy),
- cInstEntry4Stack("allocate", &cHardware4Stack::Inst_Allocate),
- cInstEntry4Stack("divide", &cHardware4Stack::Inst_Divide),
- cInstEntry4Stack("inject", &cHardware4Stack::Inst_Inject),
- cInstEntry4Stack("inject-r", &cHardware4Stack::Inst_InjectRand),
- cInstEntry4Stack("get", &cHardware4Stack::Inst_TaskGet),
- cInstEntry4Stack("put", &cHardware4Stack::Inst_TaskPut),
- cInstEntry4Stack("IO", &cHardware4Stack::Inst_TaskIO),
- cInstEntry4Stack("search-f", &cHardware4Stack::Inst_SearchF),
- cInstEntry4Stack("search-b", &cHardware4Stack::Inst_SearchB),
- cInstEntry4Stack("mem-size", &cHardware4Stack::Inst_MemSize),
-
- cInstEntry4Stack("rotate-l", &cHardware4Stack::Inst_RotateL),
- cInstEntry4Stack("rotate-r", &cHardware4Stack::Inst_RotateR),
-
- cInstEntry4Stack("set-cmut", &cHardware4Stack::Inst_SetCopyMut),
- cInstEntry4Stack("mod-cmut", &cHardware4Stack::Inst_ModCopyMut),
-
- // Threading instructions
- cInstEntry4Stack("fork-th", &cHardware4Stack::Inst_ForkThread),
- cInstEntry4Stack("kill-th", &cHardware4Stack::Inst_KillThread),
- cInstEntry4Stack("id-th", &cHardware4Stack::Inst_ThreadID),
-
- // Head-based instructions
- cInstEntry4Stack("h-alloc", &cHardware4Stack::Inst_MaxAlloc),
- cInstEntry4Stack("h-divide", &cHardware4Stack::Inst_HeadDivide),
- cInstEntry4Stack("h-read", &cHardware4Stack::Inst_HeadRead),
- cInstEntry4Stack("h-write", &cHardware4Stack::Inst_HeadWrite),
- cInstEntry4Stack("h-copy", &cHardware4Stack::Inst_HeadCopy),
- cInstEntry4Stack("h-search", &cHardware4Stack::Inst_HeadSearch),
- cInstEntry4Stack("h-push", &cHardware4Stack::Inst_HeadPush),
- cInstEntry4Stack("h-pop", &cHardware4Stack::Inst_HeadPop),
- cInstEntry4Stack("set-head", &cHardware4Stack::Inst_SetHead),
- cInstEntry4Stack("adv-head", &cHardware4Stack::Inst_AdvanceHead),
- cInstEntry4Stack("mov-head", &cHardware4Stack::Inst_MoveHead),
- cInstEntry4Stack("jmp-head", &cHardware4Stack::Inst_JumpHead),
- cInstEntry4Stack("get-head", &cHardware4Stack::Inst_GetHead),
- cInstEntry4Stack("if-label", &cHardware4Stack::Inst_IfLabel),
- cInstEntry4Stack("set-flow", &cHardware4Stack::Inst_SetFlow),
-
-
- // Placebo instructions
- // nop-x (included with nops)
- cInstEntry4Stack("skip", &cHardware4Stack::Inst_Skip)*/
+ //36
+ cInstEntry4Stack("IO", &cHardware4Stack::Inst_IO),
+ //37
+ cInstEntry4Stack("Inject", &cHardware4Stack::Inst_Inject)
};
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntry4Stack);
@@ -460,17 +352,24 @@
return inst_lib;
}
-#endif /* USE_INST_SET_CODE */
cHardware4Stack::cHardware4Stack(cOrganism * in_organism, cInstSet * in_inst_set)
: cHardwareBase(in_organism, in_inst_set)
+ , memory_array(NUM_MEMORY_SPACES)
{
-#ifdef USE_INST_SET_CODE
/* FIXME: reorganize storage of m_functions. -- kgn */
m_functions = s_inst_slib->GetFunctions();
/**/
-#endif /* USE_INST_SET_CODE */
- memory = in_organism->GetGenome(); // Initialize memory...
+ inst_remainder = 0;
+
+ for(int x=1; x<=cConfig::GetMaxCPUThreads(); x++)
+ {
+ slice_array[x] = (x-1)*cConfig::GetThreadSlicingMethod()+1;
+ }
+
+ memory_array[0] = in_organism->GetGenome(); // Initialize memory...
+ memory_array[0].Resize(GetMemory(0).GetSize()+1);
+ memory_array[0][memory_array[0].GetSize()-1] = cInstruction();
Reset(); // Setup the rest of the hardware...
}
@@ -483,15 +382,24 @@
void cHardware4Stack::Recycle(cOrganism * new_organism, cInstSet * in_inst_set)
{
cHardwareBase::Recycle(new_organism, in_inst_set);
- memory = new_organism->GetGenome();
+ memory_array[0] = new_organism->GetGenome();
+ memory_array[0].Resize(GetMemory(0).GetSize()+1);
+ memory_array[0][memory_array[0].GetSize()-1] = cInstruction();
Reset();
}
void cHardware4Stack::Reset()
{
- global_stack.Clear();
- thread_time_used = 0;
+ //global_stack.Clear();
+ //thread_time_used = 0;
+
+ // Setup the memory...
+ for (int i = 1; i < NUM_MEMORY_SPACES; i++) {
+ memory_array[i].Resize(1);
+ //GetMemory(i).Replace(0, 1, cGenome(ConvertToInstruction(i)));
+ GetMemory(i)=cGenome(ConvertToInstruction(i));
+ }
// We want to reset to have a single thread.
threads.Resize(1);
@@ -503,6 +411,12 @@
mal_active = false;
+ // Reset all stacks (local and global)
+ for(int i=0; i<NUM_STACKS; i++)
+ {
+ Stack(i).Clear();
+ }
+
#ifdef INSTRUCTION_COSTS
// instruction cost arrays
const int num_inst_cost = GetNumInst();
@@ -517,24 +431,33 @@
}
-
// This function processes the very next command in the genome, and is made
// to be as optimized as possible. This is the heart of avida.
void cHardware4Stack::SingleProcess(ostream * trace_fp)
{
organism->GetPhenotype().IncTimeUsed();
- if (GetNumThreads() > 1) thread_time_used++;
+ //if(organism->GetCellID()==46 && IP().GetMemSpace()==2)
+ // int x=0;
+ //if (GetNumThreads() > 1) thread_time_used++;
+ //assert((GetHead(HEAD_WRITE).GetPosition() == Stack(STACK_BX).Top() ||
+ // Stack(STACK_BX).Top()==GetMemory(IP().GetMemSpace()).GetSize()-1 ||
+ // GetHead(HEAD_WRITE).GetPosition() == Stack(STACK_BX).Top()+1) &&
+ // (GetHead(HEAD_WRITE).GetMemSpace() == IP().GetMemSpace() ||
+ // GetHead(HEAD_WRITE).GetMemSpace() == IP().GetMemSpace()+1));
// If we have threads turned on and we executed each thread in a single
// timestep, adjust the number of instructions executed accordingly.
- const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ?
- GetNumThreads() : 1;
+ //const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ?
+ // GetNumThreads() : 1;
+
+ const int num_inst_exec = int(slice_array[GetNumThreads()]+ inst_remainder);
+ inst_remainder = slice_array[GetNumThreads()] + inst_remainder - num_inst_exec;
for (int i = 0; i < num_inst_exec; i++) {
// Setup the hardware for the next instruction to be executed.
NextThread();
- advance_ip = true;
+ AdvanceIP() = true;
IP().Adjust();
#ifdef BREAKPOINTS
@@ -558,7 +481,7 @@
// Some instruction (such as jump) may turn advance_ip off. Ususally
// we now want to move to the next instruction in the memory.
- if (advance_ip == true) IP().Advance();
+ if (AdvanceIP() == true) IP().Advance();
} // if exec
} // Previous was executed once for each thread...
@@ -571,7 +494,6 @@
}
}
-
// This method will test to see if all costs have been paid associated
// with executing an instruction and only return true when that instruction
// should proceed.
@@ -609,24 +531,14 @@
bool cHardware4Stack::SingleProcess_ExecuteInst(const cInstruction & cur_inst)
{
// Get a pointer to the corrisponding method...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int inst_idx = GetInstSet().GetLibFunctionIndex(cur_inst);
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod inst_ptr = GetInstSet().GetFunction(cur_inst);
-#endif /* USE_INST_SET_CODE */
// Mark the instruction as executed
IP().FlagExecuted() = true;
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
-#ifdef USE_INST_SET_CODE
if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
-#else /* USE_INST_SET_CODE */
- if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif /* USE_INST_SET_CODE */
#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
@@ -635,15 +547,7 @@
#endif
// And execute it.
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
- const bool exec_success
- //= (this->*(s_inst_slib->GetFunctions()[inst_idx]))();
- = (this->*(m_functions[inst_idx]))();
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- const bool exec_success = (this->*inst_ptr)();
-#endif /* USE_INST_SET_CODE */
+ const bool exec_success = (this->*(m_functions[inst_idx]))();
#ifdef INSTRUCTION_COUNT
// decremenet if the instruction was not executed successfully
@@ -659,7 +563,7 @@
void cHardware4Stack::LoadGenome(const cGenome & new_genome)
{
- GetMemory() = new_genome;
+ GetMemory(0) = new_genome;
}
@@ -667,12 +571,15 @@
{
bool result = true;
- if (!memory.OK()) result = false;
+ for(int i = 0 ; i < NUM_MEMORY_SPACES; i++) {
+ if (!memory_array[i].OK()) result = false;
+ }
for (int i = 0; i < GetNumThreads(); i++) {
assert (threads[i].input_pointer < IO_SIZE);
- if (threads[i].stack.OK() == false) result = false;
+ for(int j=0; j<NUM_LOCAL_STACKS; j++)
+ if (threads[i].local_stacks[j].OK() == false) result = false;
if (threads[i].next_label.OK() == false) result = false;
}
@@ -682,32 +589,46 @@
void cHardware4Stack::PrintStatus(ostream & fp)
{
fp << organism->GetPhenotype().GetTimeUsed() << " "
- << "IP:" << IP().GetPosition() << " "
+ << "IP:(" << IP().GetMemSpace() << ", " << IP().GetPosition() << ") "
- << "AX:" << Register(REG_AX) << " "
- << setbase(16) << "[0x" << Register(REG_AX) << "] " << setbase(10)
+ << "AX:" << Stack(STACK_AX).Top() << " "
+ << setbase(16) << "[0x" << Stack(STACK_AX).Top() << "] " << setbase(10)
- << "BX:" << Register(REG_BX) << " "
- << setbase(16) << "[0x" << Register(REG_BX) << "] " << setbase(10)
+ << "BX:" << Stack(STACK_BX).Top() << " "
+ << setbase(16) << "[0x" << Stack(STACK_BX).Top() << "] " << setbase(10)
- << "CX:" << Register(REG_CX) << " "
- << setbase(16) << "[0x" << Register(REG_CX) << "]" << setbase(10)
+ << "CX:" << Stack(STACK_CX).Top() << " "
+ << setbase(16) << "[0x" << Stack(STACK_CX).Top() << "] " << setbase(10)
- << "DX:" << Register(REG_DX) << " "
- << setbase(16) << "[0x" << Register(REG_DX) << "]" << setbase(10)
+ << "DX:" << Stack(STACK_DX).Top() << " "
+ << setbase(16) << "[0x" << Stack(STACK_DX).Top() << "] " << setbase(10)
<< endl;
- fp << " R-Head:" << GetHead(HEAD_READ).GetPosition() << " "
- << "W-Head:" << GetHead(HEAD_WRITE).GetPosition() << " "
- << "F-Head:" << GetHead(HEAD_FLOW).GetPosition() << " "
+ fp << " R-Head:(" << GetHead(HEAD_READ).GetMemSpace() << ", "
+ << GetHead(HEAD_READ).GetPosition() << ") "
+ << "W-Head:(" << GetHead(HEAD_WRITE).GetMemSpace() << ", "
+ << GetHead(HEAD_WRITE).GetPosition() << ") "
+ << "F-Head:(" << GetHead(HEAD_FLOW).GetMemSpace() << ", "
+ << GetHead(HEAD_FLOW).GetPosition() << ") "
<< "RL:" << GetReadLabel().AsString() << " "
<< "NEXT: >> " << inst_set->GetName(IP().GetInst())() << " <<"
<< endl;
- fp << " Mem (" << GetMemory().GetSize() << "):"
- << " " << GetMemory().AsString()
+ fp << " Mem (" << GetMemory(0).GetSize() << "):"
+ << " " << GetMemory(0).AsString()
+ << endl;
+ fp << " " << GetMemory(1).GetSize() << "):"
+ << " " << GetMemory(1).AsString()
+ << endl;
+ fp << " " << GetMemory(2).GetSize() << "):"
+ << " " << GetMemory(2).AsString()
+ << endl;
+ fp << " " << GetMemory(3).GetSize() << "):"
+ << " " << GetMemory(3).AsString()
<< endl;
+
+
fp.flush();
}
@@ -734,15 +655,15 @@
//
/////////////////////////////////////////////////////////////////////////
-cCPUHead cHardware4Stack::FindLabel(int direction)
+c4StackHead cHardware4Stack::FindLabel(int direction)
{
- cCPUHead & inst_ptr = IP();
+ c4StackHead & inst_ptr = IP();
// Start up a search head at the position of the instruction pointer.
- cCPUHead search_head(inst_ptr);
+ c4StackHead search_head(inst_ptr);
cCodeLabel & search_label = GetLabel();
- // Make sure the label is of size > 0.
+ // Make sure the label is of size > 0.
if (search_label.GetSize() == 0) {
return inst_ptr;
@@ -767,8 +688,9 @@
}
// Return the last line of the found label, if it was found.
- if (found_pos >= 0) search_head.Set(found_pos - 1);
-
+ if (found_pos > 0) search_head.Set(found_pos - 1, IP().GetMemSpace());
+ //*** I THINK THIS MIGHT HAVE BEEN WRONG...CHANGED >= to >. -law ***//
+
// Return the found position (still at start point if not found).
return search_head;
}
@@ -935,7 +857,7 @@
}
// Search for 'in_label' anywhere in the hardware.
-cCPUHead cHardware4Stack::FindLabel(const cCodeLabel & in_label, int direction)
+c4StackHead cHardware4Stack::FindLabel(const cCodeLabel & in_label, int direction)
{
assert (in_label.GetSize() > 0);
@@ -946,7 +868,7 @@
// FOR NOW:
// Get something which works, no matter how inefficient!!!
- cCPUHead temp_head(this);
+ c4StackHead temp_head(this);
while (temp_head.InMemory()) {
// IDEALY: Analyze the label we are in; see if the one we are looking
@@ -973,14 +895,14 @@
// @CAO: direction is not currently used; should be used to indicate the
// direction which the heads[HEAD_IP] should progress through a creature.
-cCPUHead cHardware4Stack::FindFullLabel(const cCodeLabel & in_label)
+c4StackHead cHardware4Stack::FindFullLabel(const cCodeLabel & in_label)
{
// cout << "Running FindFullLabel with " << in_label.AsString() <<
// endl;
assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
- cCPUHead temp_head(this);
+ c4StackHead temp_head(this);
while (temp_head.InMemory()) {
// If we are not in a label, jump to the next checkpoint...
@@ -1039,118 +961,124 @@
return temp_head;
}
-
-int cHardware4Stack::Inject(const cCodeLabel & in_label, const cGenome & injection)
+// This is the code run by the INFECTED organism. Its function is to SPREAD infection.
+bool cHardware4Stack::Inject_Parasite(int mem_space_used, double mut_multiplier)
{
- // Make sure the genome will be below max size after injection.
-
- const int new_size = injection.GetSize() + GetMemory().GetSize();
- if (new_size > MAX_CREATURE_SIZE) return 1; // (inject fails)
-
- const int inject_line = FindFullLabel(in_label).GetPosition();
+ const int end_pos = GetHead(HEAD_WRITE).GetPosition();
- // Abort if no compliment is found.
- if (inject_line == -1) return 2; // (inject fails)
+ // Make sure the creature will still be above the minimum size,
+ if (end_pos <= 0) {
+ Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: no code to inject");
+ return false; // (inject fails)
+ }
+
+ if (end_pos < MIN_CREATURE_SIZE) {
+ Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
+ return false; // (inject fails)
+ }
- // Inject the code!
- InjectCode(injection, inject_line+1);
+ GetMemory(mem_space_used).Resize(end_pos);
+ cCPUMemory injected_code = GetMemory(mem_space_used);
- return 0; // (inject succeeds!)
-}
+ Inject_DoMutations(mut_multiplier, injected_code);
-int cHardware4Stack::InjectThread(const cCodeLabel & in_label, const cGenome & injection)
-{
- // Make sure the genome will be below max size after injection.
+ int inject_signal = false;
- const int new_size = injection.GetSize() + GetMemory().GetSize();
- if (new_size > MAX_CREATURE_SIZE) return 1; // (inject fails)
+ //************* CALL GOES HERE ******************//
+ // spin around randomly (caution: possible organism dizziness)
+ const int num_neighbors = organism->GetNeighborhoodSize();
+ for(unsigned int i=0; i<g_random.GetUInt(num_neighbors); i++)
+ organism->Rotate(1);
- const int inject_line = FindFullLabel(in_label).GetPosition();
+ // If we don't have a host, stop here.
+ cOrganism * host_organism = organism->GetNeighbor();
+
+
+ if(host_organism!=NULL)
+ {
+ inject_signal = host_organism->GetHardware().Inject_Host(GetLabel(), injected_code);
+ }
+
+ //************** CALL ENDS HERE ******************//
- // Abort if no compliment is found.
- if (inject_line == -1) return 2; // (inject fails)
+ //reset the memory space which was injected
+ GetMemory(mem_space_used)=cGenome(ConvertToInstruction(mem_space_used));
- // Inject the code!
- InjectCodeThread(injection, inject_line+1);
+ for(int x=0; x<NUM_HEADS; x++)
+ {
+ GetHead(x).Reset(IP().GetMemSpace(), this);
+ }
- return 0; // (inject succeeds!)
+ for(int x=0; x<NUM_LOCAL_STACKS; x++)
+ {
+ Stack(x).Clear();
+ }
+
+ AdvanceIP() = false;
+
+ return inject_signal;
}
-void cHardware4Stack::InjectCode(const cGenome & inject_code, const int line_num)
+//This is the code run by the TARGET of an injection. This RECIEVES the infection.
+bool cHardware4Stack::Inject_Host(const cCodeLabel & in_label, const cGenome & inject_code)
{
- assert(line_num >= 0);
- assert(line_num <= memory.GetSize());
- assert(memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
-
- // Inject the new code.
- const int inject_size = inject_code.GetSize();
- memory.Insert(line_num, inject_code);
-
- // Set instruction flags on the injected code
- for (int i = line_num; i < line_num + inject_size; i++) {
- memory.FlagInjected(i) = true;
- }
- organism->GetPhenotype().IsModified() = true;
-
- // Adjust all of the heads to take into account the new mem size.
+ // Make sure the genome will be below max size after injection.
- for (int i=0; i < NUM_HEADS; i++) {
- if (!GetHead(i).TestParasite() &&
- GetHead(i).GetPosition() > line_num)
- GetHead(i).Jump(inject_size);
- }
-}
+ // xxxTEMPORARYxxx - we should have this match injection templates. For now it simply
+ // makes sure the target_mem_space (hardcoded to 2) is empty. - law
+ int target_mem_space = 2;
+ if(!(isEmpty(target_mem_space)))
+ return false;
-void cHardware4Stack::InjectCodeThread(const cGenome & inject_code, const int line_num)
-{
- assert(line_num >= 0);
- assert(line_num <= memory.GetSize());
- assert(memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
+ assert(target_mem_space >=0 && target_mem_space < 4);
- if(ForkThread())
- {
- // Inject the new code.
- const int inject_size = inject_code.GetSize();
- memory.Insert(line_num, inject_code);
-
- // Set instruction flags on the injected code
- for (int i = line_num; i < line_num + inject_size; i++) {
- memory.FlagInjected(i) = true;
+ if(ForkThread()) {
+ // Inject the new code
+ cCPUMemory oldcode = GetMemory(target_mem_space);
+ GetMemory(target_mem_space) = inject_code;
+ GetMemory(target_mem_space).Resize(inject_code.GetSize() + oldcode.GetSize());
+
+ // Copies previous instructions to the end of the injected code.
+ // Is there a faster way to do this?? -law
+ for(int x=0; x<oldcode.GetSize(); x++)
+ GetMemory(target_mem_space)[inject_code.GetSize()+x] = oldcode[x];
+
+ // Set instruction flags on the injected code
+ for (int i = 0; i < inject_code.GetSize(); i++) {
+ memory_array[target_mem_space].FlagInjected(i) = true;
+ }
+ organism->GetPhenotype().IsModified() = true;
+
+ // Adjust all of the heads to take into account the new mem size.
+
+ cur_thread=GetNumThreads()-1;
+
+ for(int i=0; i<cur_thread; i++) {
+ for(int j=0; j<NUM_HEADS; j++) {
+ if(threads[i].heads[j].GetMemSpace()==target_mem_space)
+ threads[i].heads[j].Jump(inject_code.GetSize());
}
- organism->GetPhenotype().IsModified() = true;
- organism->GetPhenotype().IsMultiThread() = true;
-
- // Adjust all of the heads to take into account the new mem size.
-
- int currthread = GetCurThread();
- SetThread(0);
- for (int i=0; i<GetNumThreads()-2; i++)
- {
- for (int j=0; j < NUM_HEADS; j++)
- {
- if (!GetHead(i).TestParasite() && GetHead(i).GetPosition() > line_num)
- GetHead(i).Jump(inject_size);
- }
- NextThread();
- }
- SetThread(currthread);
-
}
- else
- {
- //Some kind of error message should go here...but what?
+
+ for (int i=0; i < NUM_HEADS; i++) {
+ GetHead(i).Reset(target_mem_space, this);
+ }
+ for (int i=0; i < NUM_LOCAL_STACKS; i++) {
+ Stack(i).Clear();
}
+ }
+ return true; // (inject succeeds!)
}
void cHardware4Stack::Mutate(int mut_point)
{
// Test if trying to mutate outside of genome...
- assert(mut_point >= 0 && mut_point < GetMemory().GetSize());
+ assert(mut_point >= 0 && mut_point < GetMemory(0).GetSize());
- GetMemory()[mut_point] = GetRandomInst();
- GetMemory().FlagMutated(mut_point) = true;
- GetMemory().FlagPointMut(mut_point) = true;
+ GetMemory(0)[mut_point] = GetRandomInst();
+ GetMemory(0).FlagMutated(mut_point) = true;
+ GetMemory(0).FlagPointMut(mut_point) = true;
//organism->GetPhenotype().IsMutated() = true;
organism->CPUStats().mut_stats.point_mut_count++;
}
@@ -1158,10 +1086,10 @@
int cHardware4Stack::PointMutate(const double mut_rate)
{
const int num_muts =
- g_random.GetRandBinomial(GetMemory().GetSize(), mut_rate);
+ g_random.GetRandBinomial(GetMemory(0).GetSize(), mut_rate);
for (int i = 0; i < num_muts; i++) {
- const int pos = g_random.GetUInt(GetMemory().GetSize());
+ const int pos = g_random.GetUInt(GetMemory(0).GetSize());
Mutate(pos);
}
@@ -1183,7 +1111,7 @@
return TriggerMutations(trigger, IP());
}
-bool cHardware4Stack::TriggerMutations(int trigger, cCPUHead & cur_head)
+bool cHardware4Stack::TriggerMutations(int trigger, c4StackHead & cur_head)
{
// Collect information about mutations from the organism.
cLocalMutations & mut_info = organism->GetLocalMutations();
@@ -1196,7 +1124,7 @@
// Determine what memory this mutation will be affecting.
cCPUMemory & target_mem = (trigger == MUTATION_TRIGGER_DIVIDE)
- ? organism->ChildGenome() : GetMemory();
+ ? organism->ChildGenome() : GetMemory(0);
// Loop through all mutations associated with this trigger and test them.
tConstListIterator<cMutation> mut_it(mut_list);
@@ -1236,7 +1164,7 @@
}
bool cHardware4Stack::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
{
// The rate we have stored indicates the probability that a single
// mutation will occur anywhere in the genome.
@@ -1244,7 +1172,7 @@
if (g_random.P(rate) == true) {
// We must create a temporary head and use it to randomly determine the
// position in the genome to be mutated.
- cCPUHead tmp_head(cur_head);
+ c4StackHead tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
return true;
@@ -1253,7 +1181,7 @@
}
bool cHardware4Stack::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
{
// The rate we have stored is the probability for a mutation at this single
// position in the genome.
@@ -1266,7 +1194,7 @@
}
int cHardware4Stack::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate)
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate)
{
// The probability we have stored is per-site, so we can pull a random
// number from a binomial distribution to determine the number of mutations
@@ -1277,7 +1205,7 @@
if (num_mut > 0) {
for (int i = 0; i < num_mut; i++) {
- cCPUHead tmp_head(cur_head);
+ c4StackHead tmp_head(cur_head);
tmp_head.AbsSet(g_random.GetUInt(target_memory.GetSize()));
TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
}
@@ -1287,7 +1215,7 @@
}
void cHardware4Stack::TriggerMutations_Body(int type, cCPUMemory & target_memory,
- cCPUHead & cur_head)
+ c4StackHead & cur_head)
{
const int pos = cur_head.GetPosition();
@@ -1336,7 +1264,7 @@
void cHardware4Stack::ReadLabel(int max_size)
{
int count = 0;
- cCPUHead * inst_ptr = &( IP() );
+ c4StackHead * inst_ptr = &( IP() );
GetLabel().Clear();
@@ -1362,8 +1290,10 @@
// Make room for the new thread.
threads.Resize(num_threads + 1);
+ //IP().Advance();
+
// Initialize the new thread to the same values as the current one.
- threads[num_threads] = threads[cur_thread];
+ threads[num_threads] = threads[cur_thread];
// Find the first free bit in thread_id_chart to determine the new
// thread id.
@@ -1417,9 +1347,10 @@
fp<<"cHardware4Stack"<<endl;
// global_stack (in inverse order so load can just push)
- global_stack.SaveState(fp);
+ for(int i=NUM_LOCAL_STACKS; i<NUM_STACKS; i++)
+ Stack(i).SaveState(fp);
- fp << thread_time_used << endl;
+ //fp << thread_time_used << endl;
fp << GetNumThreads() << endl;
fp << cur_thread << endl;
@@ -1440,10 +1371,11 @@
assert( foo == "cHardware4Stack" );
// global_stack
- global_stack.LoadState(fp);
+ for(int i=NUM_LOCAL_STACKS; i<NUM_STACKS; i++)
+ Stack(i).LoadState(fp);
int num_threads;
- fp >> thread_time_used;
+ //fp >> thread_time_used;
fp >> num_threads;
fp >> cur_thread;
@@ -1458,18 +1390,6 @@
// Instruction Helpers...
////////////////////////////
-inline int cHardware4Stack::FindModifiedRegister(int default_register)
-{
- assert(default_register < NUM_REG_4STACK); // Reg ID too high.
-
- if (GetInstSet().IsNop(IP().GetNextInst())) {
- IP().Advance();
- default_register = GetInstSet().GetNopMod(IP().GetInst());
- IP().FlagExecuted() = true;
- }
- return default_register;
-}
-
inline int cHardware4Stack::FindModifiedStack(int default_stack)
{
assert(default_stack < NUM_STACKS); // Stack ID too high.
@@ -1482,7 +1402,6 @@
return default_stack;
}
-
inline int cHardware4Stack::FindModifiedHead(int default_head)
{
assert(default_head < NUM_HEADS); // Head ID too high.
@@ -1495,13 +1414,6 @@
return default_head;
}
-
-inline int cHardware4Stack::FindComplementRegister(int base_reg)
-{
- const int comp_reg = base_reg + 2;
- return comp_reg%NUM_REG_4STACK;
-}
-
inline int cHardware4Stack::FindComplementStack(int base_stack)
{
const int comp_stack = base_stack + 2;
@@ -1513,103 +1425,12 @@
organism->Fault(fault_loc, fault_type, fault_desc);
}
-
-bool cHardware4Stack::Allocate_Necro(const int new_size)
-{
- GetMemory().ResizeOld(new_size);
- return true;
-}
-
-bool cHardware4Stack::Allocate_Random(const int old_size, const int new_size)
-{
- GetMemory().Resize(new_size);
-
- for (int i = old_size; i < new_size; i++) {
- GetMemory()[i] = GetInstSet().GetRandomInst();
- }
- return true;
-}
-
-bool cHardware4Stack::Allocate_Default(const int new_size)
-{
- GetMemory().Resize(new_size);
-
- // New space already defaults to default instruction...
-
- return true;
-}
-
-bool cHardware4Stack::Allocate_Main(const int allocated_size)
-{
- // must do divide before second allocate & must allocate positive amount...
- if (cConfig::GetRequireAllocate() && mal_active == true) {
- Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR, "Allocate already active");
- return false;
- }
- if (allocated_size < 1) {
- Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
- cStringUtil::Stringf("Allocate of %d too small", allocated_size));
- return false;
- }
-
- const int old_size = GetMemory().GetSize();
- const int new_size = old_size + allocated_size;
-
- // Make sure that the new size is in range.
- if (new_size > MAX_CREATURE_SIZE || new_size < MIN_CREATURE_SIZE) {
- Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
- cStringUtil::Stringf("Invalid post-allocate size (%d)",
- new_size));
- return false;
- }
-
- const int max_alloc_size = (int) (old_size * cConfig::GetChildSizeRange());
- if (allocated_size > max_alloc_size) {
- Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
- cStringUtil::Stringf("Allocate too large (%d > %d)",
- allocated_size, max_alloc_size));
- return false;
- }
-
- const int max_old_size =
- (int) (allocated_size * cConfig::GetChildSizeRange());
- if (old_size > max_old_size) {
- Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
- cStringUtil::Stringf("Allocate too small (%d > %d)",
- old_size, max_old_size));
- return false;
- }
-
- switch (cConfig::GetAllocMethod()) {
- case ALLOC_METHOD_NECRO:
- // Only break if this succeeds -- otherwise just do random.
- if (Allocate_Necro(new_size) == true) break;
- case ALLOC_METHOD_RANDOM:
- Allocate_Random(old_size, new_size);
- break;
- case ALLOC_METHOD_DEFAULT:
- Allocate_Default(new_size);
- break;
- }
-
- mal_active = true;
-
- return true;
-}
-
-
-bool cHardware4Stack::Divide_CheckViable(const int child_size,
- const int parent_size)
+bool cHardware4Stack::Divide_CheckViable(const int parent_size,
+ const int child_size, const int mem_space)
{
// Make sure the organism is okay with dividing now...
if (organism->Divide_CheckViable() == false) return false; // (divide fails)
- // If required, make sure an allocate has occured.
- if (cConfig::GetRequireAllocate() && mal_active == false) {
- Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR, "Must allocate before divide");
- return false; // (divide fails)
- }
-
// Make sure that neither parent nor child will be below the minimum size.
const int genome_size = organism->GetGenome().GetSize();
@@ -1622,18 +1443,13 @@
cStringUtil::Stringf("Invalid offspring length (%d)", child_size));
return false; // (divide fails)
}
- if (parent_size < min_size || parent_size > max_size) {
- Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
- cStringUtil::Stringf("Invalid post-divide length (%d)",parent_size));
- return false; // (divide fails)
- }
// Count the number of lines executed in the parent, and make sure the
// specified fraction has been reached.
int executed_size = 0;
for (int i = 0; i < parent_size; i++) {
- if (GetMemory().FlagExecuted(i)) executed_size++;
+ if (GetMemory(0).FlagExecuted(i)) executed_size++;
}
const int min_exe_lines = (int) (parent_size * cConfig::GetMinExeLines());
@@ -1648,9 +1464,9 @@
// sure the specified fraction has been reached.
int copied_size = 0;
- for (int i = parent_size; i < parent_size + child_size; i++) {
- if (GetMemory().FlagCopied(i)) copied_size++;
- }
+ for (int i = 0; i < GetMemory(mem_space).GetSize(); i++) {
+ if (GetMemory(mem_space).FlagCopied(i)) copied_size++;
+ }
const int min_copied = (int) (child_size * cConfig::GetMinCopiedLines());
if (copied_size < min_copied) {
@@ -1757,9 +1573,9 @@
// Mutations in the parent's genome
if (organism->GetParentMutProb() > 0) {
- for (int i = 0; i < GetMemory().GetSize(); i++) {
+ for (int i = 0; i < GetMemory(0).GetSize(); i++) {
if (organism->TestParentMut()) {
- GetMemory()[i] = GetRandomInst();
+ GetMemory(0)[i] = GetRandomInst();
cpu_stats.mut_stats.parent_mut_line_count++;
}
}
@@ -1767,8 +1583,8 @@
// Count up mutated lines
- for(int i = 0; i < GetMemory().GetSize(); i++){
- if (GetMemory().FlagPointMut(i) == true) {
+ for(int i = 0; i < GetMemory(0).GetSize(); i++){
+ if (GetMemory(0).FlagPointMut(i) == true) {
cpu_stats.mut_stats.point_mut_line_count++;
}
}
@@ -1779,6 +1595,118 @@
}
}
+void cHardware4Stack::Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code)
+{
+ //sCPUStats & cpu_stats = organism->CPUStats();
+ //cCPUMemory & child_genome = organism->ChildGenome();
+
+ organism->GetPhenotype().SetDivType(mut_multiplier);
+
+ // Divide Mutations
+ if (organism->TestDivideMut()) {
+ const UINT mut_line = g_random.GetUInt(injected_code.GetSize());
+ injected_code[mut_line] = GetRandomInst();
+ //cpu_stats.mut_stats.divide_mut_count++;
+ }
+
+ // Divide Insertions
+ if (organism->TestDivideIns() && injected_code.GetSize() < MAX_CREATURE_SIZE){
+ const UINT mut_line = g_random.GetUInt(injected_code.GetSize() + 1);
+ injected_code.Insert(mut_line, GetRandomInst());
+ //cpu_stats.mut_stats.divide_insert_mut_count++;
+ }
+
+ // Divide Deletions
+ if (organism->TestDivideDel() && injected_code.GetSize() > MIN_CREATURE_SIZE){
+ const UINT mut_line = g_random.GetUInt(injected_code.GetSize());
+ // if( injected_code.FlagCopied(mut_line) == true) copied_size_change--;
+ injected_code.Remove(mut_line);
+ //cpu_stats.mut_stats.divide_delete_mut_count++;
+ }
+
+ // Divide Mutations (per site)
+ if(organism->GetDivMutProb() > 0){
+ int num_mut = g_random.GetRandBinomial(injected_code.GetSize(),
+ organism->GetDivMutProb() / mut_multiplier);
+ // If we have lines to mutate...
+ if( num_mut > 0 ){
+ for (int i = 0; i < num_mut; i++) {
+ int site = g_random.GetUInt(injected_code.GetSize());
+ injected_code[site]=GetRandomInst();
+ //cpu_stats.mut_stats.div_mut_count++;
+ }
+ }
+ }
+
+
+ // Insert Mutations (per site)
+ if(organism->GetInsMutProb() > 0){
+ int num_mut = g_random.GetRandBinomial(injected_code.GetSize(),
+ organism->GetInsMutProb());
+ // If would make creature to big, insert up to MAX_CREATURE_SIZE
+ if( num_mut + injected_code.GetSize() > MAX_CREATURE_SIZE ){
+ num_mut = MAX_CREATURE_SIZE - injected_code.GetSize();
+ }
+ // If we have lines to insert...
+ if( num_mut > 0 ){
+ // Build a list of the sites where mutations occured
+ static int mut_sites[MAX_CREATURE_SIZE];
+ for (int i = 0; i < num_mut; i++) {
+ mut_sites[i] = g_random.GetUInt(injected_code.GetSize() + 1);
+ }
+ // Sort the list
+ qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
+ // Actually do the mutations (in reverse sort order)
+ for(int i = num_mut-1; i >= 0; i--) {
+ injected_code.Insert(mut_sites[i], GetRandomInst());
+ //cpu_stats.mut_stats.insert_mut_count++;
+ }
+ }
+ }
+
+
+ // Delete Mutations (per site)
+ if( organism->GetDelMutProb() > 0 ){
+ int num_mut = g_random.GetRandBinomial(injected_code.GetSize(),
+ organism->GetDelMutProb());
+ // If would make creature too small, delete down to MIN_CREATURE_SIZE
+ if (injected_code.GetSize() - num_mut < MIN_CREATURE_SIZE) {
+ num_mut = injected_code.GetSize() - MIN_CREATURE_SIZE;
+ }
+
+ // If we have lines to delete...
+ for (int i = 0; i < num_mut; i++) {
+ int site = g_random.GetUInt(injected_code.GetSize());
+ // if (injected_code.FlagCopied(site) == true) copied_size_change--;
+ injected_code.Remove(site);
+ //cpu_stats.mut_stats.delete_mut_count++;
+ }
+ }
+
+ // Mutations in the parent's genome
+ if (organism->GetParentMutProb() > 0) {
+ for (int i = 0; i < GetMemory(0).GetSize(); i++) {
+ if (organism->TestParentMut()) {
+ GetMemory(0)[i] = GetRandomInst();
+ //cpu_stats.mut_stats.parent_mut_line_count++;
+ }
+ }
+ }
+
+ /*
+ // Count up mutated lines
+ for(int i = 0; i < GetMemory(0).GetSize(); i++){
+ if (GetMemory(0).FlagPointMut(i) == true) {
+ cpu_stats.mut_stats.point_mut_line_count++;
+ }
+ }
+ for(int i = 0; i < injected_code.GetSize(); i++){
+ if( injected_code.FlagCopyMut(i) == true) {
+ cpu_stats.mut_stats.copy_mut_line_count++;
+ }
+ }*/
+}
+
// test whether the offspring creature contains an advantageous mutation.
void cHardware4Stack::Divide_TestFitnessMeasures()
@@ -1840,21 +1768,25 @@
}
-bool cHardware4Stack::Divide_Main(const int div_point, const int extra_lines, double mut_multiplier)
+bool cHardware4Stack::Divide_Main(int mem_space_used, double mut_multiplier)
{
- const int child_size = GetMemory().GetSize() - div_point - extra_lines;
+ int write_head_pos = GetHead(HEAD_WRITE).GetPosition();
+
+ // We're going to disallow division calls from memory spaces other than zero
+ // for right now -law
+ if(IP().GetMemSpace()!=0)
+ return false;
// Make sure this divide will produce a viable offspring.
- const bool viable = Divide_CheckViable(child_size, div_point);
- if (viable == false) return false;
-
+ if(!Divide_CheckViable(GetMemory(IP().GetMemSpace()).GetSize(),
+ write_head_pos, mem_space_used))
+ return false;
+
// Since the divide will now succeed, set up the information to be sent
// to the new organism
cGenome & child_genome = organism->ChildGenome();
- child_genome = cGenomeUtil::Crop(memory, div_point, div_point+child_size);
-
- // Cut off everything in this memory past the divide point.
- GetMemory().Resize(div_point);
+ GetMemory(mem_space_used).Resize(write_head_pos);
+ child_genome = GetMemory(mem_space_used);
// Handle Divide Mutations...
Divide_DoMutations(mut_multiplier);
@@ -1871,21 +1803,78 @@
}
#endif
- mal_active = false;
- if (cConfig::GetDivideMethod() == DIVIDE_METHOD_SPLIT) {
- advance_ip = false;
- }
-
- // Activate the child, and do more work if the parent lives through the
- // birth.
bool parent_alive = organism->ActivateDivide();
- if (parent_alive) {
- if (cConfig::GetDivideMethod() == DIVIDE_METHOD_SPLIT) Reset();
- }
+ //reset the memory of the memory space that has been divided off
+ GetMemory(mem_space_used)=cGenome(ConvertToInstruction(mem_space_used));
+
+ // 3 Division Methods:
+ // 1) DIVIDE_METHOD_OFFSPRING - Create a child, leave parent state untouched.
+ // 2) DIVIDE_METHOD_SPLIT - Create a child, completely reset state of parent.
+ // 3) DIVIDE_METHOD_BIRTH - Create a child, reset state of parent's current thread.
+ if(parent_alive && !(cConfig::GetDivideMethod() == DIVIDE_METHOD_OFFSPRING))
+ {
+
+ if(cConfig::GetDivideMethod() == DIVIDE_METHOD_SPLIT)
+ {
+ //this will wipe out all parasites on a divide.
+ Reset();
+
+ }
+ else if(cConfig::GetDivideMethod() == DIVIDE_METHOD_BIRTH)
+ {
+ //if this isn't the only thread, get rid of it!
+ // ***this can cause a concurrency problem if we have
+ // multiprocessor support for single organisms...don't
+ // think that's happening anytime soon though -law ***
+ if(!organism->GetPhenotype().IsModified() && GetNumThreads()>1 ||
+ GetNumThreads()>2)
+ {
+ KillThread();
+ }
+
+ //this will reset the current thread's heads and stacks. It will
+ //not touch any other threads or memory spaces (ie: parasites)
+ else
+ {
+ for(int x=0; x<NUM_HEADS; x++)
+ {
+ GetHead(x).Reset(0, this);
+ }
+ for(int x=0; x<NUM_LOCAL_STACKS; x++)
+ {
+ Stack(x).Clear();
+ }
+ }
+ }
+ AdvanceIP()=false;
+ }
+
return true;
}
+cString cHardware4Stack::ConvertToInstruction(int mem_space_used)
+{
+ char c = mem_space_used + 97;
+ cString ret;
+ ret += c;
+ return ret;
+}
+
+cString cHardware4Stack::GetActiveStackID(int stackID) const
+{
+ if(stackID==STACK_AX)
+ return "AX";
+ else if(stackID==STACK_BX)
+ return "BX";
+ else if(stackID==STACK_CX)
+ return "CX";
+ else if(stackID==STACK_DX)
+ return "DX";
+ else
+ return "";
+}
+
//////////////////////////
// And the instructions...
@@ -1895,7 +1884,9 @@
bool cHardware4Stack::Inst_ShiftR()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() >>= 1;
+ int value = Stack(stack_used).Pop();
+ value >>= 1;
+ Stack(stack_used).Push(value);
return true;
}
@@ -1903,51 +1894,53 @@
bool cHardware4Stack::Inst_ShiftL()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() <<= 1;
+ int value = Stack(stack_used).Pop();
+ value <<= 1;
+ Stack(stack_used).Push(value);
return true;
}
//8
-bool cHardware4Stack::Inst_Nand()
+bool cHardware4Stack::Inst_Val_Nand()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() = ~(Stack(STACK_BX).Top() & Stack(STACK_CX).Top());
+ Stack(stack_used).Push(~(Stack(STACK_BX).Top() & Stack(STACK_CX).Top()));
return true;
}
//9
-bool cHardware4Stack::Inst_Add()
+bool cHardware4Stack::Inst_Val_Add()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() = Stack(STACK_BX).Top() + Stack(STACK_CX).Top();
+ Stack(stack_used).Push(Stack(STACK_BX).Top() + Stack(STACK_CX).Top());
return true;
}
//10
-bool cHardware4Stack::Inst_Sub()
+bool cHardware4Stack::Inst_Val_Sub()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() = Stack(STACK_BX).Top() - Stack(STACK_CX).Top();
+ Stack(stack_used).Push(Stack(STACK_BX).Top() - Stack(STACK_CX).Top());
return true;
}
//11
-bool cHardware4Stack::Inst_Mult()
+bool cHardware4Stack::Inst_Val_Mult()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() = Stack(STACK_BX).Top() * Stack(STACK_CX).Top();
+ Stack(stack_used).Push(Stack(STACK_BX).Top() * Stack(STACK_CX).Top());
return true;
}
//12
-bool cHardware4Stack::Inst_Div()
+bool cHardware4Stack::Inst_Val_Div()
{
const int stack_used = FindModifiedStack(STACK_BX);
if (Stack(STACK_CX).Top() != 0) {
if (0-INT_MAX > Stack(STACK_BX).Top() && Stack(STACK_CX).Top() == -1)
Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "div: Float exception");
else
- Stack(stack_used).Top() = Stack(STACK_BX).Top() / Stack(STACK_CX).Top();
+ Stack(stack_used).Push(Stack(STACK_BX).Top() / Stack(STACK_CX).Top());
} else {
Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "div: dividing by 0");
return false;
@@ -1956,34 +1949,50 @@
}
//13
-bool cHardware4Stack::Inst_MaxAlloc() // Allocate maximal more
+bool cHardware4Stack::Inst_SetMemory() // Allocate maximal more
{
- const int cur_size = GetMemory().GetSize();
- const int alloc_size = Min((int) (cConfig::GetChildSizeRange() * cur_size),
- MAX_CREATURE_SIZE - cur_size);
- if( Allocate_Main(alloc_size) ) {
- Stack(STACK_AX).Top() = cur_size;
- return true;
- } else return false;
+ int mem_space_used = FindModifiedStack(-1);
+
+ if(mem_space_used==-1) {
+ mem_space_used = FindFirstEmpty();
+ if(mem_space_used==-1)
+ return false;
+ }
+
+ GetHead(HEAD_FLOW).Set(0, mem_space_used);
+ return true;
+
+ //const int cur_size = GetMemory(0).GetSize();
+ //const int alloc_size = Min((int) (cConfig::GetChildSizeRange() * cur_size),
+ // MAX_CREATURE_SIZE - cur_size);
+ //if( Allocate_Main(alloc_size) ) {
+ // Stack(STACK_AX).Push(cur_size);
+ // return true;
+ //} else return false;
}
//14
-bool cHardware4Stack::Inst_HeadDivide()
+bool cHardware4Stack::Inst_Divide()
{
- return Inst_HeadDivideMut(1);
+ int mem_space_used = GetHead(HEAD_WRITE).GetMemSpace();
+ int mut_multiplier = 1;
+
+ return Divide_Main(mem_space_used, mut_multiplier);
}
bool cHardware4Stack::Inst_HeadDivideMut(double mut_multiplier)
{
- AdjustHeads();
- const int divide_pos = GetHead(HEAD_READ).GetPosition();
- int child_end = GetHead(HEAD_WRITE).GetPosition();
- if (child_end == 0) child_end = GetMemory().GetSize();
- const int extra_lines = GetMemory().GetSize() - child_end;
- bool ret_val = Divide_Main(divide_pos, extra_lines, mut_multiplier);
- // Re-adjust heads.
- AdjustHeads();
- return ret_val;
+ // Unused for the moment...
+ return true;
+ //AdjustHeads();
+ //const int divide_pos = GetHead(HEAD_READ).GetPosition();
+ //int child_end = GetHead(HEAD_WRITE).GetPosition();
+ //if (child_end == 0) child_end = GetMemory(0).GetSize();
+ //const int extra_lines = GetMemory(0).GetSize() - child_end;
+ //bool ret_val = Divide_Main(divide_pos, extra_lines, mut_multiplier);
+ //// Re-adjust heads.
+ //AdjustHeads();
+ //return ret_val;
}
//15
@@ -2001,7 +2010,7 @@
} else {
read_inst = GetHead(head_id).GetInst().GetOp();
}
- Stack(STACK_BX).Top() = read_inst;
+ Stack(STACK_AX).Push(read_inst);
ReadInst(read_inst);
cpu_stats.mut_stats.copies_exec++; // @CAO, this too..
@@ -2013,11 +2022,19 @@
bool cHardware4Stack::Inst_HeadWrite()
{
const int head_id = FindModifiedHead(HEAD_WRITE);
- cCPUHead & active_head = GetHead(head_id);
+ c4StackHead & active_head = GetHead(head_id);
+ int mem_space_used = active_head.GetMemSpace();
+
+ //commented out for right now...
+ if(active_head.GetPosition()>=GetMemory(mem_space_used).GetSize()-1)
+ {
+ GetMemory(mem_space_used).Resize(GetMemory(mem_space_used).GetSize()+1);
+ GetMemory(mem_space_used).Copy(GetMemory(mem_space_used).GetSize()-1, GetMemory(mem_space_used).GetSize()-2);
+ }
active_head.Adjust();
- int value = Stack(STACK_BX).Top();
+ int value = Stack(STACK_AX).Pop();
if (value < 0 || value >= GetNumInst()) value = 0;
active_head.SetInst(cInstruction(value));
@@ -2032,8 +2049,8 @@
bool cHardware4Stack::Inst_HeadCopy()
{
// For the moment, this cannot be nop-modified.
- cCPUHead & read_head = GetHead(HEAD_READ);
- cCPUHead & write_head = GetHead(HEAD_WRITE);
+ c4StackHead & read_head = GetHead(HEAD_READ);
+ c4StackHead & write_head = GetHead(HEAD_WRITE);
sCPUStats & cpu_stats = organism->CPUStats();
read_head.Adjust();
@@ -2065,19 +2082,19 @@
}
//17
-bool cHardware4Stack::Inst_IfEqu() // Execute next if bx == ?cx?
+bool cHardware4Stack::Inst_IfEqual() // Execute next if bx == ?cx?
{
- const int stack_used = FindModifiedStack(STACK_BX);
- const int stack_used2 = FindComplementStack(stack_used);
+ const int stack_used = FindModifiedStack(STACK_AX);
+ const int stack_used2 = (stack_used+1)%NUM_STACKS;
if (Stack(stack_used).Top() != Stack(stack_used2).Top()) IP().Advance();
return true;
}
//18
-bool cHardware4Stack::Inst_IfNEqu() // Execute next if bx != ?cx?
+bool cHardware4Stack::Inst_IfNotEqual() // Execute next if bx != ?cx?
{
- const int stack_used = FindModifiedStack(STACK_BX);
- const int stack_used2 = FindComplementStack(stack_used);
+ const int stack_used = FindModifiedStack(STACK_AX);
+ const int stack_used2 = (stack_used+1)%NUM_STACKS;
if (Stack(stack_used).Top() == Stack(stack_used2).Top()) IP().Advance();
return true;
}
@@ -2085,17 +2102,17 @@
//19
bool cHardware4Stack::Inst_IfLess() // Execute next if ?bx? < ?cx?
{
- const int stack_used = FindModifiedStack(STACK_BX);
- const int stack_used2 = FindComplementStack(stack_used);
+ const int stack_used = FindModifiedStack(STACK_AX);
+ const int stack_used2 = (stack_used+1)%NUM_STACKS;
if (Stack(stack_used).Top() >= Stack(stack_used2).Top()) IP().Advance();
return true;
}
//20
-bool cHardware4Stack::Inst_IfGr() // Execute next if bx > ?cx?
+bool cHardware4Stack::Inst_IfGreater() // Execute next if bx > ?cx?
{
- const int stack_used = FindModifiedStack(STACK_BX);
- const int stack_used2 = FindComplementStack(stack_used);
+ const int stack_used = FindModifiedStack(STACK_AX);
+ const int stack_used2 = (stack_used+1)%NUM_STACKS;
if (Stack(stack_used).Top() <= Stack(stack_used2).Top()) IP().Advance();
return true;
}
@@ -2104,11 +2121,11 @@
bool cHardware4Stack::Inst_HeadPush()
{
const int head_used = FindModifiedHead(HEAD_IP);
- StackPush(GetHead(head_used).GetPosition());
- if (head_used == HEAD_IP) {
- GetHead(head_used).Set(GetHead(HEAD_FLOW));
- advance_ip = false;
- }
+ Stack(STACK_BX).Push(GetHead(head_used).GetPosition());
+ //if (head_used == HEAD_IP) {
+ // GetHead(head_used).Set(GetHead(HEAD_FLOW));
+ // AdvanceIP() = false;
+ //}
return true;
}
@@ -2116,58 +2133,102 @@
bool cHardware4Stack::Inst_HeadPop()
{
const int head_used = FindModifiedHead(HEAD_IP);
- GetHead(head_used).Set(StackPop(), this);
+ GetHead(head_used).Set(Stack(STACK_BX).Pop(),
+ GetHead(head_used).GetMemSpace(), this);
return true;
}
//23
-bool cHardware4Stack::Inst_MoveHead()
+bool cHardware4Stack::Inst_HeadMove()
{
const int head_used = FindModifiedHead(HEAD_IP);
- GetHead(head_used).Set(GetHead(HEAD_FLOW));
- if (head_used == HEAD_IP) advance_ip = false;
+ if(head_used != HEAD_FLOW)
+ {
+ GetHead(head_used).Set(GetHead(HEAD_FLOW));
+ if (head_used == HEAD_IP) AdvanceIP() = false;
+ }
+ else
+ {
+ threads[cur_thread].heads[HEAD_FLOW]++;
+ }
return true;
}
//24
-bool cHardware4Stack::Inst_HeadSearch()
+bool cHardware4Stack::Inst_Search()
{
ReadLabel();
GetLabel().Rotate(2, NUM_NOPS_4STACK);
- cCPUHead found_pos = FindLabel(0);
- const int search_size = found_pos.GetPosition() - IP().GetPosition();
- Stack(STACK_BX).Top() = search_size;
- Stack(STACK_CX).Top() = GetLabel().GetSize();
- GetHead(HEAD_FLOW).Set(found_pos);
- GetHead(HEAD_FLOW).Advance();
+ c4StackHead found_pos = FindLabel(0);
+ if(found_pos.GetPosition()-IP().GetPosition()==0)
+ {
+ GetHead(HEAD_FLOW).Set(IP().GetPosition()+1, IP().GetMemSpace(), this);
+ // pushing zero into STACK_AX on a missed search makes it difficult to create
+ // a self-replicating organism. -law
+ //Stack(STACK_AX).Push(0);
+ Stack(STACK_BX).Push(0);
+ }
+ else
+ {
+ int search_size = found_pos.GetPosition() - IP().GetPosition() + GetLabel().GetSize() + 1;
+ Stack(STACK_BX).Push(search_size);
+ Stack(STACK_AX).Push(GetLabel().GetSize());
+ GetHead(HEAD_FLOW).Set(found_pos);
+ }
+
return true;
}
//25
-bool cHardware4Stack::Inst_PushA() { StackPush(Stack(STACK_AX).Top()); return true;}
+bool cHardware4Stack::Inst_PushNext()
+{
+ int stack_used = FindModifiedStack(STACK_AX);
+ int successor = (stack_used+1)%NUM_STACKS;
+ Stack(successor).Push(Stack(stack_used).Pop());
+ return true;
+}
//26
-bool cHardware4Stack::Inst_PushB() { StackPush(Stack(STACK_AX).Top()); return true;}
+bool cHardware4Stack::Inst_PushPrevious()
+{
+ int stack_used = FindModifiedStack(STACK_BX);
+ int predecessor = (stack_used+NUM_STACKS-1)%NUM_STACKS;
+ Stack(predecessor).Push(Stack(stack_used).Pop());
+ return true;
+}
//27
-bool cHardware4Stack::Inst_PushC() { StackPush(Stack(STACK_AX).Top()); return true;}
+bool cHardware4Stack::Inst_PushComplement()
+{
+ int stack_used = FindModifiedStack(STACK_BX);
+ int complement = FindComplementStack(stack_used);
+ Stack(complement).Push(Stack(stack_used).Pop());
+ return true;
+}
-//INSTRUCTION 28 - "ValDelete" GOES HERE - law
+//28
+bool cHardware4Stack::Inst_ValDelete()
+{
+ int stack_used = FindModifiedStack(STACK_BX);
+ Stack(stack_used).Pop();
+ return true;
+}
//29
-bool cHardware4Stack::Inst_CopyStack()
+bool cHardware4Stack::Inst_ValCopy()
{
const int stack_used = FindModifiedStack(STACK_BX);
- const int other_stack = FindComplementStack(stack_used);
- Stack(other_stack).Top() = Stack(stack_used).Top();
+ Stack(stack_used).Push(Stack(stack_used).Top());
return true;
}
//30
bool cHardware4Stack::Inst_ForkThread()
{
- IP().Advance();
- if (!ForkThread()) Fault(FAULT_LOC_THREAD_FORK, FAULT_TYPE_FORK_TH);
+ if (!ForkThread())
+ Fault(FAULT_LOC_THREAD_FORK, FAULT_TYPE_FORK_TH);
+ else
+ IP().Advance();
return true;
}
@@ -2181,18 +2242,20 @@
}
//32
-bool cHardware4Stack::Inst_Inc()
+bool cHardware4Stack::Inst_Increment()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() += 1;
+ int value = Stack(stack_used).Pop();
+ Stack(stack_used).Push(++value);
return true;
}
//33
-bool cHardware4Stack::Inst_Dec()
+bool cHardware4Stack::Inst_Decrement()
{
const int stack_used = FindModifiedStack(STACK_BX);
- Stack(stack_used).Top() -= 1;
+ int value = Stack(stack_used).Pop();
+ Stack(stack_used).Push(--value);
return true;
}
@@ -2201,7 +2264,10 @@
{
const int stack_used = FindModifiedStack(STACK_BX);
if (Stack(STACK_CX).Top() != 0) {
- Stack(stack_used).Top() = Stack(STACK_BX).Top() % Stack(STACK_CX).Top();
+ if(Stack(STACK_CX).Top() == -1)
+ Stack(stack_used).Push(0);
+ else
+ Stack(stack_used).Push(Stack(STACK_BX).Top() % Stack(STACK_CX).Top());
} else {
Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "mod: modding by 0");
return false;
@@ -2213,1053 +2279,92 @@
bool cHardware4Stack::Inst_KillThread()
{
if (!KillThread()) Fault(FAULT_LOC_THREAD_KILL, FAULT_TYPE_KILL_TH);
- else advance_ip = false;
- return true;
-}
-
-/*bool cHardware4Stack::Inst_If0() // Execute next if ?bx? ==0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) != 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfNot0() // Execute next if ?bx? != 0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) == 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfGr0() // Execute next if ?bx? ! < 0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) <= 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfGrEqu0() // Execute next if ?bx? != 0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) < 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfGrEqu() // Execute next if bx > ?cx?
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int reg_used2 = FindComplementRegister(reg_used);
- if (Register(reg_used) < Register(reg_used2)) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfLess0() // Execute next if ?bx? != 0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) >= 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfLsEqu0() // Execute next if ?bx? != 0.
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if (Register(reg_used) > 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfLsEqu() // Execute next if bx > ?cx?
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int reg_used2 = FindComplementRegister(reg_used);
- if (Register(reg_used) > Register(reg_used2)) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfBit1()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- if ((Register(reg_used) & 1) == 0) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfANotEqB() // Execute next if AX != BX
-{
- if (Register(REG_AX) == Register(REG_BX) ) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfBNotEqC() // Execute next if BX != CX
-{
- if (Register(REG_BX) == Register(REG_CX) ) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_IfANotEqC() // Execute next if AX != BX
-{
- if (Register(REG_AX) == Register(REG_CX) ) IP().Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_JumpF()
-{
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- // If there is no label, jump BX steps.
- if (GetLabel().GetSize() == 0) {
- GetActiveHead().Jump(Register(REG_BX));
- return true;
- }
-
- // Otherwise, try to jump to the complement label.
- const cCPUHead jump_location(FindLabel(1));
- if ( jump_location.GetPosition() != -1 ) {
- GetActiveHead().Set(jump_location);
- return true;
- }
-
- // If complement label was not found; record an error.
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
- "jump-f: No complement label");
- return false;
-}
-
-bool cHardware4Stack::Inst_JumpB()
-{
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- // If there is no label, jump BX steps.
- if (GetLabel().GetSize() == 0) {
- GetActiveHead().Jump(-Register(REG_BX));
- return true;
- }
-
- // otherwise jump to the complement label.
- const cCPUHead jump_location(FindLabel(-1));
- if ( jump_location.GetPosition() != -1 ) {
- GetActiveHead().Set(jump_location);
- return true;
- }
-
- // If complement label was not found; record an error.
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
- "jump-b: No complement label");
- return false;
-}
-
-bool cHardware4Stack::Inst_JumpP()
-{
- cOrganism * other_organism = organism->GetNeighbor();
-
- // Make sure the other organism was found and that its hardware is of the
- // same type, or else we won't be able to be parasitic on it.
- if (other_organism == NULL ||
- other_organism->GetHardware().GetType() != GetType()) {
- // Without another organism, its hard to determine if we're dealing
- // with a parasite. For the moment, we'll assume it is and move on.
- // @CAO Do better!
- organism->GetPhenotype().IsParasite() = true;
- return true;
- }
-
- // Otherwise, grab the hardware from the neighbor, and use it!
- cHardware4Stack & other_hardware = (cHardware4Stack &) other_organism->GetHardware();
-
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- // If there is no label, jump to line BX in creature.
- if (GetLabel().GetSize() == 0) {
- const int new_pos = Register(REG_BX);
- IP().Set(new_pos, &other_hardware);
- organism->GetPhenotype().IsParasite() = true;
- return true;
- }
-
- // otherwise jump to the complement label.
- const cCPUHead jump_location(other_hardware.FindFullLabel(GetLabel()));
- if (jump_location.GetPosition() != -1) {
- IP().Set(jump_location);
- organism->GetPhenotype().IsParasite() = true;
- return true;
- }
-
- // If complement label was not found; record a warning (since the
- // actual neighbors are not under the organisms control, this is not
- // a full-scale error).
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_WARNING,
- "jump-p: No complement label");
- return false;
-}
-
-bool cHardware4Stack::Inst_JumpSelf()
-{
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- // If there is no label, jump to line BX in creature.
- if (GetLabel().GetSize() == 0) {
- IP().Set(Register(REG_BX), this);
- return true;
- }
-
- // otherwise jump to the complement label.
- const cCPUHead jump_location( FindFullLabel(GetLabel()) );
- if ( jump_location.GetPosition() != -1 ) {
- IP().Set(jump_location);
- return true;
- }
-
- // If complement label was not found; record an error.
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
- "jump-slf: no complement label");
- return false;
-}
-
-bool cHardware4Stack::Inst_Call()
-{
- // Put the starting location onto the stack
- const int location = IP().GetPosition();
- StackPush(location);
-
- // Jump to the compliment label (or by the ammount in the bx register)
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- if (GetLabel().GetSize() == 0) {
- IP().Jump(Register(REG_BX));
- return true;
- }
-
- const cCPUHead jump_location(FindLabel(1));
- if (jump_location.GetPosition() != -1) {
- IP().Set(jump_location);
- return true;
- }
-
- // If complement label was not found; record an error.
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
- "call: no complement label");
- return false;
-}
-
-bool cHardware4Stack::Inst_Return()
-{
- IP().Set(StackPop());
- return true;
-}
-
-bool cHardware4Stack::Inst_Pop()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = StackPop();
- return true;
-}
-
-bool cHardware4Stack::Inst_Push()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- StackPush(Register(reg_used));
+ else AdvanceIP() = false;
return true;
}
-bool cHardware4Stack::Inst_PopA() { Register(REG_AX) = StackPop(); return true;}
-bool cHardware4Stack::Inst_PopB() { Register(REG_BX) = StackPop(); return true;}
-bool cHardware4Stack::Inst_PopC() { Register(REG_CX) = StackPop(); return true;}
-
-bool cHardware4Stack::Inst_SwitchStack() { SwitchStack(); return true;}
-bool cHardware4Stack::Inst_FlipStack() { StackFlip(); return true;}
-
-bool cHardware4Stack::Inst_Swap()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int other_reg = FindComplementRegister(reg_used);
- Swap(Register(reg_used), Register(other_reg));
- return true;
-}
-
-bool cHardware4Stack::Inst_SwapAB() { Swap(Register(REG_AX), Register(REG_BX)); return true; }
-bool cHardware4Stack::Inst_SwapBC() { Swap(Register(REG_BX), Register(REG_CX)); return true; }
-bool cHardware4Stack::Inst_SwapAC() { Swap(Register(REG_AX), Register(REG_CX)); return true; }
-
-bool cHardware4Stack::Inst_CopyRegAB() { Register(REG_AX) = Register(REG_BX); return true;
-}
-bool cHardware4Stack::Inst_CopyRegAC() { Register(REG_AX) = Register(REG_CX); return true;
-}
-bool cHardware4Stack::Inst_CopyRegBA() { Register(REG_BX) = Register(REG_AX); return true;
-}
-bool cHardware4Stack::Inst_CopyRegBC() { Register(REG_BX) = Register(REG_CX); return true;
-}
-bool cHardware4Stack::Inst_CopyRegCA() { Register(REG_CX) = Register(REG_AX); return true;
-}
-bool cHardware4Stack::Inst_CopyRegCB() { Register(REG_CX) = Register(REG_BX); return true;
-}
-
-bool cHardware4Stack::Inst_Reset()
-{
- Register(REG_AX) = 0;
- Register(REG_BX) = 0;
- Register(REG_CX) = 0;
- StackClear();
- return true;
-}
-
-bool cHardware4Stack::Inst_Bit1()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) |= 1;
- return true;
-}
-
-bool cHardware4Stack::Inst_SetNum()
-{
- ReadLabel();
- Register(REG_BX) = GetLabel().AsInt();
- return true;
-}
-
-bool cHardware4Stack::Inst_Zero()
+//36
+bool cHardware4Stack::Inst_IO()
{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = 0;
- return true;
-}
+ const int stack_used = FindModifiedStack(STACK_BX);
-bool cHardware4Stack::Inst_Neg()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = 0-Register(reg_used);
- return true;
-}
+ // Do the "put" component
+ const int value_out = Stack(stack_used).Top();
+ DoOutput(value_out); // Check for tasks compleated.
-bool cHardware4Stack::Inst_Square()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = Register(reg_used) * Register(reg_used);
+ // Do the "get" component
+ const int value_in = organism->GetInputAt(threads[GetCurThread()].input_pointer);
+ Stack(stack_used).Push(value_in);
+ DoInput(value_in);
return true;
}
-bool cHardware4Stack::Inst_Sqrt()
+int cHardware4Stack::FindFirstEmpty()
{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int value = Register(reg_used);
- if (value > 1) Register(reg_used) = (int) sqrt((double) value);
- else if (value < 0) {
- Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "sqrt: value is negative");
- return false;
- }
- return true;
-}
+ bool OK=true;
+ const int current_mem_space = IP().GetMemSpace();
-bool cHardware4Stack::Inst_Log()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int value = Register(reg_used);
- if (value >= 1) Register(reg_used) = (int) log((double) value);
- else if (value < 0) {
- Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "log: value is negative");
- return false;
- }
- return true;
-}
+ for(int x=1; x<NUM_MEMORY_SPACES; x++)
+ {
+ OK=true;
+
+ int index = (current_mem_space+x) % NUM_MEMORY_SPACES;
-bool cHardware4Stack::Inst_Log10()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int value = Register(reg_used);
- if (value >= 1) Register(reg_used) = (int) log10((double) value);
- else if (value < 0) {
- Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "log10: value is negative");
- return false;
- }
- return true;
+ for(int y=0; y<GetMemory(index).GetSize() && OK; y++)
+ {
+ if(GetMemory(index)[y].GetOp() >= NUM_NOPS_4STACK)
+ OK=false;
+ }
+ for(int y=0; y<GetNumThreads() && OK; y++)
+ {
+ for(int z=0; z<NUM_HEADS; z++)
+ {
+ if(threads[y].heads[z].GetMemSpace() == index)
+ OK=false;
+ }
+ }
+ if(OK)
+ return index;
+ }
+ return -1;
}
-bool cHardware4Stack::Inst_Minus18()
+bool cHardware4Stack::isEmpty(int mem_space_used)
{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) -= 18;
+ for(int x=0; x<GetMemory(mem_space_used).GetSize(); x++)
+ {
+ if(GetMemory(mem_space_used)[x].GetOp() >= NUM_NOPS_4STACK)
+ return false;
+ }
return true;
}
-bool cHardware4Stack::Inst_Nor()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = ~(Register(REG_BX) | Register(REG_CX));
- return true;
-}
+// The inject instruction can be used instead of a divide command, paired
+// with an allocate. Note that for an inject to work, one needs to have a
+// broad range for sizes allowed to be allocated.
+//
+// This command will cut out from read-head to write-head.
+// It will then look at the template that follows the command and inject it
+// into the complement template found in a neighboring organism.
-bool cHardware4Stack::Inst_And()
+bool cHardware4Stack::Inst_Inject()
{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = (Register(REG_BX) & Register(REG_CX));
- return true;
-}
+ const int mem_space_used = GetHead(HEAD_WRITE).GetMemSpace();
+ double mut_multiplier = 1;
-bool cHardware4Stack::Inst_Not()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = ~(Register(reg_used));
- return true;
+ return Inject_Parasite(mem_space_used, mut_multiplier);
}
-bool cHardware4Stack::Inst_Order()
-{
- if (Register(REG_BX) > Register(REG_CX)) {
- Swap(Register(REG_BX), Register(REG_CX));
- }
- return true;
-}
-bool cHardware4Stack::Inst_Xor()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = Register(REG_BX) ^ Register(REG_CX);
- return true;
-}
-bool cHardware4Stack::Inst_Copy()
+/*
+bool cHardware4Stack::Inst_InjectRand()
{
- const cCPUHead from(this, Register(REG_BX));
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
- sCPUStats & cpu_stats = organism->CPUStats();
-
- if (organism->TestCopyMut()) {
- to.SetInst(GetRandomInst());
- to.FlagMutated() = true; // Mark this instruction as mutated...
- to.FlagCopyMut() = true; // Mark this instruction as copy mut...
- //organism->GetPhenotype().IsMutated() = true;
- cpu_stats.mut_stats.copy_mut_count++;
- } else {
- to.SetInst(from.GetInst());
- to.FlagMutated() = false; // UnMark
- to.FlagCopyMut() = false; // UnMark
- }
-
- to.FlagCopied() = true; // Set the copied flag.
- cpu_stats.mut_stats.copies_exec++;
+ // Rotate to a random facing and then run the normal inject instruction
+ const int num_neighbors = organism->GetNeighborhoodSize();
+ organism->Rotate(g_random.GetUInt(num_neighbors));
+ Inst_Inject();
return true;
}
-bool cHardware4Stack::Inst_ReadInst()
-{
- const int reg_used = FindModifiedRegister(REG_CX);
- const cCPUHead from(this, Register(REG_BX));
-
- // Dis-allowing mutations on read, for the moment (write only...)
- // @CAO This allows perfect error-correction...
- Register(reg_used) = from.GetInst().GetOp();
- return true;
-}
-
-bool cHardware4Stack::Inst_WriteInst()
-{
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
- const int reg_used = FindModifiedRegister(REG_CX);
- const int value = Mod(Register(reg_used), GetNumInst());
- sCPUStats & cpu_stats = organism->CPUStats();
-
- // Change value on a mutation...
- if (organism->TestCopyMut()) {
- to.SetInst(GetRandomInst());
- to.FlagMutated() = true; // Mark this instruction as mutated...
- to.FlagCopyMut() = true; // Mark this instruction as copy mut...
- //organism->GetPhenotype().IsMutated() = true;
- cpu_stats.mut_stats.copy_mut_count++;
- } else {
- to.SetInst(cInstruction(value));
- to.FlagMutated() = false; // UnMark
- to.FlagCopyMut() = false; // UnMark
- }
-
- to.FlagCopied() = true; // Set the copied flag.
- cpu_stats.mut_stats.copies_exec++;
- return true;
-}
-
-bool cHardware4Stack::Inst_StackReadInst()
-{
- const int reg_used = FindModifiedRegister(REG_CX);
- cCPUHead from(this, Register(reg_used));
- StackPush(from.GetInst().GetOp());
- return true;
-}
-
-bool cHardware4Stack::Inst_StackWriteInst()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- cCPUHead to(this, Register(REG_AX) + Register(reg_used));
- const int value = Mod(StackPop(), GetNumInst());
- sCPUStats & cpu_stats = organism->CPUStats();
-
- // Change value on a mutation...
- if (organism->TestCopyMut()) {
- to.SetInst(GetRandomInst());
- to.FlagMutated() = true; // Mark this instruction as mutated...
- to.FlagCopyMut() = true; // Mark this instruction as copy mut...
- //organism->GetPhenotype().IsMutated() = true;
- cpu_stats.mut_stats.copy_mut_count++;
- } else {
- to.SetInst(cInstruction(value));
- to.FlagMutated() = false; // UnMark
- to.FlagCopyMut() = false; // UnMark
- }
-
- to.FlagCopied() = true; // Set the copied flag.
- cpu_stats.mut_stats.copies_exec++;
- return true;
-}
-
-bool cHardware4Stack::Inst_Compare()
-{
- const int reg_used = FindModifiedRegister(REG_CX);
- cCPUHead from(this, Register(REG_BX));
- cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
-
- // Compare is dangerous -- it can cause mutations!
- if (organism->TestCopyMut()) {
- to.SetInst(GetRandomInst());
- to.FlagMutated() = true; // Mark this instruction as mutated...
- to.FlagCopyMut() = true; // Mark this instruction as copy mut...
- //organism->GetPhenotype().IsMutated() = true;
- }
-
- Register(reg_used) = from.GetInst().GetOp() - to.GetInst().GetOp();
-
- return true;
-}
-
-bool cHardware4Stack::Inst_IfNCpy()
-{
- const cCPUHead from(this, Register(REG_BX));
- const cCPUHead to(this, Register(REG_AX) + Register(REG_BX));
-
- // Allow for errors in this test...
- if (organism->TestCopyMut()) {
- if (from.GetInst() != to.GetInst()) IP().Advance();
- } else {
- if (from.GetInst() == to.GetInst()) IP().Advance();
- }
- return true;
-}
-
-bool cHardware4Stack::Inst_Allocate() // Allocate bx more space...
-{
- const int size = GetMemory().GetSize();
- if( Allocate_Main(Register(REG_BX)) ) {
- Register(REG_AX) = size;
- return true;
- } else return false;
-}
-
-bool cHardware4Stack::Inst_Divide()
-{
- return Divide_Main(Register(REG_AX));
-}
-
-bool cHardware4Stack::Inst_CDivide()
-{
- return Divide_Main(GetMemory().GetSize() / 2);
-}
-
-bool cHardware4Stack::Inst_CAlloc()
-{
- return Allocate_Main(GetMemory().GetSize());
-}
-
-bool cHardware4Stack::Inst_Repro()
-{
- // Setup child
- cCPUMemory & child_genome = organism->ChildGenome();
- child_genome = GetMemory();
- organism->GetPhenotype().SetLinesCopied(GetMemory().GetSize());
-
- int lines_executed = 0;
- for ( int i = 0; i < GetMemory().GetSize(); i++ ) {
- if ( GetMemory().FlagExecuted(i) == true ) lines_executed++;
- }
- organism->GetPhenotype().SetLinesExecuted(lines_executed);
-
- // Perform Copy Mutations...
- if (organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
- for (int i = 0; i < GetMemory().GetSize(); i++) {
- if (organism->TestCopyMut()) {
- child_genome[i]=GetRandomInst();
- //organism->GetPhenotype().IsMutated() = true;
- }
- }
- }
- Divide_DoMutations();
-
- // Many tests will require us to run the offspring through a test CPU;
- // this is, for example, to see if mutations need to be reverted or if
- // lineages need to be updated.
- Divide_TestFitnessMeasures();
-
-#ifdef INSTRUCTION_COSTS
- // reset first time instruction costs
- for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
- inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
- }
-#endif
-
- if (cConfig::GetDivideMethod() == DIVIDE_METHOD_SPLIT) advance_ip = false;
-
- organism->ActivateDivide();
-
- return true;
-}
-
-// The inject instruction can be used instead of a divide command, paired
-// with an allocate. Note that for an inject to work, one needs to have a
-// broad range for sizes allowed to be allocated.
-//
-// This command will cut out from read-head to write-head.
-// It will then look at the template that follows the command and inject it
-// into the complement template found in a neighboring organism.
-
-bool cHardware4Stack::Inst_Inject()
-{
- AdjustHeads();
- const int start_pos = GetHead(HEAD_READ).GetPosition();
- const int end_pos = GetHead(HEAD_WRITE).GetPosition();
- const int inject_size = end_pos - start_pos;
-
- // Make sure the creature will still be above the minimum size,
- if (inject_size <= 0) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: no code to inject");
- return false; // (inject fails)
- }
- if (start_pos < MIN_CREATURE_SIZE) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
- return false; // (inject fails)
- }
-
- // Since its legal to cut out the injected piece, do so.
- cGenome inject_code( cGenomeUtil::Crop(GetMemory(), start_pos, end_pos) );
- GetMemory().Remove(start_pos, inject_size);
-
- // If we don't have a host, stop here.
- cOrganism * host_organism = organism->GetNeighbor();
- if (host_organism == NULL) return false;
-
- // Scan for the label to match...
- ReadLabel();
-
- // If there is no label, abort.
- if (GetLabel().GetSize() == 0) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: label required");
- return false; // (inject fails)
- }
-
- // Search for the label in the host...
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- const int inject_signal =
- host_organism->GetHardware().Inject(GetLabel(), inject_code);
- if (inject_signal == 1) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: host too large.");
- return false; // Inject failed.
- }
- if (inject_signal == 2) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: target not in host.");
- return false; // Inject failed.
- }
-
- // Set the relevent flags.
- organism->GetPhenotype().IsModifier() = true;
-
- return true;
-}
-
-bool cHardware4Stack::Inst_InjectRand()
-{
- // Rotate to a random facing and then run the normal inject instruction
- const int num_neighbors = organism->GetNeighborhoodSize();
- organism->Rotate(g_random.GetUInt(num_neighbors));
- Inst_Inject();
- return true;
-}
-
-// The inject instruction can be used instead of a divide command, paired
-// with an allocate. Note that for an inject to work, one needs to have a
-// broad range for sizes allowed to be allocated.
-//
-// This command will cut out from read-head to write-head.
-// It will then look at the template that follows the command and inject it
-// into the complement template found in a neighboring organism.
-
-bool cHardware4Stack::Inst_InjectThread()
-{
- AdjustHeads();
- const int start_pos = GetHead(HEAD_READ).GetPosition();
- const int end_pos = GetHead(HEAD_WRITE).GetPosition();
- const int inject_size = end_pos - start_pos;
-
- // Make sure the creature will still be above the minimum size,
- if (inject_size <= 0) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: no code to inject");
- return false; // (inject fails)
- }
- if (start_pos < MIN_CREATURE_SIZE) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
- return false; // (inject fails)
- }
-
- // Since its legal to cut out the injected piece, do so.
- cGenome inject_code( cGenomeUtil::Crop(GetMemory(), start_pos, end_pos) );
- GetMemory().Remove(start_pos, inject_size);
-
- // If we don't have a host, stop here.
- cOrganism * host_organism = organism->GetNeighbor();
- if (host_organism == NULL) return false;
-
- // Scan for the label to match...
- ReadLabel();
-
- // If there is no label, abort.
- if (GetLabel().GetSize() == 0) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: label required");
- return false; // (inject fails)
- }
-
- // Search for the label in the host...
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
-
- const int inject_signal =
- host_organism->GetHardware().InjectThread(GetLabel(), inject_code);
- if (inject_signal == 1) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: host too large.");
- return false; // Inject failed.
- }
- if (inject_signal == 2) {
- Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: target not in host.");
- return false; // Inject failed.
- }
-
- // Set the relevent flags.
- organism->GetPhenotype().IsModifier() = true;
-
- return true;
-}
-
-bool cHardware4Stack::Inst_TaskGet()
-{
- const int reg_used = FindModifiedRegister(REG_CX);
- const int value = organism->GetInput();
- Register(reg_used) = value;
- DoInput(value);
- return true;
-}
-
-bool cHardware4Stack::Inst_TaskStackGet()
-{
- const int value = organism->GetInput();
- StackPush(value);
- DoInput(value);
- return true;
-}
-
-bool cHardware4Stack::Inst_TaskStackLoad()
-{
- for (int i = 0; i < IO_SIZE; i++) StackPush( organism->GetInput() );
- return true;
-}
-
-bool cHardware4Stack::Inst_TaskPut()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int value = Register(reg_used);
- Register(reg_used) = 0;
- DoOutput(value);
- return true;
-}
-
-bool cHardware4Stack::Inst_TaskIO()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
-
- // Do the "put" component
- const int value_out = Register(reg_used);
- DoOutput(value_out); // Check for tasks compleated.
-
- // Do the "get" component
- const int value_in = organism->GetInput();
- Register(reg_used) = value_in;
- DoInput(value_in);
- return true;
-}
-
-bool cHardware4Stack::Inst_SearchF()
-{
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
- const int search_size = FindLabel(1).GetPosition() - IP().GetPosition();
- Register(REG_BX) = search_size;
- Register(REG_CX) = GetLabel().GetSize();
- return true;
-}
-
-bool cHardware4Stack::Inst_SearchB()
-{
- ReadLabel();
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
- const int search_size = IP().GetPosition() - FindLabel(-1).GetPosition();
- Register(REG_BX) = search_size;
- Register(REG_CX) = GetLabel().GetSize();
- return true;
-}
-
-bool cHardware4Stack::Inst_MemSize()
-{
- Register(FindModifiedRegister(REG_BX)) = GetMemory().GetSize();
- return true;
-}
-
-
-bool cHardware4Stack::Inst_RotateL()
-{
- const int num_neighbors = organism->GetNeighborhoodSize();
-
- // If this organism has no neighbors, ignore rotate.
- if (num_neighbors == 0) return false;
-
- ReadLabel();
-
- // Always rotate at least once.
- organism->Rotate(-1);
-
- // If there is no label, then the one rotation was all we want.
- if (!GetLabel().GetSize()) return true;
-
- // Rotate until a complement label is found (or all have been checked).
- GetLabel().Rotate(2, NUM_NOPS_4STACK);
- for (int i = 1; i < num_neighbors; i++) {
- cOrganism * neighbor = organism->GetNeighbor();
-
- // Assuming we have a neighbor and it is of the same hardware type,
- // search for the label in it.
- if (neighbor != NULL &&
- neighbor->GetHardware().GetType() == GetType()) {
-
- // If this facing has the full label, stop here.
- cHardware4Stack & cur_hardware = (cHardware4Stack &) neighbor->GetHardware();
- if (cur_hardware.FindFullLabel( GetLabel() ).InMemory()) return true;
- }
-
- // Otherwise keep rotating...
- organism->Rotate(-1);
- }
- return true;
-}
-
-bool cHardware4Stack::Inst_RotateR()
-{
- const int num_neighbors = organism->GetNeighborhoodSize();
-
- // If this organism has no neighbors, ignore rotate.
- if (num_neighbors == 0) return false;
-
- ReadLabel();
-
- // Always rotate at least once.
- organism->Rotate(-1);
-
- // If there is no label, then the one rotation was all we want.
- if (!GetLabel().GetSize()) return true;
-
- // Rotate until a complement label is found (or all have been checked).
- GetLabel().Rotate(2, NUM_NOPS_4STACK)S;
- for (int i = 1; i < num_neighbors; i++) {
- cOrganism * neighbor = organism->GetNeighbor();
-
- // Assuming we have a neighbor and it is of the same hardware type,
- // search for the label in it.
- if (neighbor != NULL &&
- neighbor->GetHardware().GetType() == GetType()) {
-
- // If this facing has the full label, stop here.
- cHardware4Stack & cur_hardware = (cHardware4Stack &) neighbor->GetHardware();
- if (cur_hardware.FindFullLabel( GetLabel() ).InMemory()) return true;
- }
-
- // Otherwise keep rotating...
- organism->Rotate(1);
- }
- return true;
-}
-
-bool cHardware4Stack::Inst_SetCopyMut()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const int new_mut_rate = Max( Register(reg_used), 1 );
- organism->SetCopyMutProb(((double) new_mut_rate) / 10000.0);
- return true;
-}
-
-bool cHardware4Stack::Inst_ModCopyMut()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- const double new_mut_rate = organism->GetCopyMutProb() +
- ((double) Register(reg_used)) / 10000.0;
- if (new_mut_rate > 0.0) organism->SetCopyMutProb(new_mut_rate);
- return true;
-}
-// Multi-threading.
-
-bool cHardware4Stack::Inst_ThreadID()
-{
- const int reg_used = FindModifiedRegister(REG_BX);
- Register(reg_used) = GetCurThreadID();
- return true;
-}
-
-
-// Head-based instructions
-bool cHardware4Stack::Inst_SetHead()
-{
- const int head_used = FindModifiedHead(HEAD_IP);
- SetActiveHead(head_used);
- return true;
-}
-
-bool cHardware4Stack::Inst_AdvanceHead()
-{
- const int head_used = FindModifiedHead(HEAD_WRITE);
- GetHead(head_used).Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_JumpHead()
-{
- const int head_used = FindModifiedHead(HEAD_IP);
- GetHead(head_used).Jump( Register(REG_CX) );
- return true;
-}
-
-bool cHardware4Stack::Inst_GetHead()
-{
- const int head_used = FindModifiedHead(HEAD_IP);
- Register(REG_CX) = GetHead(head_used).GetPosition();
- return true;
-}
-
-bool cHardware4Stack::Inst_HeadDivideSex()
-{
- organism->GetPhenotype().SetDivideSex(true);
- return Inst_HeadDivide();
-}
-
-bool cHardware4Stack::Inst_HeadDivideAsex()
-{
- organism->GetPhenotype().SetDivideSex(false);
- return Inst_HeadDivide();
-}
-
-bool cHardware4Stack::Inst_HeadDivide1() { return Inst_HeadDivideMut(1); }
-bool cHardware4Stack::Inst_HeadDivide2() { return Inst_HeadDivideMut(2); }
-bool cHardware4Stack::Inst_HeadDivide3() { return Inst_HeadDivideMut(3); }
-bool cHardware4Stack::Inst_HeadDivide4() { return Inst_HeadDivideMut(4); }
-bool cHardware4Stack::Inst_HeadDivide5() { return Inst_HeadDivideMut(5); }
-bool cHardware4Stack::Inst_HeadDivide6() { return Inst_HeadDivideMut(6); }
-bool cHardware4Stack::Inst_HeadDivide7() { return Inst_HeadDivideMut(7); }
-bool cHardware4Stack::Inst_HeadDivide8() { return Inst_HeadDivideMut(8); }
-bool cHardware4Stack::Inst_HeadDivide9() { return Inst_HeadDivideMut(9); }
-bool cHardware4Stack::Inst_HeadDivide10() { return Inst_HeadDivideMut(10); }
-bool cHardware4Stack::Inst_HeadDivide16() { return Inst_HeadDivideMut(16); }
-bool cHardware4Stack::Inst_HeadDivide32() { return Inst_HeadDivideMut(32); }
-bool cHardware4Stack::Inst_HeadDivide50() { return Inst_HeadDivideMut(50); }
-bool cHardware4Stack::Inst_HeadDivide100() { return Inst_HeadDivideMut(100); }
-bool cHardware4Stack::Inst_HeadDivide500() { return Inst_HeadDivideMut(500); }
-bool cHardware4Stack::Inst_HeadDivide1000() { return Inst_HeadDivideMut(1000); }
-bool cHardware4Stack::Inst_HeadDivide5000() { return Inst_HeadDivideMut(5000); }
-bool cHardware4Stack::Inst_HeadDivide10000() { return Inst_HeadDivideMut(10000); }
-bool cHardware4Stack::Inst_HeadDivide50000() { return Inst_HeadDivideMut(50000); }
-bool cHardware4Stack::Inst_HeadDivide0_5() { return Inst_HeadDivideMut(0.5); }
-bool cHardware4Stack::Inst_HeadDivide0_1() { return Inst_HeadDivideMut(0.1); }
-bool cHardware4Stack::Inst_HeadDivide0_05() { return Inst_HeadDivideMut(0.05); }
-bool cHardware4Stack::Inst_HeadDivide0_01() { return Inst_HeadDivideMut(0.01); }
-bool cHardware4Stack::Inst_HeadDivide0_001() { return Inst_HeadDivideMut(0.001); }
-
-bool cHardware4Stack::HeadCopy_ErrorCorrect(double reduction)
-{
- // For the moment, this cannot be nop-modified.
- cCPUHead & read_head = GetHead(HEAD_READ);
- cCPUHead & write_head = GetHead(HEAD_WRITE);
- sCPUStats & cpu_stats = organism->CPUStats();
-
- read_head.Adjust();
- write_head.Adjust();
-
- // Do mutations.
- cInstruction read_inst = read_head.GetInst();
- if ( g_random.P(organism->GetCopyMutProb() / reduction) ) {
- read_inst = GetRandomInst();
- cpu_stats.mut_stats.copy_mut_count++;
- write_head.FlagMutated() = true;
- write_head.FlagCopyMut() = true;
- //organism->GetPhenotype().IsMutated() = true;
- }
- ReadInst(read_inst.GetOp());
-
- cpu_stats.mut_stats.copies_exec++;
-
- write_head.SetInst(read_inst);
- write_head.FlagCopied() = true; // Set the copied flag...
-
- read_head.Advance();
- write_head.Advance();
- return true;
-}
-
-bool cHardware4Stack::Inst_HeadCopy2() { return HeadCopy_ErrorCorrect(2); }
-bool cHardware4Stack::Inst_HeadCopy3() { return HeadCopy_ErrorCorrect(3); }
-bool cHardware4Stack::Inst_HeadCopy4() { return HeadCopy_ErrorCorrect(4); }
-bool cHardware4Stack::Inst_HeadCopy5() { return HeadCopy_ErrorCorrect(5); }
-bool cHardware4Stack::Inst_HeadCopy6() { return HeadCopy_ErrorCorrect(6); }
-bool cHardware4Stack::Inst_HeadCopy7() { return HeadCopy_ErrorCorrect(7); }
-bool cHardware4Stack::Inst_HeadCopy8() { return HeadCopy_ErrorCorrect(8); }
-bool cHardware4Stack::Inst_HeadCopy9() { return HeadCopy_ErrorCorrect(9); }
-bool cHardware4Stack::Inst_HeadCopy10() { return HeadCopy_ErrorCorrect(10); }
-
-bool cHardware4Stack::Inst_SetFlow()
-{
- const int reg_used = FindModifiedRegister(REG_CX);
- GetHead(HEAD_FLOW).Set(Register(reg_used), this);
- return true;
-}
-
-// Direct Matching Templates
-
-bool cHardware4Stack::Inst_DMJumpF()
-{
- ReadLabel();
-
- // If there is no label, jump BX steps.
- if (GetLabel().GetSize() == 0) {
- IP().Jump(Register(REG_BX));
- return true;
- }
-
- // Otherwise, jump to the label.
- cCPUHead jump_location(FindLabel(1));
- if (jump_location.GetPosition() != -1) {
- IP().Set(jump_location);
- return true;
- }
-
- // If complement label was not found; record an error.
- organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
- "dm-jump-f: no complement label");
- return false;
-}
-
-//// Placebo insts ////
-bool cHardware4Stack::Inst_Skip()
-{
- IP().Advance();
- return true;
-}
*/
-
Index: avida/current/source/cpu/hardware_4stack.hh
diff -u avida/current/source/cpu/hardware_4stack.hh:1.2.4.2 avida/current/source/cpu/hardware_4stack.hh:1.2.4.3
--- avida/current/source/cpu/hardware_4stack.hh:1.2.4.2 Thu May 29 11:21:00 2003
+++ avida/current/source/cpu/hardware_4stack.hh Tue Aug 19 10:49:29 2003
@@ -20,6 +20,7 @@
#include "cpu_defs.hh"
#include "label.hh"
#include "head.hh"
+#include "../main/config.hh"
class cInstSet;
class cInstLibBase;
@@ -27,33 +28,33 @@
class cMutation;
//new-style constant declarations - law
-static const int NUM_LOCAL_STACKS = 2;
-static const int NUM_GLOBAL_STACKS = 2;
+static const int NUM_LOCAL_STACKS = 3;
+static const int NUM_GLOBAL_STACKS = 1;
static const int NUM_STACKS = NUM_LOCAL_STACKS + NUM_GLOBAL_STACKS;
static const int STACK_AX = 0;
static const int STACK_BX = 1;
static const int STACK_CX = 2;
static const int STACK_DX = 3;
static const int NUM_NOPS_4STACK = 4;
+static const int NUM_MEMORY_SPACES = 4;
/**
* This class is needed to run several threads on a single genome.
*
- * @see cCPUStack, cCPUHead, cHardware4Stack
+ * @see cCPUStack, c4StackHead, cHardware4Stack
**/
struct cHardware4Stack_Thread {
private:
int id;
+
public:
- int reg[NUM_REG_4STACK];
- cCPUHead heads[NUM_HEADS];
- cCPUStack stack;
- UCHAR cur_stack; // 0 = local stack, 1 = global stack.
+ c4StackHead heads[NUM_HEADS];
UCHAR cur_head;
cCPUStack local_stacks[NUM_LOCAL_STACKS];
- UCHAR input_pointer;
+ int input_pointer;
+ bool advance_ip; // Should the IP advance after this instruction?
tBuffer<int> input_buf;
tBuffer<int> output_buf;
cCodeLabel read_label;
@@ -95,18 +96,18 @@
static cInstLib4Stack *initInstLib(void);
tHardware4StackMethod *m_functions;
private:
- cCPUMemory memory; // Memory...
- cCPUStack global_stack; // A stack that all threads share.
+ tArray<cCPUMemory> memory_array; // Memory...
+ //cCPUStack global_stack; // A stack that all threads share.
cCPUStack global_stacks[NUM_GLOBAL_STACKS];
- int thread_time_used;
+ //int thread_time_used;
tArray<cHardware4Stack_Thread> threads;
int thread_id_chart;
int cur_thread;
// Flags...
- bool mal_active; // Has an allocate occured since last divide?
- bool advance_ip; // Should the IP advance after this instruction?
+ bool mal_active; // Has an allocate occured since last dividehe?
+ //bool advance_ip; // Should the IP advance after this instruction?
// Instruction costs...
#ifdef INSTRUCTION_COSTS
@@ -114,6 +115,15 @@
tArray<int> inst_ft_cost;
#endif
+ // Thread slicing...
+
+ // Keeps track of the base thread slicing number for each possible number of threads
+ float slice_array[10]; //***HACK! How do I do this right? -law
+ //this wouldn't compile -> [cConfig::GetMaxCPUThreads()+1]***;
+
+ // Keeps track of fractional instructions that carry over into next update
+ float inst_remainder;
+
public:
cHardware4Stack(cOrganism * in_organism, cInstSet * in_inst_set);
~cHardware4Stack();
@@ -137,15 +147,16 @@
bool GetMalActive() const { return mal_active; }
// -------- Stack Manipulation... --------
- inline void StackPush(int value);
- inline int StackPop();
inline void StackFlip();
- inline int GetStack(int depth=0, int stack_id=-1) const;
+ inline int GetStack(int depth=0, int stack_id=-1, int in_thread=-1) const;
inline void StackClear();
inline void SwitchStack();
- int GetActiveStackID() const { return threads[cur_thread].cur_stack; }
- //NEW STUFF
- inline cCPUStack & Stack(int stack_id); //retrieves appropriate stack
+ cString GetActiveStackID(int stackID) const;
+ //retrieves appropriate stack
+ inline cCPUStack & Stack(int stack_id);
+ inline const cCPUStack & Stack(int stack_id) const;
+ inline cCPUStack & Stack(int stack_id, int in_thread);
+ inline const cCPUStack & Stack(int stack_id, int in_thread) const;
// -------- Tasks & IO --------
tBuffer<int> & GetInputBuffer() { return threads[cur_thread].input_buf; }
@@ -158,20 +169,36 @@
{ threads[cur_thread].cur_head = (UCHAR) new_head; }
int GetCurHead() const { return threads[cur_thread].cur_head; }
- const cCPUHead & GetHead(int head_id) const
- { return threads[cur_thread].heads[head_id]; }
- cCPUHead & GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
+
+ const c4StackHead & GetHead(int head_id) const
+ { return threads[cur_thread].heads[head_id]; }
+ c4StackHead & GetHead(int head_id)
+ { return threads[cur_thread].heads[head_id];}
+
+ const c4StackHead & GetHead(int head_id, int thread) const
+ { return threads[thread].heads[head_id]; }
+ c4StackHead & GetHead(int head_id, int thread)
+ { return threads[thread].heads[head_id];}
- const cCPUHead & GetActiveHead() const { return GetHead(GetCurHead()); }
- cCPUHead & GetActiveHead() { return GetHead(GetCurHead()); }
+ const c4StackHead & GetActiveHead() const { return GetHead(GetCurHead()); }
+ c4StackHead & GetActiveHead() { return GetHead(GetCurHead()); }
void AdjustHeads();
- inline const cCPUHead & IP() const
+ inline const c4StackHead & IP() const
{ return threads[cur_thread].heads[HEAD_IP]; }
- inline cCPUHead & IP() { return threads[cur_thread].heads[HEAD_IP]; }
+ inline c4StackHead & IP() { return threads[cur_thread].heads[HEAD_IP]; }
+
+ inline const c4StackHead & IP(int thread) const
+ { return threads[thread].heads[HEAD_IP]; }
+ inline c4StackHead & IP(int thread)
+ { return threads[thread].heads[HEAD_IP]; }
+ inline const bool & AdvanceIP() const
+ { return threads[cur_thread].advance_ip; }
+ inline bool & AdvanceIP() { return threads[cur_thread].advance_ip; }
+
// -------- Label Manipulation -------
void ReadLabel(int max_size=MAX_LABEL_SIZE);
const cCodeLabel & GetLabel() const
@@ -183,12 +210,14 @@
// -------- Register Manipulation --------
- int Register(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
- int & Register(int reg_id) { return threads[cur_thread].reg[reg_id]; }
+ //int Register(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
+ //int & Register(int reg_id) { return threads[cur_thread].reg[reg_id]; }
- // -------- Memory Manipulation --------
- inline const cCPUMemory & Memory() const { return memory; }
- inline cCPUMemory & Memory() { return memory; }
+ // -------- Memory Manipulation --------}
+ inline cCPUMemory & GetMemory();
+ inline cCPUMemory & GetMemory(int mem_space);
+ inline const cCPUMemory & GetMemory(int mem_space) const;
+ inline const cCPUMemory & GetMemory() const;
// -------- Thread Manipulation --------
bool ForkThread(); // Adds a new thread based off of cur_thread.
@@ -202,10 +231,7 @@
int TestParasite() const;
// -------- Accessors --------
- const cCPUMemory & GetMemory() const { return memory; }
- cCPUMemory & GetMemory() { return memory; }
-
- int GetThreadTimeUsed() const { return thread_time_used; }
+ //int GetThreadTimeUsed() const { return thread_time_used; }
int GetNumThreads() const { return threads.GetSize(); }
int GetCurThread() const { return cur_thread; }
int GetCurThreadID() const { return threads[cur_thread].GetID(); }
@@ -217,32 +243,33 @@
}
// Complex label manipulation...
- cCPUHead FindLabel(int direction);
+ c4StackHead FindLabel(int direction);
int FindLabel_Forward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
int FindLabel_Backward(const cCodeLabel & search_label,
const cGenome & search_genome, int pos);
- cCPUHead FindLabel(const cCodeLabel & in_label, int direction);
- cCPUHead FindFullLabel(const cCodeLabel & in_label);
+ c4StackHead FindLabel(const cCodeLabel & in_label, int direction);
+ c4StackHead FindFullLabel(const cCodeLabel & in_label);
int GetType() const { return HARDWARE_TYPE_CPU_4STACK; }
- int Inject(const cCodeLabel & in_label, const cGenome & injection);
- int InjectThread(const cCodeLabel & in_label, const cGenome & injection);
- void InjectCode(const cGenome & injection, const int line_num);
- void InjectCodeThread(const cGenome & injection, const int line_num);
+ bool Inject_Parasite(int mem_space_used, double mut_multiplier);
+ bool Inject_Host(const cCodeLabel & in_label, const cGenome & injection);
+ int InjectThread(const cCodeLabel &, const cGenome &) { return -1; }
void Mutate(const int mut_point);
int PointMutate(const double mut_rate);
+ int FindFirstEmpty();
+ bool isEmpty(int mem_space_used);
bool TriggerMutations(int trigger);
- bool TriggerMutations(int trigger, cCPUHead & cur_head);
+ bool TriggerMutations(int trigger, c4StackHead & cur_head);
bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
- cCPUMemory & target_memory, cCPUHead & cur_head, const double rate);
+ cCPUMemory & target_memory, c4StackHead & cur_head, const double rate);
void TriggerMutations_Body(int type, cCPUMemory & target_memory,
- cCPUHead & cur_head);
+ c4StackHead & cur_head);
void ReadInst(const int in_inst);
@@ -250,16 +277,15 @@
void LoadState(std::istream & fp);
void InitInstSet(const cString & filename, cInstSet & inst_set);
+ cString ConvertToInstruction(int mem_space_used);
private:
/////////---------- Instruction Helpers ------------//////////
- int FindModifiedRegister(int default_register);
int FindModifiedStack(int default_stack);
int FindModifiedHead(int default_head);
- int FindComplementRegister(int base_reg);
int FindComplementStack(int base_stack);
void Fault(int fault_loc, int fault_type, cString fault_desc="");
@@ -268,10 +294,10 @@
bool Allocate_Default(const int new_size);
bool Allocate_Main(const int allocated_size);
- bool Divide_Main(const int divide_point, const int extra_lines=0, double mut_multiplier=1);
-
- bool Divide_CheckViable(const int child_size, const int parent_size);
+ bool Divide_Main(const int mem_space_used, double mut_multiplier=1);
+ bool Divide_CheckViable(const int parent_size, const int child_size, const int mem_space);
void Divide_DoMutations(double mut_multiplier=1);
+ void Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code);
void Divide_TestFitnessMeasures();
bool HeadCopy_ErrorCorrect(double reduction);
@@ -280,224 +306,79 @@
public:
/////////---------- Instruction Library ------------//////////
- // Flow Control
- bool Inst_If0();
- bool Inst_IfEqu();
- bool Inst_IfNot0();
- bool Inst_IfNEqu();
- bool Inst_IfGr0();
- bool Inst_IfGr();
- bool Inst_IfGrEqu0();
- bool Inst_IfGrEqu();
- bool Inst_IfLess0();
- bool Inst_IfLess();
- bool Inst_IfLsEqu0();
- bool Inst_IfLsEqu();
- bool Inst_IfBit1();
- bool Inst_IfANotEqB();
- bool Inst_IfBNotEqC();
- bool Inst_IfANotEqC();
-
- bool Inst_JumpF();
- bool Inst_JumpB();
- bool Inst_JumpP();
- bool Inst_JumpSelf();
- bool Inst_Call();
- bool Inst_Return();
-
- // Stack and Register Operations
- bool Inst_Pop();
- bool Inst_Push();
- bool Inst_HeadPop();
- bool Inst_HeadPush();
-
- bool Inst_PopA();
- bool Inst_PopB();
- bool Inst_PopC();
- bool Inst_PushA();
- bool Inst_PushB();
- bool Inst_PushC();
-
- bool Inst_SwitchStack();
- bool Inst_FlipStack();
- bool Inst_Swap();
- bool Inst_SwapAB();
- bool Inst_SwapBC();
- bool Inst_SwapAC();
- bool Inst_CopyStack();
- bool Inst_CopyRegAB();
- bool Inst_CopyRegAC();
- bool Inst_CopyRegBA();
- bool Inst_CopyRegBC();
- bool Inst_CopyRegCA();
- bool Inst_CopyRegCB();
- bool Inst_Reset();
-
- // Single-Argument Math
+ //6
bool Inst_ShiftR();
+ //7
bool Inst_ShiftL();
- bool Inst_Bit1();
- bool Inst_SetNum();
- bool Inst_Inc();
- bool Inst_Dec();
- bool Inst_Zero();
- bool Inst_Not();
- bool Inst_Neg();
- bool Inst_Square();
- bool Inst_Sqrt();
- bool Inst_Log();
- bool Inst_Log10();
- bool Inst_Minus18();
-
- // Double Argument Math
- bool Inst_Add();
- bool Inst_Sub();
- bool Inst_Mult();
- bool Inst_Div();
- bool Inst_Mod();
- bool Inst_Nand();
- bool Inst_Nor();
- bool Inst_And();
- bool Inst_Order();
- bool Inst_Xor();
-
- // Biological
- bool Inst_Copy();
- bool Inst_ReadInst();
- bool Inst_WriteInst();
- bool Inst_StackReadInst();
- bool Inst_StackWriteInst();
- bool Inst_Compare();
- bool Inst_IfNCpy();
- bool Inst_Allocate();
+ //8
+ bool Inst_Val_Nand();
+ //9
+ bool Inst_Val_Add();
+ //10
+ bool Inst_Val_Sub();
+ //11
+ bool Inst_Val_Mult();
+ //12
+ bool Inst_Val_Div();
+ //13
+ bool Inst_SetMemory();
+ //14
bool Inst_Divide();
- bool Inst_CAlloc();
- bool Inst_CDivide();
- bool Inst_MaxAlloc();
+ //15
+ bool Inst_HeadRead();
+ //16
+ bool Inst_HeadWrite();
+ //??
+ bool Inst_HeadCopy();
+ //17
+ bool Inst_IfEqual();
+ //18
+ bool Inst_IfNotEqual();
+ //19
+ bool Inst_IfLess();
+ //20
+ bool Inst_IfGreater();
+ //21
+ bool Inst_HeadPush();
+ //22
+ bool Inst_HeadPop();
+ //23
+ bool Inst_HeadMove();
+ //24
+ bool Inst_Search();
+ //25
+ bool Inst_PushNext();
+ //26
+ bool Inst_PushPrevious();
+ //27
+ bool Inst_PushComplement();
+ //28
+ bool Inst_ValDelete();
+ //29
+ bool Inst_ValCopy();
+ //30
+ bool Inst_ForkThread();
+ //31
+ bool Inst_IfLabel();
+ //32
+ bool Inst_Increment();
+ //33
+ bool Inst_Decrement();
+ //34
+ bool Inst_Mod();
+ //35
+ bool Inst_KillThread();
+ //36
+ bool Inst_IO();
+ //37
bool Inst_Inject();
+
+ /*
bool Inst_InjectRand();
bool Inst_InjectThread();
bool Inst_Repro();
-
- // I/O and Sensory
- bool Inst_TaskGet();
- bool Inst_TaskStackGet();
- bool Inst_TaskStackLoad();
- bool Inst_TaskPut();
- bool Inst_TaskIO();
- bool Inst_SearchF();
- bool Inst_SearchB();
- bool Inst_MemSize();
-
- // Environment
-
- bool Inst_RotateL();
- bool Inst_RotateR();
- bool Inst_SetCopyMut();
- bool Inst_ModCopyMut();
-
- // Multi-threading...
-
- bool Inst_ForkThread();
- bool Inst_KillThread();
- bool Inst_ThreadID();
-
- // Head-based instructions...
-
- bool Inst_SetHead();
- bool Inst_AdvanceHead();
- bool Inst_MoveHead();
- bool Inst_JumpHead();
- bool Inst_GetHead();
- bool Inst_IfLabel();
- bool Inst_HeadDivide();
- bool Inst_HeadRead();
- bool Inst_HeadWrite();
- bool Inst_HeadCopy();
- bool Inst_HeadSearch();
- bool Inst_SetFlow();
-
- bool Inst_HeadCopy2();
- bool Inst_HeadCopy3();
- bool Inst_HeadCopy4();
- bool Inst_HeadCopy5();
- bool Inst_HeadCopy6();
- bool Inst_HeadCopy7();
- bool Inst_HeadCopy8();
- bool Inst_HeadCopy9();
- bool Inst_HeadCopy10();
-
- bool Inst_HeadDivideSex();
- bool Inst_HeadDivideAsex();
-
- bool Inst_HeadDivide1();
- bool Inst_HeadDivide2();
- bool Inst_HeadDivide3();
- bool Inst_HeadDivide4();
- bool Inst_HeadDivide5();
- bool Inst_HeadDivide6();
- bool Inst_HeadDivide7();
- bool Inst_HeadDivide8();
- bool Inst_HeadDivide9();
- bool Inst_HeadDivide10();
- bool Inst_HeadDivide16();
- bool Inst_HeadDivide32();
- bool Inst_HeadDivide50();
- bool Inst_HeadDivide100();
- bool Inst_HeadDivide500();
- bool Inst_HeadDivide1000();
- bool Inst_HeadDivide5000();
- bool Inst_HeadDivide10000();
- bool Inst_HeadDivide50000();
- bool Inst_HeadDivide0_5();
- bool Inst_HeadDivide0_1();
- bool Inst_HeadDivide0_05();
- bool Inst_HeadDivide0_01();
- bool Inst_HeadDivide0_001();
-
-
- // Direct Matching Templates
-
- bool Inst_DMJumpF();
- bool Inst_DMJumpB();
- bool Inst_DMCall();
- bool Inst_DMSearchF();
- bool Inst_DMSearchB();
-
- // Relative Addressed Jumps
-
- bool Inst_REJumpF();
- bool Inst_REJumpB();
-
- // Absoulte Addressed Jumps
-
- bool Inst_ABSJump();
-
-
- // Biologically inspired reproduction
- bool Inst_BCAlloc();
- bool Inst_BCopy();
- bool Inst_BDivide();
-private:
- bool Inst_BCopy_Main(double mut_prob); // Internal called by all BCopy's
-public:
- // Bio Error Correction
- bool Inst_BCopyDiv2();
- bool Inst_BCopyDiv3();
- bool Inst_BCopyDiv4();
- bool Inst_BCopyDiv5();
- bool Inst_BCopyDiv6();
- bool Inst_BCopyDiv7();
- bool Inst_BCopyDiv8();
- bool Inst_BCopyDiv9();
- bool Inst_BCopyDiv10();
- bool Inst_BCopyPow2();
- bool Inst_BIfNotCopy();
- bool Inst_BIfCopy();
-
-
- //// Placebo ////
- bool Inst_Skip();
+ */
+
};
@@ -505,6 +386,32 @@
// cHardware4Stack
//////////////////
+//Not used, but here to satisfy the requirements of HardwareBase
+inline const cCPUMemory & cHardware4Stack::GetMemory() const
+{
+ return memory_array[0];
+}
+
+//Not used, but here to satisfy the requirements of HardwareBase
+inline cCPUMemory & cHardware4Stack::GetMemory()
+{
+ return memory_array[0];
+}
+
+inline const cCPUMemory & cHardware4Stack::GetMemory(int mem_space) const
+{
+ if(mem_space >= NUM_MEMORY_SPACES)
+ mem_space %= NUM_MEMORY_SPACES;
+ return memory_array[mem_space];
+}
+
+inline cCPUMemory & cHardware4Stack::GetMemory(int mem_space)
+{
+ if(mem_space >= NUM_MEMORY_SPACES)
+ mem_space %= NUM_MEMORY_SPACES;
+ return memory_array[mem_space];
+}
+
inline void cHardware4Stack::NextThread()
{
cur_thread++;
@@ -523,72 +430,87 @@
cur_thread=value;
}
-inline void cHardware4Stack::StackPush(int value)
-{
- if (threads[cur_thread].cur_stack == 0) {
- threads[cur_thread].stack.Push(value);
- } else {
- global_stack.Push(value);
- }
-}
-
-inline int cHardware4Stack::StackPop()
-{
- int pop_value;
-
- if (threads[cur_thread].cur_stack == 0) {
- pop_value = threads[cur_thread].stack.Pop();
- } else {
- pop_value = global_stack.Pop();
- }
-
- return pop_value;
-}
-
-inline void cHardware4Stack::StackFlip()
+/*inline void cHardware4Stack::StackFlip()
{
if (threads[cur_thread].cur_stack == 0) {
threads[cur_thread].stack.Flip();
} else {
global_stack.Flip();
}
-}
+}*/
-inline int cHardware4Stack::GetStack(int depth, int stack_id) const
+inline int cHardware4Stack::GetStack(int depth, int stack_id, int in_thread) const
{
- int value = 0;
-
- if (stack_id == -1) stack_id = threads[cur_thread].cur_stack;
+ if(stack_id<0 || stack_id>NUM_STACKS) stack_id=0;
+
+ if(in_thread==-1)
+ in_thread=cur_thread;
+
+ return Stack(stack_id, in_thread).Get(depth);
+}
- if (stack_id == 0) value = threads[cur_thread].stack.Get(depth);
- else if (stack_id == 1) value = global_stack.Get(depth);
+//inline void cHardware4Stack::StackClear()
+//{
+
+ //if (threads[cur_thread].cur_stack == 0) {
+ // threads[cur_thread].stack.Clear();
+ //} else {
+ // global_stack.Clear();
+ //}
+//}
+
+//inline void cHardware4Stack::SwitchStack()
+//{
+// threads[cur_thread].cur_stack++;
+// if (threads[cur_thread].cur_stack > 1) threads[cur_thread].cur_stack = 0;
+//}
- return value;
+inline cCPUStack& cHardware4Stack::Stack(int stack_id)
+{
+ if(stack_id >= NUM_STACKS)
+ {
+ stack_id=0;
+ }
+ if(stack_id < NUM_LOCAL_STACKS)
+ return threads[cur_thread].local_stacks[stack_id];
+ else
+ return global_stacks[stack_id % NUM_LOCAL_STACKS];
}
-inline void cHardware4Stack::StackClear()
+inline const cCPUStack& cHardware4Stack::Stack(int stack_id) const
{
- if (threads[cur_thread].cur_stack == 0) {
- threads[cur_thread].stack.Clear();
- } else {
- global_stack.Clear();
- }
+ if(stack_id >= NUM_STACKS)
+ {
+ stack_id=0;
+ }
+ if(stack_id < NUM_LOCAL_STACKS)
+ return threads[cur_thread].local_stacks[stack_id];
+ else
+ return global_stacks[stack_id % NUM_LOCAL_STACKS];
}
-inline void cHardware4Stack::SwitchStack()
+inline cCPUStack& cHardware4Stack::Stack(int stack_id, int in_thread)
{
- threads[cur_thread].cur_stack++;
- if (threads[cur_thread].cur_stack > 1) threads[cur_thread].cur_stack = 0;
+ if(stack_id >= NUM_STACKS)
+ stack_id=0;
+ if(in_thread >= threads.GetSize())
+ in_thread=cur_thread;
+
+ if(stack_id < NUM_LOCAL_STACKS)
+ return threads[in_thread].local_stacks[stack_id];
+ else
+ return global_stacks[stack_id % NUM_LOCAL_STACKS];
}
-inline cCPUStack& cHardware4Stack::Stack(int stack_id)
+inline const cCPUStack& cHardware4Stack::Stack(int stack_id, int in_thread) const
{
if(stack_id >= NUM_STACKS)
- {
stack_id=0;
- }
+ if(in_thread >= threads.GetSize())
+ in_thread=cur_thread;
+
if(stack_id < NUM_LOCAL_STACKS)
- return threads[cur_thread].local_stacks[stack_id];
+ return threads[in_thread].local_stacks[stack_id];
else
return global_stacks[stack_id % NUM_LOCAL_STACKS];
}
Index: avida/current/source/cpu/hardware_base.hh
diff -u avida/current/source/cpu/hardware_base.hh:1.17 avida/current/source/cpu/hardware_base.hh:1.17.2.1
--- avida/current/source/cpu/hardware_base.hh:1.17 Sun May 18 21:15:21 2003
+++ avida/current/source/cpu/hardware_base.hh Tue Aug 19 10:49:29 2003
@@ -52,7 +52,7 @@
// -------- Other Virtual Tools --------
virtual int GetType() const = 0;
- virtual int Inject(const cCodeLabel & in_label,
+ virtual bool Inject_Host(const cCodeLabel & in_label,
const cGenome & injection) = 0;
virtual int InjectThread(const cCodeLabel & in_label,
const cGenome & injection) = 0;
@@ -69,6 +69,7 @@
// -------- @CAO Should be rethought? --------
virtual cCPUMemory & GetMemory() = 0;
+ virtual cCPUMemory & GetMemory(int) = 0;
// -------- DEBUG ---------
static int GetInstanceCount() { return instance_count; }
Index: avida/current/source/cpu/hardware_cpu.cc
diff -u avida/current/source/cpu/hardware_cpu.cc:1.45.2.3 avida/current/source/cpu/hardware_cpu.cc:1.45.2.4
--- avida/current/source/cpu/hardware_cpu.cc:1.45.2.3 Thu May 29 11:21:00 2003
+++ avida/current/source/cpu/hardware_cpu.cc Tue Aug 19 10:49:29 2003
@@ -13,9 +13,7 @@
#include "../tools/string_util.hh"
#include "../main/config.hh"
-#ifdef USE_INST_SET_CODE
- #include "../main/inst_set.hh"
-#endif /* USE_INST_SET_CODE */
+#include "../main/inst_set.hh"
#include "../main/inst_lib.hh"
#include "../main/genome_util.hh"
#include "../main/organism.hh"
@@ -147,7 +145,6 @@
stack.LoadState(fp);
char marker; fp>>marker; assert( marker == '|' );
-#ifdef USE_INST_SET_CODE
/* YIKES! data loss below: */
char the_cur_stack = cur_stack;
char the_cur_head = cur_head;
@@ -155,11 +152,6 @@
fp.get(the_cur_stack);
fp.get(the_cur_head);
fp.get(the_input_pointer);
-#else /* USE_INST_SET_CODE */
- fp.get((char)cur_stack);
- fp.get((char)cur_head);
- fp.get((char)input_pointer);
-#endif /* USE_INST_SET_CODE */
// IO buffers
input_buf.LoadState(fp);
@@ -171,7 +163,6 @@
}
-#ifdef USE_INST_SET_CODE
///////////////
// cInstLibCPU
///////////////
@@ -227,13 +218,11 @@
const cInstruction & GetInstDefault(){ return inst_default; }
const cInstruction & GetInstError(){ return inst_error; }
};
-#endif /* USE_INST_SET_CODE */
///////////////
// cHardwareCPU
///////////////
-#ifdef USE_INST_SET_CODE
const cInstruction cInstLibCPU::inst_error(255);
const cInstruction cInstLibCPU::inst_default(0);
cInstLibBase *cHardwareCPU::GetInstLib(){ return s_inst_slib; }
@@ -441,6 +430,9 @@
cInstEntryCPU("h-copy9", &cHardwareCPU::Inst_HeadCopy9),
cInstEntryCPU("h-copy10", &cHardwareCPU::Inst_HeadCopy10),
+ cInstEntryCPU("divide-sex", &cHardwareCPU::Inst_HeadDivideSex),
+ cInstEntryCPU("divide-asex", &cHardwareCPU::Inst_HeadDivide1),
+
cInstEntryCPU("h-divide1", &cHardwareCPU::Inst_HeadDivide1),
cInstEntryCPU("h-divide2", &cHardwareCPU::Inst_HeadDivide2),
cInstEntryCPU("h-divide3", &cHardwareCPU::Inst_HeadDivide3),
@@ -540,16 +532,13 @@
return inst_lib;
}
-#endif /* USE_INST_SET_CODE */
cHardwareCPU::cHardwareCPU(cOrganism * in_organism, cInstSet * in_inst_set)
: cHardwareBase(in_organism, in_inst_set)
{
-#ifdef USE_INST_SET_CODE
/* FIXME: reorganize storage of m_functions. -- kgn */
m_functions = s_inst_slib->GetFunctions();
/**/
-#endif /* USE_INST_SET_CODE */
memory = in_organism->GetGenome(); // Initialize memory...
Reset(); // Setup the rest of the hardware...
}
@@ -689,24 +678,14 @@
bool cHardwareCPU::SingleProcess_ExecuteInst(const cInstruction & cur_inst)
{
// Get a pointer to the corrisponding method...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int inst_idx = GetInstSet().GetLibFunctionIndex(cur_inst);
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod inst_ptr = GetInstSet().GetFunction(cur_inst);
-#endif /* USE_INST_SET_CODE */
// Mark the instruction as executed
IP().FlagExecuted() = true;
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
-#ifdef USE_INST_SET_CODE
if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
-#else /* USE_INST_SET_CODE */
- if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif /* USE_INST_SET_CODE */
#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
@@ -715,15 +694,9 @@
#endif
// And execute it.
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
const bool exec_success
//= (this->*(s_inst_slib->GetFunctions()[inst_idx]))();
= (this->*(m_functions[inst_idx]))();
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- const bool exec_success = (this->*inst_ptr)();
-#endif /* USE_INST_SET_CODE */
#ifdef INSTRUCTION_COUNT
// decremenet if the instruction was not executed successfully
@@ -1117,22 +1090,22 @@
}
-int cHardwareCPU::Inject(const cCodeLabel & in_label, const cGenome & injection)
+bool cHardwareCPU::Inject_Host(const cCodeLabel & in_label, const cGenome & injection)
{
// Make sure the genome will be below max size after injection.
const int new_size = injection.GetSize() + GetMemory().GetSize();
- if (new_size > MAX_CREATURE_SIZE) return 1; // (inject fails)
+ if (new_size > MAX_CREATURE_SIZE) return false; // (inject fails)
const int inject_line = FindFullLabel(in_label).GetPosition();
// Abort if no compliment is found.
- if (inject_line == -1) return 2; // (inject fails)
+ if (inject_line == -1) return false; // (inject fails)
// Inject the code!
InjectCode(injection, inject_line+1);
- return 0; // (inject succeeds!)
+ return true; // (inject succeeds!)
}
int cHardwareCPU::InjectThread(const cCodeLabel & in_label, const cGenome & injection)
@@ -1721,8 +1694,47 @@
}
// Save the information we collected here...
- organism->GetPhenotype().SetLinesExecuted(executed_size);
- organism->GetPhenotype().SetLinesCopied(copied_size);
+ cPhenotype & phenotype = organism->GetPhenotype();
+ phenotype.SetLinesExecuted(executed_size);
+ phenotype.SetLinesCopied(copied_size);
+
+ // Determine the fitness of this organism as compared to its parent...
+ if (cConfig::GetTestSterilize() == true &&
+ phenotype.IsInjected() == false) {
+ const int merit_base =
+ cPhenotype::CalcSizeMerit(genome_size, copied_size, executed_size);
+ const double cur_fitness =
+ merit_base * phenotype.GetCurBonus() / phenotype.GetTimeUsed();
+ const double fitness_ratio = cur_fitness / phenotype.GetLastFitness();
+
+
+ // const double neut_min = parent_fitness * FITNESS_NEUTRAL_MIN;
+ // const double neut_max = parent_fitness * FITNESS_NEUTRAL_MAX;
+
+ bool sterilize = false;
+
+ if (fitness_ratio < FITNESS_NEUTRAL_MIN) {
+ if (g_random.P(organism->GetSterilizeNeg())) sterilize = true;
+ } else if (fitness_ratio <= FITNESS_NEUTRAL_MAX) {
+ if (g_random.P(organism->GetSterilizeNeut())) sterilize = true;
+ } else {
+ if (g_random.P(organism->GetSterilizePos())) sterilize = true;
+ }
+
+// cout << "[ min(" << genome_size
+// << "," << copied_size
+// << "," << executed_size
+// << ") * " << phenotype.GetCurBonus()
+// << " / " << phenotype.GetTimeUsed()
+// << "] / " << phenotype.GetLastFitness()
+// << " == " << fitness_ratio;
+
+ if (sterilize == true) {
+ //Don't let this organism have this or any more children!
+ phenotype.IsFertile() = false;
+ return false;
+ }
+ }
return true; // (divide succeeds!)
}
@@ -2751,8 +2763,8 @@
// Search for the label in the host...
GetLabel().Rotate(1, NUM_NOPS);
- const int inject_signal =
- host_organism->GetHardware().Inject(GetLabel(), inject_code);
+ const bool inject_signal =
+ host_organism->GetHardware().Inject_Host(GetLabel(), inject_code);
if (inject_signal == 1) {
Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: host too large.");
return false; // Inject failed.
@@ -2765,7 +2777,7 @@
// Set the relevent flags.
organism->GetPhenotype().IsModifier() = true;
- return true;
+ return inject_signal;
}
@@ -2843,7 +2855,7 @@
bool cHardwareCPU::Inst_TaskGet()
{
const int reg_used = FindModifiedRegister(REG_CX);
- const int value = organism->GetInput();
+ const int value = organism->GetInputAt(threads[GetCurThread()].input_pointer);
Register(reg_used) = value;
DoInput(value);
return true;
@@ -2851,7 +2863,7 @@
bool cHardwareCPU::Inst_TaskStackGet()
{
- const int value = organism->GetInput();
+ const int value = organism->GetInputAt(threads[GetCurThread()].input_pointer);
StackPush(value);
DoInput(value);
return true;
@@ -2859,7 +2871,8 @@
bool cHardwareCPU::Inst_TaskStackLoad()
{
- for (int i = 0; i < IO_SIZE; i++) StackPush( organism->GetInput() );
+ for (int i = 0; i < IO_SIZE; i++)
+ StackPush( organism->GetInputAt(threads[GetCurThread()].input_pointer) );
return true;
}
@@ -2881,7 +2894,7 @@
DoOutput(value_out); // Check for tasks compleated.
// Do the "get" component
- const int value_in = organism->GetInput();
+ const int value_in = organism->GetInputAt(threads[GetCurThread()].input_pointer);
Register(reg_used) = value_in;
DoInput(value_in);
return true;
Index: avida/current/source/cpu/hardware_cpu.hh
diff -u avida/current/source/cpu/hardware_cpu.hh:1.28.2.2 avida/current/source/cpu/hardware_cpu.hh:1.28.2.3
--- avida/current/source/cpu/hardware_cpu.hh:1.28.2.2 Thu May 29 11:21:00 2003
+++ avida/current/source/cpu/hardware_cpu.hh Tue Aug 19 10:49:29 2003
@@ -44,7 +44,7 @@
UCHAR cur_stack; // 0 = local stack, 1 = global stack.
UCHAR cur_head;
- UCHAR input_pointer;
+ int input_pointer;
tBuffer<int> input_buf;
tBuffer<int> output_buf;
cCodeLabel read_label;
@@ -192,6 +192,8 @@
// -------- Accessors --------
const cCPUMemory & GetMemory() const { return memory; }
cCPUMemory & GetMemory() { return memory; }
+ const cCPUMemory & GetMemory(int value) const { return memory;}
+ cCPUMemory & GetMemory(int value) { return memory; }
int GetThreadTimeUsed() const { return thread_time_used; }
int GetNumThreads() const { return threads.GetSize(); }
@@ -214,7 +216,7 @@
cCPUHead FindFullLabel(const cCodeLabel & in_label);
int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }
- int Inject(const cCodeLabel & in_label, const cGenome & injection);
+ bool Inject_Host(const cCodeLabel & in_label, const cGenome & injection);
int InjectThread(const cCodeLabel & in_label, const cGenome & injection);
void InjectCode(const cGenome & injection, const int line_num);
void InjectCodeThread(const cGenome & injection, const int line_num);
Index: avida/current/source/cpu/hardware_util.cc
diff -u avida/current/source/cpu/hardware_util.cc:1.23.2.4 avida/current/source/cpu/hardware_util.cc:1.23.2.5
--- avida/current/source/cpu/hardware_util.cc:1.23.2.4 Wed Jun 4 09:36:30 2003
+++ avida/current/source/cpu/hardware_util.cc Tue Aug 19 10:49:29 2003
@@ -22,17 +22,10 @@
using namespace std;
-#ifdef USE_INST_SET_CODE
void cHardwareUtil::LoadInstSet(cString filename, cInstSet & inst_set,
tDictionary<int> & nop_dict,
tDictionary<int> & inst_dict
){
-#else /* USE_INST_SET_CODE */
-void cHardwareUtil::LoadInstSet(cString & filename, cInstSet & inst_set,
- tDictionary<int> & nop_dict,
- tDictionary<tHardwareMethod> & inst_dict
-){
-#endif /* USE_INST_SET_CODE */
// If there is no filename, use the default for the appropriate hardware.
cString default_filename = "unknown";
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
@@ -92,45 +85,18 @@
// Otherwise, this instruction will be in the set.
// First, determine if it is a nop...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int nop_mod = -1;
if(nop_dict.Find(inst_name, nop_mod) == true) {
inst_set.AddNop2(nop_mod, redundancy, ft_cost, cost, prob_fail);
continue;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- int nop_mod = -1;
- /* XXX start -- kgn */
- int nop_mod_2 = -1;
- /* XXX end */
- if (nop_dict.Find(inst_name, nop_mod) == true) {
- inst_set.AddNop(inst_name, &cHardwareBase::Inst_Nop, nop_mod,
- redundancy, ft_cost, cost, prob_fail);
- continue;
- }
-#endif /* USE_INST_SET_CODE */
// Otherwise, it had better be in the main dictionary...
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int fun_id = -1;
if(inst_dict.Find(inst_name, fun_id) == true){
inst_set.Add2(fun_id, redundancy, ft_cost, cost, prob_fail);
continue;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod cpu_method = NULL;
- /* XXX start -- kgn */
- int fun_id = -1;
- /* XXX end */
- if (inst_dict.Find(inst_name, cpu_method) == true) {
- inst_set.Add(inst_name, cpu_method, redundancy, ft_cost, cost, prob_fail);
- continue;
- }
-#endif /* USE_INST_SET_CODE */
// Oh oh! Didn't find an instruction!
cerr << endl
@@ -148,221 +114,9 @@
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
-#ifndef USE_INST_SET_CODE
- tDictionary< int > nop_dict;
- nop_dict.Add("nop-A", REG_AX);
- nop_dict.Add("nop-B", REG_BX);
- nop_dict.Add("nop-C", REG_CX);
-#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
-#ifndef USE_INST_SET_CODE
- tDictionary< tHardwareMethod > inst_dict;
-
- // Remaining instructions.
- inst_dict.Add("nop-X", (tHardwareMethod) &cHardwareCPU::Inst_Nop);
- inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardwareCPU::Inst_If0);
- inst_dict.Add("if-not-0", (tHardwareMethod) &cHardwareCPU::Inst_IfNot0);
- inst_dict.Add("if-n-equ", (tHardwareMethod) &cHardwareCPU::Inst_IfNEqu);
- inst_dict.Add("if-equ", (tHardwareMethod) &cHardwareCPU::Inst_IfEqu);
- inst_dict.Add("if-grt-0", (tHardwareMethod) &cHardwareCPU::Inst_IfGr0);
- inst_dict.Add("if-grt", (tHardwareMethod) &cHardwareCPU::Inst_IfGr);
- inst_dict.Add("if->=-0", (tHardwareMethod) &cHardwareCPU::Inst_IfGrEqu0);
- inst_dict.Add("if->=", (tHardwareMethod) &cHardwareCPU::Inst_IfGrEqu);
- inst_dict.Add("if-les-0", (tHardwareMethod) &cHardwareCPU::Inst_IfLess0);
- inst_dict.Add("if-less", (tHardwareMethod) &cHardwareCPU::Inst_IfLess);
- inst_dict.Add("if-<=-0", (tHardwareMethod) &cHardwareCPU::Inst_IfLsEqu0);
- inst_dict.Add("if-<=", (tHardwareMethod) &cHardwareCPU::Inst_IfLsEqu);
- inst_dict.Add("if-A!=B", (tHardwareMethod) &cHardwareCPU::Inst_IfANotEqB);
- inst_dict.Add("if-B!=C", (tHardwareMethod) &cHardwareCPU::Inst_IfBNotEqC);
- inst_dict.Add("if-A!=C", (tHardwareMethod) &cHardwareCPU::Inst_IfANotEqC);
-
- inst_dict.Add("if-bit-1", (tHardwareMethod) &cHardwareCPU::Inst_IfBit1);
- inst_dict.Add("jump-f", (tHardwareMethod) &cHardwareCPU::Inst_JumpF);
- inst_dict.Add("jump-b", (tHardwareMethod) &cHardwareCPU::Inst_JumpB);
- inst_dict.Add("jump-p", (tHardwareMethod) &cHardwareCPU::Inst_JumpP);
- inst_dict.Add("jump-slf", (tHardwareMethod) &cHardwareCPU::Inst_JumpSelf);
- inst_dict.Add("call", (tHardwareMethod) &cHardwareCPU::Inst_Call);
- inst_dict.Add("return", (tHardwareMethod) &cHardwareCPU::Inst_Return);
-
- inst_dict.Add("pop", (tHardwareMethod) &cHardwareCPU::Inst_Pop);
- inst_dict.Add("push", (tHardwareMethod) &cHardwareCPU::Inst_Push);
- inst_dict.Add("swap-stk",(tHardwareMethod) &cHardwareCPU::Inst_SwitchStack);
- inst_dict.Add("flip-stk",(tHardwareMethod) &cHardwareCPU::Inst_FlipStack);
- inst_dict.Add("swap", (tHardwareMethod) &cHardwareCPU::Inst_Swap);
- inst_dict.Add("swap-AB", (tHardwareMethod) &cHardwareCPU::Inst_SwapAB);
- inst_dict.Add("swap-BC", (tHardwareMethod) &cHardwareCPU::Inst_SwapBC);
- inst_dict.Add("swap-AC", (tHardwareMethod) &cHardwareCPU::Inst_SwapAC);
- inst_dict.Add("copy-reg",(tHardwareMethod) &cHardwareCPU::Inst_CopyReg);
- inst_dict.Add("set_A=B", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegAB);
- inst_dict.Add("set_A=C", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegAC);
- inst_dict.Add("set_B=A", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegBA);
- inst_dict.Add("set_B=C", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegBC);
- inst_dict.Add("set_C=A", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegCA);
- inst_dict.Add("set_C=B", (tHardwareMethod) &cHardwareCPU::Inst_CopyRegCB);
- inst_dict.Add("reset", (tHardwareMethod) &cHardwareCPU::Inst_Reset);
-
- inst_dict.Add("pop-A", (tHardwareMethod) &cHardwareCPU::Inst_PopA);
- inst_dict.Add("pop-B", (tHardwareMethod) &cHardwareCPU::Inst_PopB);
- inst_dict.Add("pop-C", (tHardwareMethod) &cHardwareCPU::Inst_PopC);
- inst_dict.Add("push-A", (tHardwareMethod) &cHardwareCPU::Inst_PushA);
- inst_dict.Add("push-B", (tHardwareMethod) &cHardwareCPU::Inst_PushB);
- inst_dict.Add("push-C", (tHardwareMethod) &cHardwareCPU::Inst_PushC);
-
- inst_dict.Add("shift-r", (tHardwareMethod) &cHardwareCPU::Inst_ShiftR);
- inst_dict.Add("shift-l", (tHardwareMethod) &cHardwareCPU::Inst_ShiftL);
- inst_dict.Add("bit-1", (tHardwareMethod) &cHardwareCPU::Inst_Bit1);
- inst_dict.Add("set-num", (tHardwareMethod) &cHardwareCPU::Inst_SetNum);
- inst_dict.Add("inc", (tHardwareMethod) &cHardwareCPU::Inst_Inc);
- inst_dict.Add("dec", (tHardwareMethod) &cHardwareCPU::Inst_Dec);
- inst_dict.Add("zero", (tHardwareMethod) &cHardwareCPU::Inst_Zero);
- inst_dict.Add("neg", (tHardwareMethod) &cHardwareCPU::Inst_Neg);
- inst_dict.Add("square", (tHardwareMethod) &cHardwareCPU::Inst_Square);
- inst_dict.Add("sqrt", (tHardwareMethod) &cHardwareCPU::Inst_Sqrt);
- inst_dict.Add("not", (tHardwareMethod) &cHardwareCPU::Inst_Not);
- inst_dict.Add("log", (tHardwareMethod) &cHardwareCPU::Inst_Log);
- inst_dict.Add("log10", (tHardwareMethod) &cHardwareCPU::Inst_Log10);
- inst_dict.Add("minus-17", (tHardwareMethod) &cHardwareCPU::Inst_Minus17);
-
- inst_dict.Add("add", (tHardwareMethod) &cHardwareCPU::Inst_Add);
- inst_dict.Add("sub", (tHardwareMethod) &cHardwareCPU::Inst_Sub);
- inst_dict.Add("mult", (tHardwareMethod) &cHardwareCPU::Inst_Mult);
- inst_dict.Add("div", (tHardwareMethod) &cHardwareCPU::Inst_Div);
- inst_dict.Add("mod", (tHardwareMethod) &cHardwareCPU::Inst_Mod);
- inst_dict.Add("nand", (tHardwareMethod) &cHardwareCPU::Inst_Nand);
- inst_dict.Add("nor", (tHardwareMethod) &cHardwareCPU::Inst_Nor);
- inst_dict.Add("and", (tHardwareMethod) &cHardwareCPU::Inst_And);
- inst_dict.Add("order", (tHardwareMethod) &cHardwareCPU::Inst_Order);
- inst_dict.Add("xor", (tHardwareMethod) &cHardwareCPU::Inst_Xor);
-
- inst_dict.Add("copy", (tHardwareMethod)&cHardwareCPU::Inst_Copy);
- inst_dict.Add("read", (tHardwareMethod)&cHardwareCPU::Inst_ReadInst);
- inst_dict.Add("write", (tHardwareMethod)&cHardwareCPU::Inst_WriteInst);
- inst_dict.Add("stk-read",(tHardwareMethod)&cHardwareCPU::Inst_StackReadInst);
- inst_dict.Add("stk-writ",(tHardwareMethod)&cHardwareCPU::Inst_StackWriteInst);
-
- inst_dict.Add("compare", (tHardwareMethod) &cHardwareCPU::Inst_Compare);
- inst_dict.Add("if-n-cpy", (tHardwareMethod) &cHardwareCPU::Inst_IfNCpy);
- inst_dict.Add("allocate", (tHardwareMethod) &cHardwareCPU::Inst_Allocate);
- inst_dict.Add("divide", (tHardwareMethod) &cHardwareCPU::Inst_Divide);
- inst_dict.Add("c-alloc", (tHardwareMethod) &cHardwareCPU::Inst_CAlloc);
- inst_dict.Add("c-divide", (tHardwareMethod) &cHardwareCPU::Inst_CDivide);
- inst_dict.Add("inject", (tHardwareMethod) &cHardwareCPU::Inst_Inject);
- inst_dict.Add("inject-r", (tHardwareMethod) &cHardwareCPU::Inst_InjectRand);
- inst_dict.Add("inject-th", (tHardwareMethod) &cHardwareCPU::Inst_InjectThread);
-
- inst_dict.Add("get", (tHardwareMethod)&cHardwareCPU::Inst_TaskGet);
- inst_dict.Add("stk-get", (tHardwareMethod)&cHardwareCPU::Inst_TaskStackGet);
- inst_dict.Add("stk-load",(tHardwareMethod)&cHardwareCPU::Inst_TaskStackLoad);
- inst_dict.Add("put", (tHardwareMethod)&cHardwareCPU::Inst_TaskPut);
- inst_dict.Add("IO", (tHardwareMethod)&cHardwareCPU::Inst_TaskIO);
- inst_dict.Add("search-f",(tHardwareMethod)&cHardwareCPU::Inst_SearchF);
- inst_dict.Add("search-b",(tHardwareMethod)&cHardwareCPU::Inst_SearchB);
- inst_dict.Add("mem-size",(tHardwareMethod)&cHardwareCPU::Inst_MemSize);
-
- inst_dict.Add("rotate-l", (tHardwareMethod) &cHardwareCPU::Inst_RotateL);
- inst_dict.Add("rotate-r", (tHardwareMethod) &cHardwareCPU::Inst_RotateR);
-
- inst_dict.Add("set-cmut", (tHardwareMethod) &cHardwareCPU::Inst_SetCopyMut);
- inst_dict.Add("mod-cmut", (tHardwareMethod) &cHardwareCPU::Inst_ModCopyMut);
-
- // Threading instructions
- inst_dict.Add("fork-th", (tHardwareMethod) &cHardwareCPU::Inst_ForkThread);
- inst_dict.Add("kill-th", (tHardwareMethod) &cHardwareCPU::Inst_KillThread);
- inst_dict.Add("id-th", (tHardwareMethod) &cHardwareCPU::Inst_ThreadID);
-
- // Head-based instructions
- inst_dict.Add("h-alloc", (tHardwareMethod) &cHardwareCPU::Inst_MaxAlloc);
- inst_dict.Add("h-divide", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide);
- inst_dict.Add("h-read", (tHardwareMethod) &cHardwareCPU::Inst_HeadRead);
- inst_dict.Add("h-write", (tHardwareMethod) &cHardwareCPU::Inst_HeadWrite);
- inst_dict.Add("h-copy", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy);
- inst_dict.Add("h-search", (tHardwareMethod) &cHardwareCPU::Inst_HeadSearch);
- inst_dict.Add("h-push", (tHardwareMethod) &cHardwareCPU::Inst_HeadPush);
- inst_dict.Add("h-pop", (tHardwareMethod) &cHardwareCPU::Inst_HeadPop);
- inst_dict.Add("set-head", (tHardwareMethod) &cHardwareCPU::Inst_SetHead);
- inst_dict.Add("adv-head", (tHardwareMethod) &cHardwareCPU::Inst_AdvanceHead);
- inst_dict.Add("mov-head", (tHardwareMethod) &cHardwareCPU::Inst_MoveHead);
- inst_dict.Add("jmp-head", (tHardwareMethod) &cHardwareCPU::Inst_JumpHead);
- inst_dict.Add("get-head", (tHardwareMethod) &cHardwareCPU::Inst_GetHead);
- inst_dict.Add("if-label", (tHardwareMethod) &cHardwareCPU::Inst_IfLabel);
- inst_dict.Add("set-flow", (tHardwareMethod) &cHardwareCPU::Inst_SetFlow);
-
- inst_dict.Add("h-copy2", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy2);
- inst_dict.Add("h-copy3", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy3);
- inst_dict.Add("h-copy4", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy4);
- inst_dict.Add("h-copy5", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy5);
- inst_dict.Add("h-copy6", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy6);
- inst_dict.Add("h-copy7", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy7);
- inst_dict.Add("h-copy8", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy8);
- inst_dict.Add("h-copy9", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy9);
- inst_dict.Add("h-copy10", (tHardwareMethod) &cHardwareCPU::Inst_HeadCopy10);
-
-
- inst_dict.Add("divide-sex", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivideSex);
- inst_dict.Add("divide-asex", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1);
-
- inst_dict.Add("h-divide1", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1);
- inst_dict.Add("h-divide2", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide2);
- inst_dict.Add("h-divide3", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide3);
- inst_dict.Add("h-divide4", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide4);
- inst_dict.Add("h-divide5", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide5);
- inst_dict.Add("h-divide6", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide6);
- inst_dict.Add("h-divide7", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide7);
- inst_dict.Add("h-divide8", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide8);
- inst_dict.Add("h-divide9", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide9);
- inst_dict.Add("h-divide10", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide10);
- inst_dict.Add("h-divide16", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide16);
- inst_dict.Add("h-divide32", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide32);
- inst_dict.Add("h-divide50", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide50);
- inst_dict.Add("h-divide100", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide100);
- inst_dict.Add("h-divide500", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide500);
- inst_dict.Add("h-divide1000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide1000);
- inst_dict.Add("h-divide5000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide5000);
- inst_dict.Add("h-divide10000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide10000);
- inst_dict.Add("h-divide50000", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide50000);
- inst_dict.Add("h-divide0.5", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_5);
- inst_dict.Add("h-divide0.1", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_1);
- inst_dict.Add("h-divide0.05", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_05);
- inst_dict.Add("h-divide0.01", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_01);
- inst_dict.Add("h-divide0.001", (tHardwareMethod) &cHardwareCPU::Inst_HeadDivide0_001);
-
- // High-level instructions
- inst_dict.Add("repro", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-A", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-B", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-C", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-D", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-E", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-F", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-G", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-H", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-I", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-J", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-K", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-L", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-M", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-N", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-O", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-P", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Q", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-R", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-S", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-T", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-U", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-V", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-W", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-X", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Y", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
- inst_dict.Add("repro-Z", (tHardwareMethod) &cHardwareCPU::Inst_Repro);
-
- // Placebo instructions
- // nop-x (included with nops)
- inst_dict.Add("skip", (tHardwareMethod) &cHardwareCPU::Inst_Skip);
-#endif /* !USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
@@ -370,8 +124,6 @@
tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
// And load it on up!
LoadInstSet(filename, inst_set, nop_dict, inst_dict);
@@ -381,299 +133,9 @@
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
-#ifndef USE_INST_SET_CODE
- tDictionary< int > nop_dict;
- nop_dict.Add("Nop-A", REG_AX);
- nop_dict.Add("Nop-B", REG_BX);
- nop_dict.Add("Nop-C", REG_CX);
- nop_dict.Add("Nop-D", REG_DX);
-#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
-#ifndef USE_INST_SET_CODE
- tDictionary< tHardwareMethod > inst_dict;
-
- // Remaining instructions.
- //1
- //inst_dict.Add("nop-A", &cHardware4Stack::Inst_Nop),
- //2
- //inst_dict.Add("nop-B", &cHardware4Stack::Inst_Nop),
- //3
- //inst_dict.Add("nop-C", &cHardware4Stack::Inst_Nop),
- //4 - not implemented yet...
- //inst_dict.Add("nop-D", &cHardware4Stack::Inst_Nop),
- //5
- inst_dict.Add("Nop-X", (tHardwareMethod) &cHardware4Stack::Inst_Nop);
- //6
- inst_dict.Add("Val-Shift-R", (tHardwareMethod) &cHardware4Stack::Inst_ShiftR);
- //7
- inst_dict.Add("Val-Shift-L", (tHardwareMethod) &cHardware4Stack::Inst_ShiftL);
- //8
- inst_dict.Add("Val-Nand", (tHardwareMethod) &cHardware4Stack::Inst_Nand);
- //9
- inst_dict.Add("Val-Add", (tHardwareMethod) &cHardware4Stack::Inst_Add);
- //10
- inst_dict.Add("Val-Sub", (tHardwareMethod) &cHardware4Stack::Inst_Sub);
- //11
- inst_dict.Add("Val-Mult", (tHardwareMethod) &cHardware4Stack::Inst_Mult);
- //12
- inst_dict.Add("Val-Div", (tHardwareMethod) &cHardware4Stack::Inst_Div);
- //13
- inst_dict.Add("SetMemory", (tHardwareMethod) &cHardware4Stack::Inst_MaxAlloc);
- //14
- inst_dict.Add("Divide", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide);
- //15
- inst_dict.Add("Inst-Read", (tHardwareMethod) &cHardware4Stack::Inst_HeadRead);
- //16
- inst_dict.Add("Inst-Write", (tHardwareMethod) &cHardware4Stack::Inst_HeadWrite);
- //keeping this one for the transition period
- inst_dict.Add("Inst-Copy", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy);
- //17
- inst_dict.Add("If-Equal", (tHardwareMethod) &cHardware4Stack::Inst_IfEqu);
- //18
- inst_dict.Add("If-Not-Equal", (tHardwareMethod) &cHardware4Stack::Inst_IfNEqu);
- //19
- inst_dict.Add("If-Less", (tHardwareMethod) &cHardware4Stack::Inst_IfLess);
- //20
- inst_dict.Add("If-Greater", (tHardwareMethod) &cHardware4Stack::Inst_IfGr);
- //21
- inst_dict.Add("Head-Push", (tHardwareMethod) &cHardware4Stack::Inst_HeadPush);
- //22
- inst_dict.Add("Head-Pop", (tHardwareMethod) &cHardware4Stack::Inst_HeadPop);
- //23
- inst_dict.Add("Head-Move", (tHardwareMethod) &cHardware4Stack::Inst_MoveHead);
- //24
- inst_dict.Add("Search", (tHardwareMethod) &cHardware4Stack::Inst_HeadSearch);
- //25
- inst_dict.Add("Push-Next", (tHardwareMethod) &cHardware4Stack::Inst_PushA);
- //26
- inst_dict.Add("Push-Prev", (tHardwareMethod) &cHardware4Stack::Inst_PushB);
- //27
- inst_dict.Add("Push-Comp", (tHardwareMethod) &cHardware4Stack::Inst_PushC);
- //28 - Not implemented yet...
- //inst_dict.Add("Val-Delete", &cHardware4Stack::Inst_ValDelete
- //29
- inst_dict.Add("Val-Copy", (tHardwareMethod) &cHardware4Stack::Inst_CopyReg);
- //30
- inst_dict.Add("ThreadFork", (tHardwareMethod) &cHardware4Stack::Inst_ForkThread);
- //31
- inst_dict.Add("if-label", (tHardwareMethod) &cHardware4Stack::Inst_IfLabel);
- //32
- inst_dict.Add("Val-Inc", (tHardwareMethod) &cHardware4Stack::Inst_Inc);
- //33
- inst_dict.Add("Val-Dec", (tHardwareMethod) &cHardware4Stack::Inst_Dec);
- //34
- inst_dict.Add("Val-Mod", (tHardwareMethod) &cHardware4Stack::Inst_Mod);
- //35
- inst_dict.Add("ThreadKill", (tHardwareMethod) &cHardware4Stack::Inst_KillThread);/*
- // Remaining instructions.
- inst_dict.Add("nop-X", (tHardwareMethod) &cHardware4Stack::Inst_Nop);
- inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardware4Stack::Inst_If0);
- inst_dict.Add("if-not-0", (tHardwareMethod) &cHardware4Stack::Inst_IfNot0);
- inst_dict.Add("if-n-equ", (tHardwareMethod) &cHardware4Stack::Inst_IfNEqu);
- inst_dict.Add("if-equ", (tHardwareMethod) &cHardware4Stack::Inst_IfEqu);
- inst_dict.Add("if-grt-0", (tHardwareMethod) &cHardware4Stack::Inst_IfGr0);
- inst_dict.Add("if-grt", (tHardwareMethod) &cHardware4Stack::Inst_IfGr);
- inst_dict.Add("if->=-0", (tHardwareMethod) &cHardware4Stack::Inst_IfGrEqu0);
- inst_dict.Add("if->=", (tHardwareMethod) &cHardware4Stack::Inst_IfGrEqu);
- inst_dict.Add("if-les-0", (tHardwareMethod) &cHardware4Stack::Inst_IfLess0);
- inst_dict.Add("if-less", (tHardwareMethod) &cHardware4Stack::Inst_IfLess);
- inst_dict.Add("if-<=-0", (tHardwareMethod) &cHardware4Stack::Inst_IfLsEqu0);
- inst_dict.Add("if-<=", (tHardwareMethod) &cHardware4Stack::Inst_IfLsEqu);
- inst_dict.Add("if-A!=B", (tHardwareMethod) &cHardware4Stack::Inst_IfANotEqB);
- inst_dict.Add("if-B!=C", (tHardwareMethod) &cHardware4Stack::Inst_IfBNotEqC);
- inst_dict.Add("if-A!=C", (tHardwareMethod) &cHardware4Stack::Inst_IfANotEqC);
-
- inst_dict.Add("if-bit-1", (tHardwareMethod) &cHardware4Stack::Inst_IfBit1);
- inst_dict.Add("jump-f", (tHardwareMethod) &cHardware4Stack::Inst_JumpF);
- inst_dict.Add("jump-b", (tHardwareMethod) &cHardware4Stack::Inst_JumpB);
- inst_dict.Add("jump-p", (tHardwareMethod) &cHardware4Stack::Inst_JumpP);
- inst_dict.Add("jump-slf", (tHardwareMethod) &cHardware4Stack::Inst_JumpSelf);
- inst_dict.Add("call", (tHardwareMethod) &cHardware4Stack::Inst_Call);
- inst_dict.Add("return", (tHardwareMethod) &cHardware4Stack::Inst_Return);
-
- inst_dict.Add("pop", (tHardwareMethod) &cHardware4Stack::Inst_Pop);
- inst_dict.Add("push", (tHardwareMethod) &cHardware4Stack::Inst_Push);
- inst_dict.Add("swap-stk",(tHardwareMethod) &cHardware4Stack::Inst_SwitchStack);
- inst_dict.Add("flip-stk",(tHardwareMethod) &cHardware4Stack::Inst_FlipStack);
- inst_dict.Add("swap", (tHardwareMethod) &cHardware4Stack::Inst_Swap);
- inst_dict.Add("swap-AB", (tHardwareMethod) &cHardware4Stack::Inst_SwapAB);
- inst_dict.Add("swap-BC", (tHardwareMethod) &cHardware4Stack::Inst_SwapBC);
- inst_dict.Add("swap-AC", (tHardwareMethod) &cHardware4Stack::Inst_SwapAC);
- inst_dict.Add("copy-reg",(tHardwareMethod) &cHardware4Stack::Inst_CopyReg);
- inst_dict.Add("set_A=B", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegAB);
- inst_dict.Add("set_A=C", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegAC);
- inst_dict.Add("set_B=A", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegBA);
- inst_dict.Add("set_B=C", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegBC);
- inst_dict.Add("set_C=A", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegCA);
- inst_dict.Add("set_C=B", (tHardwareMethod) &cHardware4Stack::Inst_CopyRegCB);
- inst_dict.Add("reset", (tHardwareMethod) &cHardware4Stack::Inst_Reset);
-
- inst_dict.Add("pop-A", (tHardwareMethod) &cHardware4Stack::Inst_PopA);
- inst_dict.Add("pop-B", (tHardwareMethod) &cHardware4Stack::Inst_PopB);
- inst_dict.Add("pop-C", (tHardwareMethod) &cHardware4Stack::Inst_PopC);
- // inst_dict.Add("push-A", (tHardwareMethod) &cHardware4Stack::Inst_PushA);
- inst_dict.Add("push-B", (tHardwareMethod) &cHardware4Stack::Inst_PushB);
- inst_dict.Add("push-C", (tHardwareMethod) &cHardware4Stack::Inst_PushC);
-
- inst_dict.Add("shift-r", (tHardwareMethod) &cHardware4Stack::Inst_ShiftR);
- inst_dict.Add("shift-l", (tHardwareMethod) &cHardware4Stack::Inst_ShiftL);
- inst_dict.Add("bit-1", (tHardwareMethod) &cHardware4Stack::Inst_Bit1);
- inst_dict.Add("set-num", (tHardwareMethod) &cHardware4Stack::Inst_SetNum);
- inst_dict.Add("inc", (tHardwareMethod) &cHardware4Stack::Inst_Inc);
- inst_dict.Add("dec", (tHardwareMethod) &cHardware4Stack::Inst_Dec);
- inst_dict.Add("zero", (tHardwareMethod) &cHardware4Stack::Inst_Zero);
- inst_dict.Add("neg", (tHardwareMethod) &cHardware4Stack::Inst_Neg);
- inst_dict.Add("square", (tHardwareMethod) &cHardware4Stack::Inst_Square);
- inst_dict.Add("sqrt", (tHardwareMethod) &cHardware4Stack::Inst_Sqrt);
- inst_dict.Add("not", (tHardwareMethod) &cHardware4Stack::Inst_Not);
- inst_dict.Add("log", (tHardwareMethod) &cHardware4Stack::Inst_Log);
- inst_dict.Add("log10", (tHardwareMethod) &cHardware4Stack::Inst_Log10);
- inst_dict.Add("minus-18",(tHardwareMethod) &cHardware4Stack::Inst_Minus18);
-
- inst_dict.Add("add", (tHardwareMethod) &cHardware4Stack::Inst_Add);
- inst_dict.Add("sub", (tHardwareMethod) &cHardware4Stack::Inst_Sub);
- inst_dict.Add("mult", (tHardwareMethod) &cHardware4Stack::Inst_Mult);
- inst_dict.Add("div", (tHardwareMethod) &cHardware4Stack::Inst_Div);
- inst_dict.Add("mod", (tHardwareMethod) &cHardware4Stack::Inst_Mod);
- inst_dict.Add("nand", (tHardwareMethod) &cHardware4Stack::Inst_Nand);
- inst_dict.Add("nor", (tHardwareMethod) &cHardware4Stack::Inst_Nor);
- inst_dict.Add("and", (tHardwareMethod) &cHardware4Stack::Inst_And);
- inst_dict.Add("order", (tHardwareMethod) &cHardware4Stack::Inst_Order);
- inst_dict.Add("xor", (tHardwareMethod) &cHardware4Stack::Inst_Xor);
-
- inst_dict.Add("copy", (tHardwareMethod)&cHardware4Stack::Inst_Copy);
- inst_dict.Add("read", (tHardwareMethod)&cHardware4Stack::Inst_ReadInst);
- inst_dict.Add("write", (tHardwareMethod)&cHardware4Stack::Inst_WriteInst);
- inst_dict.Add("stk-read",(tHardwareMethod)&cHardware4Stack::Inst_StackReadInst);
- inst_dict.Add("stk-writ",(tHardwareMethod)&cHardware4Stack::Inst_StackWriteInst);
-
- inst_dict.Add("compare", (tHardwareMethod) &cHardware4Stack::Inst_Compare);
- inst_dict.Add("if-n-cpy", (tHardwareMethod) &cHardware4Stack::Inst_IfNCpy);
- inst_dict.Add("allocate", (tHardwareMethod) &cHardware4Stack::Inst_Allocate);
- inst_dict.Add("divide", (tHardwareMethod) &cHardware4Stack::Inst_Divide);
- inst_dict.Add("c-alloc", (tHardwareMethod) &cHardware4Stack::Inst_CAlloc);
- inst_dict.Add("c-divide", (tHardwareMethod) &cHardware4Stack::Inst_CDivide);
- inst_dict.Add("inject", (tHardwareMethod) &cHardware4Stack::Inst_Inject);
- inst_dict.Add("inject-r", (tHardwareMethod) &cHardware4Stack::Inst_InjectRand);
- inst_dict.Add("inject-th", (tHardwareMethod) &cHardware4Stack::Inst_InjectThread);
-
- inst_dict.Add("get", (tHardwareMethod)&cHardware4Stack::Inst_TaskGet);
- inst_dict.Add("stk-get", (tHardwareMethod)&cHardware4Stack::Inst_TaskStackGet);
- inst_dict.Add("stk-load",(tHardwareMethod)&cHardware4Stack::Inst_TaskStackLoad);
- inst_dict.Add("put", (tHardwareMethod)&cHardware4Stack::Inst_TaskPut);
- inst_dict.Add("IO", (tHardwareMethod)&cHardware4Stack::Inst_TaskIO);
- inst_dict.Add("search-f",(tHardwareMethod)&cHardware4Stack::Inst_SearchF);
- inst_dict.Add("search-b",(tHardwareMethod)&cHardware4Stack::Inst_SearchB);
- inst_dict.Add("mem-size",(tHardwareMethod)&cHardware4Stack::Inst_MemSize);
-
- inst_dict.Add("rotate-l", (tHardwareMethod) &cHardware4Stack::Inst_RotateL);
- inst_dict.Add("rotate-r", (tHardwareMethod) &cHardware4Stack::Inst_RotateR);
-
- inst_dict.Add("set-cmut", (tHardwareMethod) &cHardware4Stack::Inst_SetCopyMut);
- inst_dict.Add("mod-cmut", (tHardwareMethod) &cHardware4Stack::Inst_ModCopyMut);
-
- // Threading instructions
- inst_dict.Add("fork-th", (tHardwareMethod) &cHardware4Stack::Inst_ForkThread);
- inst_dict.Add("kill-th", (tHardwareMethod) &cHardware4Stack::Inst_KillThread);
- inst_dict.Add("id-th", (tHardwareMethod) &cHardware4Stack::Inst_ThreadID);
-
- // Head-based instructions
- inst_dict.Add("h-alloc", (tHardwareMethod) &cHardware4Stack::Inst_MaxAlloc);
- inst_dict.Add("h-divide", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide);
- inst_dict.Add("h-read", (tHardwareMethod) &cHardware4Stack::Inst_HeadRead);
- inst_dict.Add("h-write", (tHardwareMethod) &cHardware4Stack::Inst_HeadWrite);
- inst_dict.Add("h-copy", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy);
- inst_dict.Add("h-search", (tHardwareMethod) &cHardware4Stack::Inst_HeadSearch);
- inst_dict.Add("h-push", (tHardwareMethod) &cHardware4Stack::Inst_HeadPush);
- inst_dict.Add("h-pop", (tHardwareMethod) &cHardware4Stack::Inst_HeadPop);
- inst_dict.Add("set-head", (tHardwareMethod) &cHardware4Stack::Inst_SetHead);
- inst_dict.Add("adv-head", (tHardwareMethod) &cHardware4Stack::Inst_AdvanceHead);
- inst_dict.Add("mov-head", (tHardwareMethod) &cHardware4Stack::Inst_MoveHead);
- inst_dict.Add("jmp-head", (tHardwareMethod) &cHardware4Stack::Inst_JumpHead);
- inst_dict.Add("get-head", (tHardwareMethod) &cHardware4Stack::Inst_GetHead);
- inst_dict.Add("if-label", (tHardwareMethod) &cHardware4Stack::Inst_IfLabel);
- inst_dict.Add("set-flow", (tHardwareMethod) &cHardware4Stack::Inst_SetFlow);
-
- inst_dict.Add("h-copy2", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy2);
- inst_dict.Add("h-copy3", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy3);
- inst_dict.Add("h-copy4", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy4);
- inst_dict.Add("h-copy5", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy5);
- inst_dict.Add("h-copy6", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy6);
- inst_dict.Add("h-copy7", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy7);
- inst_dict.Add("h-copy8", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy8);
- inst_dict.Add("h-copy9", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy9);
- inst_dict.Add("h-copy10", (tHardwareMethod) &cHardware4Stack::Inst_HeadCopy10);
-
-
- inst_dict.Add("divide-sex", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivideSex);
- inst_dict.Add("divide-asex", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1);
-
- inst_dict.Add("h-divide1", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1);
- inst_dict.Add("h-divide2", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide2);
- inst_dict.Add("h-divide3", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide3);
- inst_dict.Add("h-divide4", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide4);
- inst_dict.Add("h-divide5", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide5);
- inst_dict.Add("h-divide6", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide6);
- inst_dict.Add("h-divide7", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide7);
- inst_dict.Add("h-divide8", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide8);
- inst_dict.Add("h-divide9", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide9);
- inst_dict.Add("h-divide10", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide10);
- inst_dict.Add("h-divide16", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide16);
- inst_dict.Add("h-divide32", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide32);
- inst_dict.Add("h-divide50", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide50);
- inst_dict.Add("h-divide100", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide100);
- inst_dict.Add("h-divide500", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide500);
- inst_dict.Add("h-divide1000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide1000);
- inst_dict.Add("h-divide5000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide5000);
- inst_dict.Add("h-divide10000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide10000);
- inst_dict.Add("h-divide50000", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide50000);
- inst_dict.Add("h-divide0.5", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_5);
- inst_dict.Add("h-divide0.1", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_1);
- inst_dict.Add("h-divide0.05", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_05);
- inst_dict.Add("h-divide0.01", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_01);
- inst_dict.Add("h-divide0.001", (tHardwareMethod) &cHardware4Stack::Inst_HeadDivide0_001);
-
- // High-level instructions
- inst_dict.Add("repro", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-A", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-B", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-C", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-D", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-E", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-F", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-G", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-H", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-I", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-J", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-K", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-L", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-M", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-N", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-O", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-P", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Q", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-R", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-S", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-T", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-U", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-V", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-W", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-X", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Y", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
- inst_dict.Add("repro-Z", (tHardwareMethod) &cHardware4Stack::Inst_Repro);
-
- // Placebo instructions
- // nop-x (included with nops)
- inst_dict.Add("skip", (tHardwareMethod) &cHardware4Stack::Inst_Skip);
- */
- cout << "BLEE! Instruction Library in util has " << inst_dict.GetSize()
- << " instructions + " << nop_dict.GetSize() << " nops." << endl;
-
-#endif /* !USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
@@ -681,8 +143,6 @@
tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
cout << "Instruction Library in util has " << inst_dict.GetSize()
<< " instructions and " << nop_dict.GetSize() << " nops." << endl;
@@ -700,15 +160,11 @@
// set it up.
if (inst_filename != "" && inst_set.GetSize() == 0) {
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
inst_set.SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
LoadInstSet_CPUOriginal(inst_filename, inst_set);
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
inst_set.SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
LoadInstSet_CPU4Stack(inst_filename, inst_set);
}
}
Index: avida/current/source/cpu/hardware_util.hh
diff -u avida/current/source/cpu/hardware_util.hh:1.6.2.2 avida/current/source/cpu/hardware_util.hh:1.6.2.3
--- avida/current/source/cpu/hardware_util.hh:1.6.2.2 Tue May 27 11:45:37 2003
+++ avida/current/source/cpu/hardware_util.hh Tue Aug 19 10:49:29 2003
@@ -19,13 +19,8 @@
class cHardwareUtil {
public:
-#ifdef USE_INST_SET_CODE
static void LoadInstSet( cString filename, cInstSet & inst_set,
tDictionary<int> & nop_dict, tDictionary<int> & inst_dict );
-#else /* USE_INST_SET_CODE */
- static void LoadInstSet( cString filename, cInstSet & inst_set,
- tDictionary<int> & nop_dict, tDictionary<tHardwareMethod> & inst_dict);
-#endif /* USE_INST_SET_CODE */
static void LoadInstSet_CPUOriginal(const cString & filename,
cInstSet & inst_set);
static void LoadInstSet_CPU4Stack(const cString & filename,
Index: avida/current/source/cpu/head.cc
diff -u avida/current/source/cpu/head.cc:1.20 avida/current/source/cpu/head.cc:1.20.2.1
--- avida/current/source/cpu/head.cc:1.20 Sat May 17 14:54:54 2003
+++ avida/current/source/cpu/head.cc Tue Aug 19 10:49:29 2003
@@ -256,8 +256,6 @@
return cur_hardware->GetMemory().FlagCopyMut(position);
}
-
-
cCPUHead & cCPUHead::operator=(const cCPUHead & in_cpu_head)
{
main_hardware = in_cpu_head.main_hardware;
@@ -452,6 +450,10 @@
return pos;
}
+bool cCPUHead::operator==(const cCPUHead & in_cpu_head) const {
+ return (cur_hardware == in_cpu_head.cur_hardware) &&
+ (position == in_cpu_head.position);
+}
bool cCPUHead::AtEnd() const
{
@@ -467,4 +469,202 @@
{
// If CPU has a head in another creature, mark it as a parasite.
return (cur_hardware != main_hardware);
+}
+
+c4StackHead::c4StackHead() : cCPUHead() { mem_space=0; }
+
+c4StackHead::c4StackHead(cHardwareBase * in_hardware, int in_pos, int in_mem_space)
+ : cCPUHead(in_hardware, in_pos) { mem_space = in_mem_space; }
+
+c4StackHead::c4StackHead(const c4StackHead & in_head) : cCPUHead(in_head)
+{
+ mem_space = in_head.mem_space;
+}
+
+void c4StackHead::Adjust()
+{
+ assert(cur_hardware != NULL);
+ assert(main_hardware != NULL);
+
+ const int mem_size = GetMemory().GetSize();
+
+ // If we are still in range, stop here!
+ if (position >= 0 && position < mem_size) return;
+
+ // If the memory is gone, just stick it at the begining of its parent.
+ if (mem_size == 0) {
+ cur_hardware = main_hardware;
+ position = 0;
+ }
+ else if (position <= 0) { position = 0; }
+ else if (position >= mem_size) {
+ // Always loop into the begining of the owner hardware.
+ cur_hardware = main_hardware;
+ position -= mem_size;
+ while (position >= GetMemory().GetSize()) {
+ // position back at the begining of the creature.
+ position %= GetMemory().GetSize();
+ }
+ }
+}
+
+void c4StackHead::Reset(int in_mem_space, cHardwareBase * new_hardware)
+{
+ if (new_hardware) main_hardware = new_hardware;
+ cur_hardware = new_hardware;
+ position = 0;
+ mem_space = in_mem_space;
+}
+
+void c4StackHead::Set(int new_pos, int in_mem_space, cHardwareBase * in_hardware)
+{
+ position = new_pos;
+ if (in_hardware) cur_hardware = in_hardware;
+ mem_space = in_mem_space;
+ Adjust();
+}
+
+void c4StackHead::Set(const c4StackHead & in_head)
+{
+ position = in_head.position;
+ cur_hardware = in_head.cur_hardware;
+ mem_space = in_head.mem_space;
+ Adjust();
+}
+
+void c4StackHead::LoopJump(int jump)
+{
+ position += jump;
+
+ // If we are out of range, bring back in.
+ if (position < 0 || position >= GetMemory().GetSize()) {
+ position %= GetMemory().GetSize();
+ if (position <= 0) position += GetMemory().GetSize();
+ }
+}
+
+const cCPUMemory & c4StackHead::GetMemory() const
+{
+ assert(cur_hardware != NULL);
+ return cur_hardware->GetMemory(mem_space);
+}
+
+cCPUMemory & c4StackHead::GetMemory()
+{
+ assert(cur_hardware != NULL);
+ return cur_hardware->GetMemory(mem_space);
+}
+
+const cInstruction & c4StackHead::GetInst() const
+{
+ assert(position >= 0);
+ assert(position < GetMemory().GetSize());
+ return GetMemory()[position];
+}
+
+const cInstruction & c4StackHead::GetInst(int offset) const
+{
+ int new_pos = position + offset;
+ return GetMemory()[new_pos];
+}
+
+
+void c4StackHead::SetInst(const cInstruction & value)
+{
+ assert(cur_hardware != NULL);
+#ifdef WRITE_PROTECTION
+ if (main_hardware == cur_hardware) GetMemory()[position] = value;
+#else
+ GetMemory()[position] = value;
+ if (main_hardware != cur_hardware) cur_hardware->SetModified();
+#endif
+}
+
+void c4StackHead::InsertInst(const cInstruction & value)
+{
+ assert(cur_hardware != NULL);
+#ifdef WRITE_PROTECTION
+ if (main_hardware == cur_hardware) GetMemory().Insert(position, value);
+#else
+ GetMemory().Insert(position, value);
+ if (main_hardware != cur_hardware) cur_hardware->SetModified();
+#endif
+}
+
+void c4StackHead::RemoveInst()
+{
+ assert(cur_hardware != NULL);
+#ifdef WRITE_PROTECTION
+ if (main_hardware == cur_hardware) GetMemory().Remove(position);
+#else
+ GetMemory().Remove(position);
+ if (main_hardware != cur_hardware) cur_hardware->SetModified();
+#endif
+}
+
+const cInstruction & c4StackHead::GetNextInst()
+{
+ return (AtEnd()) ? cInstSet::GetInstError() : GetMemory()[position+1];
+}
+
+bool & c4StackHead::FlagCopied()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagCopied(position);
+}
+
+bool & c4StackHead::FlagMutated()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagMutated(position);
+}
+
+bool & c4StackHead::FlagExecuted()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagExecuted(position);
+}
+
+bool & c4StackHead::FlagBreakpoint()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagBreakpoint(position);
+}
+
+bool & c4StackHead::FlagPointMut()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagPointMut(position);
+}
+
+bool & c4StackHead::FlagCopyMut()
+{
+ assert(cur_hardware != NULL);
+ return GetMemory().FlagCopyMut(position);
+}
+
+c4StackHead & c4StackHead::operator=(const c4StackHead & in_cpu_head)
+{
+ main_hardware = in_cpu_head.main_hardware;
+ cur_hardware = in_cpu_head.cur_hardware;
+ position = in_cpu_head.position;
+ mem_space = in_cpu_head.mem_space;
+ return *this;
+}
+
+bool c4StackHead::operator==(const c4StackHead & in_cpu_head) const
+{
+ return (cur_hardware == in_cpu_head.cur_hardware) &&
+ (position == in_cpu_head.position) &&
+ (mem_space == in_cpu_head.mem_space);
+}
+
+bool c4StackHead::AtEnd() const
+{
+ return (position + 1 == GetMemory().GetSize());
+}
+
+bool c4StackHead::InMemory() const
+{
+ return (position >= 0 && position < GetMemory().GetSize());
}
Index: avida/current/source/cpu/head.hh
diff -u avida/current/source/cpu/head.hh:1.10 avida/current/source/cpu/head.hh:1.10.4.1
--- avida/current/source/cpu/head.hh:1.10 Thu Mar 28 04:21:14 2002
+++ avida/current/source/cpu/head.hh Tue Aug 19 10:49:29 2003
@@ -22,7 +22,7 @@
**/
class cCPUHead {
-private:
+protected:
cHardwareBase * main_hardware;
cHardwareBase * cur_hardware;
int position;
@@ -35,22 +35,24 @@
cCPUHead();
cCPUHead(cHardwareBase * in_hardware, int in_pos = 0);
cCPUHead(const cCPUHead & in_cpu_head);
- ~cCPUHead() { ; }
-
- void Reset(cHardwareBase * new_hardware = NULL);
+ virtual ~cCPUHead() { ; }
/**
* This function keeps the position within the range of the current memory.
**/
- void Adjust();
+ virtual void Adjust();
+
+ virtual void Reset(cHardwareBase * new_hardware = NULL);
/**
* Set the new position of the head (and adjust it into range in Set()).
**/
- void Set(int new_pos, cHardwareBase * in_hardware = NULL);
+ virtual void Set(int new_pos, cHardwareBase * in_hardware = NULL);
+
void AbsSet(int new_pos) { position = new_pos; }
- void Set(const cCPUHead & in_head) {
+
+ virtual void Set(const cCPUHead & in_head) {
position = in_head.position;
cur_hardware = in_head.cur_hardware;
}
@@ -60,7 +62,7 @@
**/
void Jump(int jump);
- void LoopJump(int jump);
+ virtual void LoopJump(int jump);
void AbsJump(int jump);
// Other manipulation functions.
@@ -70,27 +72,27 @@
// Accessors.
int GetPosition() const { return position; }
- const cCPUMemory & GetMemory() const;
+ virtual const cCPUMemory & GetMemory() const;
cHardwareBase * GetCurHardware() const { return cur_hardware; }
cHardwareBase * GetMainHardware() const { return main_hardware; }
- const cInstruction & GetInst() const;
- const cInstruction & GetInst(int offset) const;
+ virtual const cInstruction & GetInst() const;
+ virtual const cInstruction & GetInst(int offset) const;
// int GetFlag(int id) const;
- void SetInst(const cInstruction & value);
- void InsertInst(const cInstruction & in_char);
- void RemoveInst();
- const cInstruction & GetNextInst();
-
- bool & FlagCopied();
- bool & FlagMutated();
- bool & FlagExecuted();
- bool & FlagBreakpoint();
- bool & FlagPointMut();
- bool & FlagCopyMut();
+ virtual void SetInst(const cInstruction & value);
+ virtual void InsertInst(const cInstruction & in_char);
+ virtual void RemoveInst();
+ virtual const cInstruction & GetNextInst();
+
+ virtual bool & FlagCopied();
+ virtual bool & FlagMutated();
+ virtual bool & FlagExecuted();
+ virtual bool & FlagBreakpoint();
+ virtual bool & FlagPointMut();
+ virtual bool & FlagCopyMut();
// Operator Overloading...
- cCPUHead & operator=(const cCPUHead & in_cpu_head);
+ virtual cCPUHead & operator=(const cCPUHead & in_cpu_head);
cCPUHead & operator++();
cCPUHead & operator--();
cCPUHead & operator++(int);
@@ -100,19 +102,59 @@
if (cur_hardware != in_cpu_head.cur_hardware) return 0;
else return position - in_cpu_head.position;
}
- inline int operator==(const cCPUHead & in_cpu_head) const {
- return (cur_hardware == in_cpu_head.cur_hardware) &&
- (position == in_cpu_head.position);
- }
+ virtual bool operator==(const cCPUHead & in_cpu_head) const;
// Bool Tests...
inline bool AtFront() const { return (position == 0); }
- bool AtEnd() const;
- bool InMemory() const;
+ virtual bool AtEnd() const;
+ virtual bool InMemory() const;
// Test functions...
int TestParasite() const;
};
+class c4StackHead : public cCPUHead
+{
+private:
+ int mem_space;
+
+public:
+
+ c4StackHead();
+ c4StackHead(cHardwareBase * in_hardware, int in_pos = 0, int mem_space = 0);
+ c4StackHead(const c4StackHead & in_cpu_head);
+
+ void Adjust();
+ void Reset(int in_mem_space=0, cHardwareBase * new_hardware = NULL);
+ void Set(int new_pos, int in_mem_space = 0, cHardwareBase * in_hardware = NULL);
+ void Set(const c4StackHead & in_head);
+ void LoopJump(int jump);
+ const cCPUMemory & GetMemory() const;
+ cCPUMemory & GetMemory();
+ const cInstruction & GetInst() const;
+ const cInstruction & GetInst(int offset) const;
+
+ int GetMemSpace() const { return mem_space; }
+
+ void SetInst(const cInstruction & value);
+ void InsertInst(const cInstruction & in_char);
+ void RemoveInst();
+ const cInstruction & GetNextInst();
+
+ bool & FlagCopied();
+ bool & FlagMutated();
+ bool & FlagExecuted();
+ bool & FlagBreakpoint();
+ bool & FlagPointMut();
+ bool & FlagCopyMut();
+
+ // Operator Overloading...
+ c4StackHead & operator=(const c4StackHead & in_cpu_head);
+ bool operator==(const c4StackHead & in_cpu_head) const;
+ bool AtEnd() const;
+ bool InMemory() const;
+};
#endif
+
+
Index: avida/current/source/cpu/test_cpu.cc
diff -u avida/current/source/cpu/test_cpu.cc:1.42 avida/current/source/cpu/test_cpu.cc:1.42.2.1
--- avida/current/source/cpu/test_cpu.cc:1.42 Sun May 18 11:59:24 2003
+++ avida/current/source/cpu/test_cpu.cc Tue Aug 19 10:49:29 2003
@@ -396,6 +396,12 @@
return input_array[cur_input++];
}
+int cTestCPU::GetInputAt(int & input_pointer)
+{
+ if (input_pointer >= input_array.GetSize()) input_pointer = 0;
+ return input_array[input_pointer++];
+}
+
const tArray<double> & cTestCPU::GetResources()
{
assert(resource_count != NULL);
Index: avida/current/source/cpu/test_cpu.hh
diff -u avida/current/source/cpu/test_cpu.hh:1.31 avida/current/source/cpu/test_cpu.hh:1.31.2.1
--- avida/current/source/cpu/test_cpu.hh:1.31 Sat May 17 14:23:25 2003
+++ avida/current/source/cpu/test_cpu.hh Tue Aug 19 10:49:29 2003
@@ -134,6 +134,7 @@
static cInstSet * GetInstSet() { return inst_set; }
static cEnvironment * GetEnvironment() { return environment; }
static int GetInput();
+ static int GetInputAt(int & input_pointer);
static const tArray<double> & GetResources();
static void UpdateResources(const tArray<double> & res_change);
};
Index: avida/current/source/event/cPopulation.events
diff -u avida/current/source/event/cPopulation.events:1.40 avida/current/source/event/cPopulation.events:1.40.2.1
--- avida/current/source/event/cPopulation.events:1.40 Tue May 20 14:07:00 2003
+++ avida/current/source/event/cPopulation.events Tue Aug 19 10:49:29 2003
@@ -783,6 +783,111 @@
cInstUtil::RandomGenome(length, population->GetEnvironment().GetInstSet());
population->Inject(genome, cell_id, merit, lineage_label, neutral_metric);
+inject_range_parasite
+:descr:
+/**
+* Injects identical organisms into a range of cells of the population.
+*
+* Parameters:
+* filename (string)
+* The filename of the genotype to load. If this is left empty, or the keyword
+* "START_CREATURE" is given, than the genotype specified in the genesis
+* file under "START_CREATURE" is used.
+* start_cell (int)
+* First cell to inject into.
+* stop_cell (int)
+* First cell *not* to inject into.
+* merit (double) default: -1
+* The initial merit of the organism. If set to -1, this is ignored.
+* lineage label (integer) default: 0
+* An integer that marks all descendants of this organism.
+* neutral metric (double) default: 0
+* A double value that randomly drifts over time.
+*
+* Example:
+* inject_range creature.gen 0 10
+*
+* Will inject 10 organisms into cells 0 through 9.
+**/
+:args:
+cString fname_parasite "organism.parasite"
+int start_cell 0
+int end_cell -1
+double merit -1
+int lineage_label 0
+double neutral_metric 0
+int mem_space 2
+:body:
+if (fname_parasite == "START_CREATURE") fname_parasite=cConfig::GetStartCreature();
+if (end_cell == -1) end_cell = start_cell + 1;
+if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+}
+else {
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+}
+
+inject_range_pair
+:descr:
+/**
+* Injects identical organisms into a range of cells of the population.
+*
+* Parameters:
+* filename (string)
+* The filename of the genotype to load. If this is left empty, or the keyword
+* "START_CREATURE" is given, than the genotype specified in the genesis
+* file under "START_CREATURE" is used.
+* start_cell (int)
+* First cell to inject into.
+* stop_cell (int)
+* First cell *not* to inject into.
+* merit (double) default: -1
+* The initial merit of the organism. If set to -1, this is ignored.
+* lineage label (integer) default: 0
+* An integer that marks all descendants of this organism.
+* neutral metric (double) default: 0
+* A double value that randomly drifts over time.
+*
+* Example:
+* inject_range creature.gen 0 10
+*
+* Will inject 10 organisms into cells 0 through 9.
+**/
+:args:
+cString fname "START_CREATURE"
+cString fname_parasite "organism.parasite"
+int start_cell 0
+int end_cell -1
+double merit -1
+int lineage_label 0
+double neutral_metric 0
+int mem_space 2
+:body:
+if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+if (end_cell == -1) end_cell = start_cell + 1;
+if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+}
+else {
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+}
################ MUTATION RATES ###############
zero_muts
Index: avida/current/source/event/cPopulation_construct_event_auto.ci
diff -u avida/current/source/event/cPopulation_construct_event_auto.ci:1.1.2.1 avida/current/source/event/cPopulation_construct_event_auto.ci:1.1.2.2
--- avida/current/source/event/cPopulation_construct_event_auto.ci:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_construct_event_auto.ci Tue Aug 19 10:49:29 2003
@@ -130,6 +130,12 @@
case cPopulationEventFactory::EVENT_inject_random :
event = new cPopulationEventinject_random(arg_list);
break;
+ case cPopulationEventFactory::EVENT_inject_range_parasite :
+ event = new cPopulationEventinject_range_parasite(arg_list);
+ break;
+ case cPopulationEventFactory::EVENT_inject_range_pair :
+ event = new cPopulationEventinject_range_pair(arg_list);
+ break;
case cPopulationEventFactory::EVENT_zero_muts :
event = new cPopulationEventzero_muts(arg_list);
break;
Index: avida/current/source/event/cPopulation_descr.ci
diff -u avida/current/source/event/cPopulation_descr.ci:1.1.2.1 avida/current/source/event/cPopulation_descr.ci:1.1.2.2
--- avida/current/source/event/cPopulation_descr.ci:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_descr.ci Tue Aug 19 10:49:29 2003
@@ -43,6 +43,8 @@
cEventEntry( "inject_range", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n The filename of the genotype to load. If this is left empty, or the keyword\n \"START_CREATURE\" is given, than the genotype specified in the genesis\n file under \"START_CREATURE\" is used.\nstart_cell (int)\n First cell to inject into.\nstop_cell (int)\n First cell *not* to inject into.\nmerit (double) default: -1\n The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n A double value that randomly drifts over time.\n\nExample:\n inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
cEventEntry( "inject_sequence", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nsequence (string)\n The genome sequence for this organism. This is a mandatory argument.\nstart_cell (int)\n First cell to inject into.\nstop_cell (int)\n First cell *not* to inject into.\nmerit (double) default: -1\n The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n A double value that randomly drifts over time.\n\nExample:\n inject_range ckdfhgklsahnfsaggdsgajfg 0 10 100\n\nWill inject 10 organisms into cells 0 through 9 with a merit of 100.\n" ),
cEventEntry( "inject_random", "Injects a randomly generated genome into the population.\n\nParameters:\nlength (integer) [required]\n Number of instructions in the randomly generated genome.\ncell ID (integer) default: -1\n The grid-point into which the genome should be placed. Default is random.\nmerit (double) default: -1\n The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n A double value that randomly drifts over time.\n" ),
+ cEventEntry( "inject_range_parasite", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n The filename of the genotype to load. If this is left empty, or the keyword\n \"START_CREATURE\" is given, than the genotype specified in the genesis\n file under \"START_CREATURE\" is used.\nstart_cell (int)\n First cell to inject into.\nstop_cell (int)\n First cell *not* to inject into.\nmerit (double) default: -1\n The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n A double value that randomly drifts over time.\n\nExample:\n inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
+ cEventEntry( "inject_range_pair", "Injects identical organisms into a range of cells of the population.\n\nParameters:\nfilename (string)\n The filename of the genotype to load. If this is left empty, or the keyword\n \"START_CREATURE\" is given, than the genotype specified in the genesis\n file under \"START_CREATURE\" is used.\nstart_cell (int)\n First cell to inject into.\nstop_cell (int)\n First cell *not* to inject into.\nmerit (double) default: -1\n The initial merit of the organism. If set to -1, this is ignored.\nlineage label (integer) default: 0\n An integer that marks all descendants of this organism.\nneutral metric (double) default: 0\n A double value that randomly drifts over time.\n\nExample:\n inject_range creature.gen 0 10\n\nWill inject 10 organisms into cells 0 through 9.\n" ),
cEventEntry( "zero_muts", "This event will set all mutation rates to zero...\n" ),
cEventEntry( "mod_copy_mut", "\n" ),
cEventEntry( "mod_div_mut", "\n" ),
@@ -80,5 +82,5 @@
cEventEntry( "inject_resource", "Inject (add) a specified amount of a specified resource.\n" ),
cEventEntry( "set_resource", "Set the resource amount to a specific level\n" ) };
-const int cEventDescrs::num_of_events = 80;
+const int cEventDescrs::num_of_events = 82;
Index: avida/current/source/event/cPopulation_enums_auto.ci
diff -u avida/current/source/event/cPopulation_enums_auto.ci:1.1.2.1 avida/current/source/event/cPopulation_enums_auto.ci:1.1.2.2
--- avida/current/source/event/cPopulation_enums_auto.ci:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_enums_auto.ci Tue Aug 19 10:49:29 2003
@@ -43,6 +43,8 @@
EVENT_inject_range,
EVENT_inject_sequence,
EVENT_inject_random,
+ EVENT_inject_range_parasite,
+ EVENT_inject_range_pair,
EVENT_zero_muts,
EVENT_mod_copy_mut,
EVENT_mod_div_mut,
Index: avida/current/source/event/cPopulation_event_list
diff -u avida/current/source/event/cPopulation_event_list:1.1.2.1 avida/current/source/event/cPopulation_event_list:1.1.2.2
--- avida/current/source/event/cPopulation_event_list:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_event_list Tue Aug 19 10:49:29 2003
@@ -44,6 +44,8 @@
inject_range [cString fname="START_CREATURE"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
inject_sequence <cString seq> [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
inject_random <int length> [int cell_id=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0]
+inject_range_parasite [cString fname_parasite="organism.parasite"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]
+inject_range_pair [cString fname="START_CREATURE"] [cString fname_parasite="organism.parasite"] [int start_cell=0] [int end_cell=-1] [double merit=-1] [int lineage_label=0] [double neutral_metric=0] [int mem_space=2]
zero_muts
mod_copy_mut <double cmut_inc> [int cell=-1]
mod_div_mut <double dmut_inc> [int cell=-1]
Index: avida/current/source/event/cPopulation_name2enum_auto.ci
diff -u avida/current/source/event/cPopulation_name2enum_auto.ci:1.1.2.1 avida/current/source/event/cPopulation_name2enum_auto.ci:1.1.2.2
--- avida/current/source/event/cPopulation_name2enum_auto.ci:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_name2enum_auto.ci Tue Aug 19 10:49:29 2003
@@ -89,6 +89,10 @@
return cPopulationEventFactory::EVENT_inject_sequence;
}else if (name == "inject_random") {
return cPopulationEventFactory::EVENT_inject_random;
+ }else if (name == "inject_range_parasite") {
+ return cPopulationEventFactory::EVENT_inject_range_parasite;
+ }else if (name == "inject_range_pair") {
+ return cPopulationEventFactory::EVENT_inject_range_pair;
}else if (name == "zero_muts") {
return cPopulationEventFactory::EVENT_zero_muts;
}else if (name == "mod_copy_mut") {
Index: avida/current/source/event/cPopulation_process_auto.ci
diff -u avida/current/source/event/cPopulation_process_auto.ci:1.1.2.1 avida/current/source/event/cPopulation_process_auto.ci:1.1.2.2
--- avida/current/source/event/cPopulation_process_auto.ci:1.1.2.1 Thu May 22 15:50:05 2003
+++ avida/current/source/event/cPopulation_process_auto.ci Tue Aug 19 10:49:29 2003
@@ -1360,6 +1360,151 @@
}
};
+///// inject_range_parasite /////
+
+/**
+* Injects identical organisms into a range of cells of the population.
+*
+* Parameters:
+* filename (string)
+* The filename of the genotype to load. If this is left empty, or the keyword
+* "START_CREATURE" is given, than the genotype specified in the genesis
+* file under "START_CREATURE" is used.
+* start_cell (int)
+* First cell to inject into.
+* stop_cell (int)
+* First cell *not* to inject into.
+* merit (double) default: -1
+* The initial merit of the organism. If set to -1, this is ignored.
+* lineage label (integer) default: 0
+* An integer that marks all descendants of this organism.
+* neutral metric (double) default: 0
+* A double value that randomly drifts over time.
+*
+* Example:
+* inject_range creature.gen 0 10
+*
+* Will inject 10 organisms into cells 0 through 9.
+**/
+
+
+class cPopulationEventinject_range_parasite : public cPopulationEvent {
+private:
+ cString fname_parasite;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ int mem_space;
+public:
+ cPopulationEventinject_range_parasite(const cString & in_args):
+ cPopulationEvent("inject_range_parasite", in_args) {
+
+ cString args(in_args);
+ if (args == "") fname_parasite="organism.parasite"; else fname_parasite=args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ if (args == "") mem_space=2; else mem_space=args.PopWord().AsInt();
+ }
+///// inject_range_parasite /////
+ void Process(){
+ if (fname_parasite == "START_CREATURE") fname_parasite=cConfig::GetStartCreature();
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+ }
+ else {
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+};
+
+///// inject_range_pair /////
+
+/**
+* Injects identical organisms into a range of cells of the population.
+*
+* Parameters:
+* filename (string)
+* The filename of the genotype to load. If this is left empty, or the keyword
+* "START_CREATURE" is given, than the genotype specified in the genesis
+* file under "START_CREATURE" is used.
+* start_cell (int)
+* First cell to inject into.
+* stop_cell (int)
+* First cell *not* to inject into.
+* merit (double) default: -1
+* The initial merit of the organism. If set to -1, this is ignored.
+* lineage label (integer) default: 0
+* An integer that marks all descendants of this organism.
+* neutral metric (double) default: 0
+* A double value that randomly drifts over time.
+*
+* Example:
+* inject_range creature.gen 0 10
+*
+* Will inject 10 organisms into cells 0 through 9.
+**/
+
+
+class cPopulationEventinject_range_pair : public cPopulationEvent {
+private:
+ cString fname;
+ cString fname_parasite;
+ int start_cell;
+ int end_cell;
+ double merit;
+ int lineage_label;
+ double neutral_metric;
+ int mem_space;
+public:
+ cPopulationEventinject_range_pair(const cString & in_args):
+ cPopulationEvent("inject_range_pair", in_args) {
+
+ cString args(in_args);
+ if (args == "") fname="START_CREATURE"; else fname=args.PopWord();
+ if (args == "") fname_parasite="organism.parasite"; else fname_parasite=args.PopWord();
+ if (args == "") start_cell=0; else start_cell=args.PopWord().AsInt();
+ if (args == "") end_cell=-1; else end_cell=args.PopWord().AsInt();
+ if (args == "") merit=-1; else merit=args.PopWord().AsDouble();
+ if (args == "") lineage_label=0; else lineage_label=args.PopWord().AsInt();
+ if (args == "") neutral_metric=0; else neutral_metric=args.PopWord().AsDouble();
+ if (args == "") mem_space=2; else mem_space=args.PopWord().AsInt();
+ }
+///// inject_range_pair /////
+ void Process(){
+ if (fname == "START_CREATURE") fname=cConfig::GetStartCreature();
+ if (end_cell == -1) end_cell = start_cell + 1;
+ if (start_cell < 0 ||
+ end_cell > population->GetSize() ||
+ start_cell >= end_cell) {
+ cout << "Warning: inject_range has invalid range!";
+ }
+ else {
+ cGenome genome =
+ cInstUtil::LoadGenome(fname, population->GetEnvironment().GetInstSet());
+ cGenome genome_parasite =
+ cInstUtil::LoadGenome(fname_parasite, population->GetEnvironment().GetInstSet());
+ for (int i = start_cell; i < end_cell; i++) {
+ population->Inject(genome, i, merit, lineage_label, neutral_metric);
+ population->Inject(genome_parasite, i, merit, lineage_label, neutral_metric, mem_space);
+ }
+ population->SetSyncEvents(true);
+ }
+ }
+};
+
///// zero_muts /////
/**
Index: avida/current/source/main/Makefile.am
diff -u avida/current/source/main/Makefile.am:1.26.2.1 avida/current/source/main/Makefile.am:1.26.2.2
--- avida/current/source/main/Makefile.am:1.26.2.1 Fri May 23 12:05:37 2003
+++ avida/current/source/main/Makefile.am Tue Aug 19 10:49:29 2003
@@ -16,7 +16,7 @@
#
# don't know why it was needed.
#
-AVIDA_EVENT_DIR = ../event
+AVIDA_EVENT_DIR = $(srcdir)/../event
AVIDA_CPU_DIR = $(srcdir)/../cpu
INCLUDES = -I$(AVIDA_EVENT_DIR) -I$(AVIDA_CPU_DIR)
#
@@ -41,6 +41,7 @@
lineage.hh lineage.cc \
lineage_control.hh lineage_control.cc \
mutations.hh mutations.cc \
+ org_message.hh org_message.cc \
organism.hh organism.cc \
phenotype.hh phenotype.cc \
population.hh population.cc \
Index: avida/current/source/main/analyze.cc
diff -u avida/current/source/main/analyze.cc:1.70.2.2 avida/current/source/main/analyze.cc:1.70.2.3
--- avida/current/source/main/analyze.cc:1.70.2.2 Tue May 27 11:45:38 2003
+++ avida/current/source/main/analyze.cc Tue Aug 19 10:49:29 2003
@@ -1806,8 +1806,6 @@
}
cInstSet map_inst_set(inst_set);
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// Locate instruction corresponding to "NULL" in the instruction library.
{
const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
@@ -1824,12 +1822,6 @@
map_inst_set.Add2(inst_lib_null_inst.GetOp());
}
const cInstruction null_inst = map_inst_set.GetInst("NULL");
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- // Build an empty instruction into the instruction set.
- map_inst_set.Add("NULL", &cHardwareBase::Inst_Nop);
- const cInstruction null_inst = map_inst_set.GetInst("NULL");
-#endif /* USE_INST_SET_CODE */
// Loop through all the lines of code, testing the removal of each.
for (int line_num = 0; line_num < max_line; line_num++) {
@@ -2016,8 +2008,6 @@
// Build an empty instruction into the an instruction library.
cInstSet map_inst_set(inst_set);
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// Locate instruction corresponding to "NULL" in the instruction library.
{
const cInstruction inst_lib_null_inst = map_inst_set.GetInstLib()->GetInst("NULL");
@@ -2034,12 +2024,6 @@
map_inst_set.Add2(inst_lib_null_inst.GetOp());
}
const cInstruction null_inst = map_inst_set.GetInst("NULL");
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- // Build an empty instruction into the instruction set.
- map_inst_set.Add("NULL", &cHardwareBase::Inst_Nop);
- const cInstruction null_inst = map_inst_set.GetInst("NULL");
-#endif /* USE_INST_SET_CODE */
cString color_string; // For coloring cells...
@@ -2059,77 +2043,86 @@
}
// Columns 2 to D+1 (the possible mutations)
- for (int mod_inst = 0; mod_inst < num_insts; mod_inst++) {
- mod_genome[line_num].SetOp(mod_inst);
- cAnalyzeGenotype test_genotype(mod_genome, inst_set);
- test_genotype.Recalculate();
- const double test_fitness = test_genotype.GetFitness() / base_fitness;
- row_fitness += test_fitness;
- total_fitness += test_fitness;
- col_fitness[mod_inst] += test_fitness;
-
- // Categorize this mutation...
- if (test_fitness == 1.0) { // Neutral Mutation...
- row_neut++;
- total_neut++;
- if (file_type == FILE_TYPE_HTML) color_string = "#FFFFFF";
- } else if (test_fitness == 0.0) { // Lethal Mutation...
- row_dead++;
- total_dead++;
- if (file_type == FILE_TYPE_HTML) color_string = "#FF0000";
- } else if (test_fitness < 1.0) { // Detrimental Mutation...
- row_neg++;
- total_neg++;
- if (file_type == FILE_TYPE_HTML) color_string = "#FFFF00";
- } else { // Beneficial Mutation...
- row_pos++;
- total_pos++;
- if (file_type == FILE_TYPE_HTML) color_string = "#00FF00";
- }
-
- // Write out this cell...
- if (file_type == FILE_TYPE_HTML) {
- fp << "<th bgcolor=\"" << color_string << "\">";
- }
- fp << test_fitness << " ";
+ for (int mod_inst = 0; mod_inst < num_insts; mod_inst++)
+ {
+ if (mod_inst == cur_inst) {
+ if (file_type == FILE_TYPE_HTML) {
+ color_string = "#FFFFFF";
+ fp << "<th bgcolor=\"" << color_string << "\">";
+ }
+ }
+ else {
+ mod_genome[line_num].SetOp(mod_inst);
+ cAnalyzeGenotype test_genotype(mod_genome, inst_set);
+ test_genotype.Recalculate();
+ const double test_fitness = test_genotype.GetFitness() / base_fitness;
+ row_fitness += test_fitness;
+ total_fitness += test_fitness;
+ col_fitness[mod_inst] += test_fitness;
+
+ // Categorize this mutation...
+ if (test_fitness == 1.0) { // Neutral Mutation...
+ row_neut++;
+ total_neut++;
+ if (file_type == FILE_TYPE_HTML) color_string = "#FFFFFF";
+ } else if (test_fitness == 0.0) { // Lethal Mutation...
+ row_dead++;
+ total_dead++;
+ if (file_type == FILE_TYPE_HTML) color_string = "#FF0000";
+ } else if (test_fitness < 1.0) { // Detrimental Mutation...
+ row_neg++;
+ total_neg++;
+ if (file_type == FILE_TYPE_HTML) color_string = "#FFFF00";
+ } else { // Beneficial Mutation...
+ row_pos++;
+ total_pos++;
+ if (file_type == FILE_TYPE_HTML) color_string = "#00FF00";
+ }
+
+ // Write out this cell...
+ if (file_type == FILE_TYPE_HTML) {
+ fp << "<th bgcolor=\"" << color_string << "\">";
+ }
+ fp << test_fitness << " ";
+ }
}
// Column: Knockout
mod_genome[line_num] = null_inst;
cAnalyzeGenotype test_genotype(mod_genome, map_inst_set);
test_genotype.Recalculate();
- const double test_fitness = test_genotype.GetFitness();
+ const double test_fitness = test_genotype.GetFitness() / base_fitness;
col_fitness[num_insts] += test_fitness;
// Categorize this mutation if its in HTML mode (color only)...
if (file_type == FILE_TYPE_HTML) {
- if (test_fitness == base_fitness) color_string = "#FFFFFF";
- else if (test_fitness == 0.0) color_string = "#FF0000";
- else if (test_fitness < base_fitness) color_string = "#FFFF00";
- else color_string = "#00FF00";
+ if (test_fitness == 1.0) color_string = "#FFFFFF";
+ else if (test_fitness == 0.0) color_string = "#FF0000";
+ else if (test_fitness < 1.0) color_string = "#FFFF00";
+ else color_string = "#00FF00";
- fp << "<th bgcolor=\"" << color_string << "\">";
+ fp << "<th bgcolor=\"" << color_string << "\">";
}
-
+
fp << test_fitness << " ";
// Fraction Columns...
if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FF0000\">";
- fp << (double) row_dead / (double) num_insts << " ";
+ fp << (double) row_dead / (double) (num_insts-1) << " ";
if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFF00\">";
- fp << (double) row_neg / (double) num_insts << " ";
+ fp << (double) row_neg / (double) (num_insts-1) << " ";
if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#FFFFFF\">";
- fp << (double) row_neut / (double) num_insts << " ";
+ fp << (double) row_neut / (double) (num_insts-1) << " ";
if (file_type == FILE_TYPE_HTML) fp << "<th bgcolor=\"#00FF00\">";
- fp << (double) row_pos / (double) num_insts << " ";
+ fp << (double) row_pos / (double) (num_insts-1) << " ";
// Column: Average Fitness
if (file_type == FILE_TYPE_HTML) fp << "<th>";
- fp << row_fitness / (double) num_insts << " ";
+ fp << row_fitness / (double) (num_insts-1) << " ";
// Column: Expected Entropy @CAO Implement!
if (file_type == FILE_TYPE_HTML) fp << "<th>";
@@ -2153,7 +2146,7 @@
fp << "<th>" << col_fitness[i] / max_line << " ";
}
- int total_tests = max_line * num_insts;
+ int total_tests = max_line * (num_insts-1);
fp << "<th>" << (double) total_dead / (double) total_tests << " ";
fp << "<th>" << (double) total_neg / (double) total_tests << " ";
fp << "<th>" << (double) total_neut / (double) total_tests << " ";
Index: avida/current/source/main/avida.cc
diff -u avida/current/source/main/avida.cc:1.41.2.1 avida/current/source/main/avida.cc:1.41.2.2
--- avida/current/source/main/avida.cc:1.41.2.1 Fri May 23 12:05:37 2003
+++ avida/current/source/main/avida.cc Tue Aug 19 10:49:29 2003
@@ -82,16 +82,12 @@
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPUOriginal(cConfig::GetInstFilename(),
environment.GetInstSet());
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPU4Stack(cConfig::GetInstFilename(),
environment.GetInstSet());
}
@@ -107,6 +103,7 @@
test_interface.SetFun_Recycle(&cCallbackUtil::CB_RecycleHardware);
test_interface.SetFun_Divide(&cCallbackUtil::CB_TestDivide);
test_interface.SetFun_GetInput(&cCallbackUtil::CB_GetInput);
+ test_interface.SetFun_GetInputAt(&cCallbackUtil::CB_GetInputAt);
test_interface.SetFun_GetResources(&cCallbackUtil::CB_GetResources);
test_interface.SetFun_UpdateResources(&cCallbackUtil::CB_UpdateResources);
@@ -190,6 +187,7 @@
default_interface.SetFun_Breakpoint(&cCallbackUtil::CB_Breakpoint);
default_interface.SetFun_TestFitness(&cCallbackUtil::CB_TestFitness);
default_interface.SetFun_GetInput(&cCallbackUtil::CB_GetInput);
+ default_interface.SetFun_GetInputAt(&cCallbackUtil::CB_GetInputAt);
default_interface.SetFun_Debug(&cCallbackUtil::CB_Debug);
default_interface.SetFun_GetResources(&cCallbackUtil::CB_GetResources);
default_interface.SetFun_UpdateResources(&cCallbackUtil::CB_UpdateResources);
Index: avida/current/source/main/callback_util.cc
diff -u avida/current/source/main/callback_util.cc:1.19.2.1 avida/current/source/main/callback_util.cc:1.19.2.2
--- avida/current/source/main/callback_util.cc:1.19.2.1 Fri May 23 12:05:37 2003
+++ avida/current/source/main/callback_util.cc Tue Aug 19 10:49:29 2003
@@ -21,6 +21,7 @@
#include "../cpu/hardware_factory.hh"
#include "../cpu/test_cpu.hh"
+#include "../main/org_message.hh"
using namespace std;
@@ -141,6 +142,14 @@
return cell.GetInput();
}
+int cCallbackUtil::CB_GetInputAt(cPopulation * pop, int cell_id, int & input_pointer)
+{
+ if (pop == NULL) return cTestCPU::GetInputAt(input_pointer);
+ cPopulationCell & cell = pop->GetCell(cell_id);
+ assert(cell.IsOccupied());
+ return cell.GetInputAt(input_pointer);
+}
+
int cCallbackUtil::CB_Debug(cPopulation * pop, int cell_id)
{
if (pop == NULL) return -1;
@@ -175,4 +184,15 @@
assert(pop != NULL);
cPopulationCell & death_cell = pop->GetCell(death_id);
pop->KillOrganism(death_cell);
+}
+
+bool cCallbackUtil::CB_SendMessage(cPopulation * pop, int cell_id, cOrgMessage & mess)
+{
+ mess.SetSenderID(cell_id);
+ mess.SetTime(pop->GetUpdate());
+ cPopulationCell & cell = pop->GetCell(cell_id);
+ if(cell.ConnectionList().GetFirst() == NULL)
+ return false;
+ mess.SetRecipientID(cell.ConnectionList().GetFirst()->GetID());
+ return cell.ConnectionList().GetFirst()->GetOrganism()->ReceiveMessage(mess);
}
Index: avida/current/source/main/callback_util.hh
diff -u avida/current/source/main/callback_util.hh:1.10 avida/current/source/main/callback_util.hh:1.10.2.1
--- avida/current/source/main/callback_util.hh:1.10 Tue Apr 1 08:58:17 2003
+++ avida/current/source/main/callback_util.hh Tue Aug 19 10:49:29 2003
@@ -15,6 +15,7 @@
class cOrganism;
class cPopulation;
class cPopulationInterface;
+class cOrgMessage;
class cCallbackUtil {
public:
@@ -32,11 +33,13 @@
static void CB_Breakpoint();
static double CB_TestFitness(cPopulation * pop, int cell_id);
static int CB_GetInput(cPopulation * pop, int cell_id);
+ static int CB_GetInputAt(cPopulation * pop, int cell_id, int & input_pointer);
static int CB_Debug(cPopulation * pop, int cell_id);
static const tArray<double>& CB_GetResources(cPopulation * pop, int cell_id);
static void CB_UpdateResources(cPopulation * pop, int cell_id,
const tArray<double> & res_change);
static void CB_KillCell(cPopulation * pop, int death_id);
+ static bool CB_SendMessage(cPopulation * pop, int cell_id, cOrgMessage & mess);
};
#endif
Index: avida/current/source/main/config.cc
diff -u avida/current/source/main/config.cc:1.55.2.1 avida/current/source/main/config.cc:1.55.2.2
--- avida/current/source/main/config.cc:1.55.2.1 Tue May 27 11:45:39 2003
+++ avida/current/source/main/config.cc Tue Aug 19 10:49:29 2003
@@ -33,6 +33,7 @@
int cConfig::end_condition_mode;
int cConfig::world_x;
int cConfig::world_y;
+int cConfig::world_geometry;
int cConfig::rand_seed;
double cConfig::point_mut_prob;
double cConfig::copy_mut_prob;
@@ -46,7 +47,7 @@
int cConfig::num_instructions;
int cConfig::hardware_type;
int cConfig::max_cpu_threads;
-int cConfig::thread_slicing_method;
+double cConfig::thread_slicing_method;
int cConfig::size_merit_method;
int cConfig::base_size_merit;
int cConfig::task_merit_method;
@@ -70,6 +71,7 @@
double cConfig::min_exe_lines;
int cConfig::require_allocate;
bool cConfig::test_on_divide;
+bool cConfig::test_sterilize;
double cConfig::revert_fatal;
double cConfig::revert_neg;
double cConfig::revert_neut;
@@ -116,6 +118,8 @@
"Width of the Avida world");
arch_group->Add(world_y, "100", "WORLD-Y",
"Height of the Avida world");
+ arch_group->Add(world_geometry, "2", "WORLD_GEOMETRY",
+ "1 = Bounded Grid\n2 = Torus");
arch_group->Add(rand_seed, "0", "RANDOM_SEED",
"Random number seed (0 for based on time)");
arch_group->Add(hardware_type, "0", "HARDWARE_TYPE",
@@ -153,7 +157,7 @@
repro_group->Add(alloc_method, "0", "ALLOC_METHOD",
"0 = Allocated space is set to default instruction.\n1 = Set to section of dead genome (Necrophilia)\n2 = Allocated space is set to random instruction.");
repro_group->Add(divide_method, "1", "DIVIDE_METHOD",
- "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother\n (after the divide, we have 2 children)");
+ "0 = Divide leaves state of mother untouched.\n1 = Divide resets state of mother (after the divide, we have 2 children)\n2 = Divide resets state of current thread only(does not touch possible parasite threads)");
repro_group->Add(generation_inc_method, "1", "GENERATION_INC_METHOD",
"0 = Only the generation of the child is\n increased on divide.\n1 = Both the generation of the mother and child are\n increased on divide (good with DIVIDE_METHOD 1).");
@@ -238,7 +242,7 @@
time_group->Add(max_cpu_threads, "1", "MAX_CPU_THREADS",
"Number of Threads a CPU can spawn");
time_group->Add(thread_slicing_method, "0", "THREAD_SLICING_METHOD",
- "0 = One thread executed per time slice.\n1 = All threads executed each time slice.");
+ "Formula for and organism's thread slicing -> 1 + (num_organism_threads-1) * THREAD_SLICING_METHOD.\n0 = One thread executed per time slice.\n1 = All threads executed each time slice.\n");
time_group->Add(max_label_exe_size, "1", "MAX_LABEL_EXE_SIZE",
"Max nops marked as executed when labels are used");
time_group->Add(base_size_merit, "0", "BASE_SIZE_MERIT",
@@ -330,9 +334,17 @@
// Determine if any variables were set that require test CPUs to be run
// at every divide.
- test_on_divide = (revert_fatal > 0.0) || (revert_neg > 0.0) ||
- (revert_neut > 0.0) || (revert_pos > 0.0) || (sterilize_fatal > 0.0) ||
- (sterilize_neg > 0.0) || (sterilize_neut > 0.0) || (sterilize_pos > 0.0);
+ test_on_divide = false;
+ if ((revert_fatal > 0.0) || (revert_neg > 0.0) || (revert_neut > 0.0) ||
+ (revert_pos > 0.0) || (fail_implicit > 0)) {
+ test_on_divide = true;
+ }
+
+ test_sterilize = false;
+ if ((sterilize_fatal > 0.0) || (sterilize_neg > 0.0) ||
+ (sterilize_neut > 0.0) || (sterilize_pos > 0.0)) {
+ test_sterilize = true;
+ }
// Determine if we are only logging threshold genotypes...
log_threshold_only = false;
Index: avida/current/source/main/config.hh
diff -u avida/current/source/main/config.hh:1.48.2.2 avida/current/source/main/config.hh:1.48.2.3
--- avida/current/source/main/config.hh:1.48.2.2 Tue May 27 14:34:45 2003
+++ avida/current/source/main/config.hh Tue Aug 19 10:49:29 2003
@@ -40,6 +40,7 @@
#define DIVIDE_METHOD_OFFSPRING 0
#define DIVIDE_METHOD_SPLIT 1
+#define DIVIDE_METHOD_BIRTH 2
#define GENERATION_INC_OFFSPRING 0
#define GENERATION_INC_BOTH 1
@@ -55,6 +56,10 @@
#define SIZE_MERIT_LEAST 4
#define SIZE_MERIT_SQRT_LEAST 5
+#define GEOMETRY_GLOBAL 0
+#define GEOMETRY_GRID 1
+#define GEOMETRY_TORUS 2
+
class cConfig {
protected:
class cConfigEntryBase {
@@ -66,7 +71,9 @@
cConfigEntryBase(const cString & _tag, const cString & _def,
const cString & _desc)
: genesis_tag(_tag), default_value(_def), description(_desc, '\n') { ; }
+ virtual ~cConfigEntryBase(){}
+ // virtual ~cConfigEntryBase();
const cString & GetTag() { return genesis_tag; }
const cString & GetDefault() { return default_value; }
const cStringList & GetDesc() { return description; }
@@ -168,6 +175,7 @@
static int end_condition_mode;
static int world_x;
static int world_y;
+ static int world_geometry;
static int rand_seed;
// Mutations
@@ -185,7 +193,7 @@
static int num_instructions;
static int hardware_type;
static int max_cpu_threads;
- static int thread_slicing_method;
+ static double thread_slicing_method;
// Merit info
static int size_merit_method;
@@ -221,6 +229,7 @@
// For specialized experiments -- mutation reversion.
static bool test_on_divide;
+ static bool test_sterilize;
static double revert_fatal;
static double revert_neg;
static double revert_neut;
@@ -292,6 +301,7 @@
static int GetEndConditionMode() { return end_condition_mode; }
static int GetWorldX() { return world_x; }
static int GetWorldY() { return world_y; }
+ static int GetWorldGeometry() { return world_geometry; }
static int GetRandSeed() { return rand_seed; }
static double GetPointMutProb() { return point_mut_prob; }
@@ -306,8 +316,8 @@
static int GetNumInstructions() { return num_instructions; }
static int GetHardwareType() { return hardware_type; }
- static int GetMaxCPUThreads() { return max_cpu_threads; }
- static int GetThreadSlicingMethod() { return thread_slicing_method; }
+ static int GetMaxCPUThreads() { return max_cpu_threads; }
+ static double GetThreadSlicingMethod() { return thread_slicing_method; }
static int GetSizeMeritMethod() { return size_merit_method; }
static int GetBaseSizeMerit() { return base_size_merit; }
@@ -336,6 +346,7 @@
static int GetRequireAllocate() { return require_allocate; }
static bool GetTestOnDivide() { return test_on_divide; }
+ static bool GetTestSterilize() { return test_sterilize; }
static double GetRevertFatal() { return revert_fatal; }
static double GetRevertNeg() { return revert_neg; }
static double GetRevertNeut() { return revert_neut; }
Index: avida/current/source/main/environment.cc
diff -u avida/current/source/main/environment.cc:1.11.2.3 avida/current/source/main/environment.cc:1.11.2.4
--- avida/current/source/main/environment.cc:1.11.2.3 Wed Jun 4 09:36:33 2003
+++ avida/current/source/main/environment.cc Tue Aug 19 10:49:29 2003
@@ -8,6 +8,7 @@
#include "../cpu/hardware_method.hh"
#include "environment.hh"
+#include "../tools/random.hh"
#include "../tools/string_util.hh"
@@ -82,6 +83,24 @@
return true;
}
+bool cEnvironment::AssertInputBool(const cString & input,
+ const cString & name,
+ const cString & type)
+{
+ if (input.IsNumber() == false) {
+ cerr << "Error: In " << type << "," << name << " set to non-number."
+ << endl;
+ return false;
+ }
+ int value = input.AsInt();
+ if ((value != 1) && (value != 0)) {
+ cerr << "Error: In " << type << "," << name << " set to non-bool."
+ << endl;
+ return false;
+ }
+ return true;
+}
+
bool cEnvironment::AssertInputValid(void * input,
const cString & name,
const cString & type,
@@ -162,6 +181,28 @@
if (!AssertInputDouble(var_value, "conversion", var_type)) return false;
new_process->SetConversion(var_value.AsDouble());
}
+ else if (var_name == "lethal") {
+ if (!AssertInputBool(var_value, "lethal", var_type))
+ return false;
+ new_process->SetLethal(var_value.AsInt());
+ }
+ else if (var_name == "detect") {
+ cResource * test_resource = resource_lib.GetResource(var_value);
+ if (!AssertInputValid(test_resource, "product", var_type, var_value)) {
+ return false;
+ }
+ new_process->SetDetect(test_resource);
+ }
+ else if (var_name == "threshold") {
+ if (!AssertInputDouble(var_value, "threshold", var_type))
+ return false;
+ new_process->SetDetectionThreshold(var_value.AsDouble());
+ }
+ else if (var_name == "detectionerror") {
+ if (!AssertInputDouble(var_value, "detectionerror", var_type))
+ return false;
+ new_process->SetDetectionError(var_value.AsDouble());
+ }
else {
cerr << "Error: Unknown process variable '" << var_name
<< "' in reaction '" << reaction->GetName() << "'" << endl;
@@ -742,12 +783,28 @@
break;
};
+ // Determine detection events
+ cResource * detected = cur_process->GetDetect();
+ if (detected != NULL) {
+ const int detected_id = detected->GetID();
+ const double real_amount = resource_count[detected_id];
+ double estimated_amount =
+ g_random.GetRandNormal(real_amount, cur_process->GetDetectionError()*real_amount);
+ if (estimated_amount < cur_process->GetDetectionThreshold()) {
+ result.Detect(detected_id, 0.0);
+ } else {
+ result.Detect(detected_id, estimated_amount);
+ }
+ }
+
// Determine byproducts
cResource * product = cur_process->GetProduct();
- if (product == NULL) continue;
+ if (product != NULL) {
+ int product_id = product->GetID();
+ double product_size = consumed * cur_process->GetConversion();
+ result.Produce(product_id, product_size);
+ }
- int product_id = product->GetID();
- double product_size = consumed * cur_process->GetConversion();
- result.Produce(product_id, product_size);
+ result.Lethal(cur_process->GetLethal());
}
}
Index: avida/current/source/main/environment.hh
diff -u avida/current/source/main/environment.hh:1.9 avida/current/source/main/environment.hh:1.9.2.1
--- avida/current/source/main/environment.hh:1.9 Sat May 17 14:54:54 2003
+++ avida/current/source/main/environment.hh Tue Aug 19 10:49:29 2003
@@ -35,6 +35,8 @@
const cString & type);
static bool AssertInputDouble(const cString & input, const cString & name,
const cString & type);
+ static bool AssertInputBool(const cString & input, const cString & name,
+ const cString & type);
static bool AssertInputValid(void * input, const cString & name,
const cString & type, const cString & value);
Index: avida/current/source/main/genome.hh
diff -u avida/current/source/main/genome.hh:1.3 avida/current/source/main/genome.hh:1.3.4.1
--- avida/current/source/main/genome.hh:1.3 Thu Feb 28 22:37:51 2002
+++ avida/current/source/main/genome.hh Tue Aug 19 10:49:29 2003
@@ -32,6 +32,8 @@
virtual void operator=(const cGenome & other_genome);
virtual bool operator==(const cGenome & other_genome) const;
+ virtual bool operator<(const cGenome & other_genome) const
+ { return AsString() < other_genome.AsString(); }
cInstruction & operator[](int index)
{ assert(index >= 0 && index < active_size); return genome[index]; }
Index: avida/current/source/main/inst_set.cc
diff -u avida/current/source/main/inst_set.cc:1.1.4.2 avida/current/source/main/inst_set.cc:1.1.4.3
--- avida/current/source/main/inst_set.cc:1.1.4.2 Tue May 27 11:45:41 2003
+++ avida/current/source/main/inst_set.cc Tue Aug 19 10:49:29 2003
@@ -18,21 +18,13 @@
//////////////////////
// Initialize static variables
-/* XXX start -- kgn */
-#ifdef USE_INST_SET_CODE
cInstruction cInstSet::inst_default2( 0 );
cInstruction cInstSet::inst_error2 ( 255 );
-#else /* USE_INST_SET_CODE */
-/* XXX end */
-const cInstruction cInstSet::inst_default( 0 );
-const cInstruction cInstSet::inst_error ( 255 );
-#endif /* USE_INST_SET_CODE */
cInstSet::cInstSet()
{
}
-#ifdef USE_INST_SET_CODE
cInstSet::cInstSet(const cInstSet & in_inst_set)
: m_inst_lib(in_inst_set.m_inst_lib)
, m_lib_name_map(in_inst_set.m_lib_name_map)
@@ -40,14 +32,6 @@
, mutation_chart2(in_inst_set.mutation_chart2)
{
}
-#else /* USE_INST_SET_CODE */
-cInstSet::cInstSet(const cInstSet & in_inst_set)
- : inst_array(in_inst_set.inst_array)
- , nop_mods(in_inst_set.nop_mods)
- , mutation_chart(in_inst_set.mutation_chart)
-{
-}
-#endif /* USE_INST_SET_CODE */
cInstSet::~cInstSet()
{
@@ -55,25 +39,15 @@
cInstSet & cInstSet::operator=(const cInstSet & _in)
{
- /* XXX start -- kgn */
-#ifdef USE_INST_SET_CODE
m_inst_lib = _in.m_inst_lib;
m_lib_name_map = _in.m_lib_name_map;
m_lib_nopmod_map = _in.m_lib_nopmod_map;
mutation_chart2 = _in.mutation_chart2;
-#else /* USE_INST_SET_CODE */
- /* XXX end */
- inst_array = _in.inst_array;
- nop_mods = _in.nop_mods;
- mutation_chart = _in.mutation_chart;
-#endif /* USE_INST_SET_CODE */
return *this;
}
bool cInstSet::OK() const
{
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
assert(m_lib_name_map.GetSize() < 256);
assert(m_lib_nopmod_map.GetSize() < m_lib_name_map.GetSize());
@@ -88,42 +62,16 @@
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
assert(m_lib_name_map[i].redundancy == test_redundancy2[i]);
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
-
- // assert(inst_array.OK());
- // assert(nop_mods.OK());
- assert(inst_array.GetSize() < 256);
- assert(nop_mods.GetSize() < inst_array.GetSize());
-
- // Make sure that all of the redundancies are represented the appropriate
- // number of times.
- tArray<int> test_redundancy(inst_array.GetSize());
- test_redundancy.SetAll(0);
- for (int i = 0; i < mutation_chart.GetSize(); i++) {
- int test_id = mutation_chart[i];
- test_redundancy[test_id]++;
- }
- for (int i = 0; i < inst_array.GetSize(); i++) {
- assert(inst_array[i].redundancy == test_redundancy[i]);
- }
-#endif /* USE_INST_SET_CODE */
return true;
}
cInstruction cInstSet::GetRandomInst() const
{
-#ifdef USE_INST_SET_CODE
int inst_op = mutation_chart2[g_random.GetUInt(mutation_chart2.GetSize())];
-#else /* USE_INST_SET_CODE */
- int inst_op = mutation_chart[g_random.GetUInt(mutation_chart.GetSize())];
-#endif /* USE_INST_SET_CODE */
return cInstruction(inst_op);
}
-/**/
-#ifdef USE_INST_SET_CODE
int cInstSet::Add2(
const int lib_fun_id,
const int redundancy,
@@ -173,65 +121,14 @@
return inst_id;
}
-#else /* USE_INST_SET_CODE */
-/**/
-
-int cInstSet::Add(const cString & _name, tHardwareMethod _fun,
- const int redundancy, const int ft_cost, const int cost,
- const double prob_fail)
-{
- const int inst_id = inst_array.GetSize();
-
- assert(inst_id < 255);
-
- // Increase the size of the array...
- inst_array.Resize(inst_id + 1);
-
- // Setup the new function...
- inst_array[inst_id].name = _name;
- inst_array[inst_id].function = _fun;
- inst_array[inst_id].redundancy = redundancy;
- inst_array[inst_id].cost = cost;
- inst_array[inst_id].ft_cost = ft_cost;
- inst_array[inst_id].prob_fail = prob_fail;
-
- const int total_redundancy = mutation_chart.GetSize();
- mutation_chart.Resize(total_redundancy + redundancy);
- for (int i = 0; i < redundancy; i++) {
- mutation_chart[total_redundancy + i] = inst_id;
- }
-
- return inst_id;
-}
-
-int cInstSet::AddNop(const cString & _name, tHardwareMethod _fun,
- const int reg, const int redundancy, const int ft_cost,
- const int cost, const double prob_fail)
-{
- // Assert nops are at the _beginning_ of an inst_set.
- assert(inst_array.GetSize() == nop_mods.GetSize());
-
- const int inst_id = Add(_name, _fun, redundancy, ft_cost, cost, prob_fail);
-
- nop_mods.Resize(inst_id + 1);
- nop_mods[inst_id] = reg;
-
- return inst_id;
-}
-#endif /* USE_INST_SET_CODE */
cString cInstSet::FindBestMatch(const cString & in_name) const
{
int best_dist = 1024;
cString best_name("");
-#ifdef USE_INST_SET_CODE
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
const cString & cur_name = m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id);
-#else /* USE_INST_SET_CODE */
- for (int i = 0; i < inst_array.GetSize(); i++) {
- const cString & cur_name = inst_array[i].name;
-#endif /* USE_INST_SET_CODE */
const int cur_dist = cStringUtil::EditDistance(cur_name, in_name);
if (cur_dist < best_dist) {
best_dist = cur_dist;
Index: avida/current/source/main/inst_set.hh
diff -u avida/current/source/main/inst_set.hh:1.1.4.1 avida/current/source/main/inst_set.hh:1.1.4.2
--- avida/current/source/main/inst_set.hh:1.1.4.1 Fri May 23 12:05:37 2003
+++ avida/current/source/main/inst_set.hh Tue Aug 19 10:49:29 2003
@@ -35,7 +35,6 @@
**/
class cInstSet {
-#ifdef USE_INST_SET_CODE
public:
cInstLibBase *m_inst_lib;
class cInstEntry2 {
@@ -53,23 +52,6 @@
static cInstruction inst_error2;
// static const cInstruction inst_none;
static cInstruction inst_default2;
-#else /* USE_INST_SET_CODE */
-private:
- // This class gives full info about a single instruction in the library.
- class cInstEntry {
- public:
- cString name; // Name of this instruction.
- tHardwareMethod function; // Pointer to hardware method.
- int redundancy; // Weight in instruction set (not impl.)
- int cost; // additional time spent to exectute inst.
- int ft_cost; // time spent first time exec (in add to cost)
- double prob_fail; // probability of failing to execute inst
- };
-
- tArray<cInstEntry> inst_array; // The instructions indexed by ID
- tArray<int> nop_mods; // Modification table for nops
- tArray<int> mutation_chart; // ID's represented by redundancy values.
-#endif /* USE_INST_SET_CODE */
// Static components...
static const cInstruction inst_error;
@@ -88,13 +70,7 @@
// Accessors
const cString & GetName(int id) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_inst_lib->GetName(m_lib_name_map[id].lib_fun_id);
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[id].name;
-#endif /* USE_INST_SET_CODE */
}
const cString & GetName(const cInstruction & inst) const
{
@@ -102,116 +78,51 @@
}
int GetCost(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].cost;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].cost;
-#endif /* USE_INST_SET_CODE */
}
int GetFTCost(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].ft_cost;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].ft_cost;
-#endif /* USE_INST_SET_CODE */
}
double GetProbFail(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].prob_fail;
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array[inst.GetOp()].prob_fail;
-#endif /* USE_INST_SET_CODE */
}
int GetRedundancy(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map[inst.GetOp()].redundancy;
-#else /* USE_INST_SET_CODE */
- ///* XXX end */
- return inst_array[inst.GetOp()].redundancy;
-#endif /* USE_INST_SET_CODE */
}
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
int GetLibFunctionIndex(const cInstruction & inst) const
{
return m_lib_name_map[inst.GetOp()].lib_fun_id;
}
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- tHardwareMethod GetFunction(const cInstruction & inst) const
- {
- return inst_array[inst.GetOp()].function;
- }
-#endif /* USE_INST_SET_CODE */
int GetNopMod(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_inst_lib->GetNopMod(m_lib_nopmod_map[inst.GetOp()]);
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return nop_mods[inst.GetOp()];
-#endif /* USE_INST_SET_CODE */
}
cInstruction GetRandomInst() const;
-#ifdef USE_INST_SET_CODE
int GetRandFunctionIndex() const
{
return m_lib_name_map[ GetRandomInst().GetOp() ].lib_fun_id;
}
-#else /* USE_INST_SET_CODE */
- tHardwareMethod GetRandFunction() const
- {
- return inst_array[ GetRandomInst().GetOp() ].function;
- }
-#endif /* USE_INST_SET_CODE */
int GetSize() const {
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_name_map.GetSize();
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_array.GetSize();
-#endif /* USE_INST_SET_CODE */
}
int GetNumNops() const {
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return m_lib_nopmod_map.GetSize();
-#else /* USE_INST_SET_CODE */
- ///* XXX end */
- return nop_mods.GetSize();
-#endif /* USE_INST_SET_CODE */
}
// Instruction Analysis.
int IsNop(const cInstruction & inst) const
{
-#ifdef USE_INST_SET_CODE
- ///* XXX start -- kgn */
return (inst.GetOp() < m_lib_nopmod_map.GetSize());
- ///* XXX end */
-#else /* USE_INST_SET_CODE */
- return (inst.GetOp() < nop_mods.GetSize());
-#endif /* USE_INST_SET_CODE */
}
// Insertion of new instructions...
-#ifdef USE_INST_SET_CODE
int Add2(
const int lib_fun_id,
const int redundancy=1,
@@ -226,16 +137,7 @@
const int cost=0,
const double prob_fail=0.0
);
-#else /* USE_INST_SET_CODE */
- int Add(const cString & _name, tHardwareMethod _fun, const int redundancy=1,
- const int ft_cost=0, const int cost=0, const double prob_fail=0.0);
- int AddNop(const cString & _name, tHardwareMethod _fun, const int reg,
- const int redundancy=1, const int ft_cost=0, const int cost=0,
- const double prob_fail=0.0);
-#endif /* USE_INST_SET_CODE */
-#ifdef USE_INST_SET_CODE
- /* XXX start -- kgn */
// accessors for instruction library
cInstLibBase *GetInstLib(){ return m_inst_lib; }
void SetInstLib(cInstLibBase *inst_lib){
@@ -243,34 +145,16 @@
inst_error2 = inst_lib->GetInstError();
inst_default2 = inst_lib->GetInstDefault();
}
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
inline cInstruction GetInst(const cString & in_name) const;
cString FindBestMatch(const cString & in_name) const;
// Static methods..
static const cInstruction & GetInstDefault() {
-#ifdef USE_INST_SET_CODE
- /* XXX start --- kgn */
- //if(inst_default != inst_default2)
- //{ std::cout << "<cInstSet::GetInstDefault> mismatch!" << std::endl; }
return inst_default2;
- /* XXX end */
-#else /* USE_INST_SET_CODE */
- return inst_default;
-#endif /* USE_INST_SET_CODE */
}
static const cInstruction & GetInstError() {
- /* XXX start --- kgn */
- //if(inst_error != inst_error2)
- //{ std::cout << "<cInstSet::GetInstError> mismatch!" << std::endl; }
-#ifdef USE_INST_SET_CODE
return inst_error2;
-#else /* USE_INST_SET_CODE */
- /* XXX end */
- return inst_error;
-#endif /* USE_INST_SET_CODE */
}
// static const cInstruction & GetInstNone() { return inst_none; }
};
@@ -278,7 +162,6 @@
inline cInstruction cInstSet::GetInst(const cString & in_name) const
{
-#ifdef USE_INST_SET_CODE
for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
if (m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id) == in_name) {
return cInstruction(i);
@@ -291,15 +174,6 @@
-- kgn
*/
return cInstruction(0);
-#else /* USE_INST_SET_CODE */
- /* XXX start --- kgn */
- for (int i = 0; i < inst_array.GetSize(); i++) {
- if (inst_array[i].name == in_name) return cInstruction(i);
- }
- // assert(false); // Requesting ID for unknown inst.
- return cInstSet::GetInstError();
- /* XXX end */
-#endif /* USE_INST_SET_CODE */
}
Index: avida/current/source/main/inst_util.cc
diff -u avida/current/source/main/inst_util.cc:1.13 avida/current/source/main/inst_util.cc:1.13.2.1
--- avida/current/source/main/inst_util.cc:1.13 Sun May 18 19:07:58 2003
+++ avida/current/source/main/inst_util.cc Tue Aug 19 10:49:29 2003
@@ -21,7 +21,7 @@
cGenome cInstUtil::LoadGenome(const cString & filename,
const cInstSet & inst_set)
{
- cInitFile input_file(filename);
+ cInitFile input_file(filename);
if (!input_file.IsOpen()) {
cerr << "Cannot open file: " << filename << endl;
return cGenome(1);
@@ -46,6 +46,9 @@
exit(1);
}
}
+
+ if(new_genome.GetSize()==0)
+ cerr << "WARNING: Genome size is 0!" << endl;
return new_genome;
}
Index: avida/current/source/main/organism.cc
diff -u avida/current/source/main/organism.cc:1.23 avida/current/source/main/organism.cc:1.23.2.1
--- avida/current/source/main/organism.cc:1.23 Sat May 17 14:54:55 2003
+++ avida/current/source/main/organism.cc Tue Aug 19 10:49:29 2003
@@ -10,12 +10,14 @@
#include "../tools/functions.hh"
#include "../tools/tArray.hh"
+//#include "../tools/message.hh"
#include "config.hh"
#include "inst_set.hh"
#include "inst_util.hh"
#include "genome.hh"
#include "genome_util.hh"
+#include "org_message.hh"
#include "../cpu/cpu_defs.hh"
#include "../cpu/hardware_base.hh"
@@ -44,6 +46,8 @@
, max_executed(-1)
, lineage_label(-1)
, lineage(NULL)
+ , inbox(0)
+ , sent(0)
{
// Initialization of structures...
hardware = pop_interface.NewHardware(this);
@@ -94,10 +98,25 @@
out_buf.Add(value);
phenotype.TestOutput(in_buf, out_buf, resource_count, res_change);
-
pop_interface.UpdateResources(res_change);
+ //if(phenotype.GetToDie() == 1) Die(); //Final Effect Lethal Reaction
}
+void cOrganism::SendMessage(cOrgMessage & mess)
+{
+ if(pop_interface.SendMessage(mess))
+ sent.Add(mess);
+ else
+ {
+ //perhaps some kind of message error buffer?
+ }
+}
+
+bool cOrganism::ReceiveMessage(cOrgMessage & mess)
+{
+ inbox.Add(mess);
+ return true;
+}
int cOrganism::OK()
{
Index: avida/current/source/main/organism.hh
diff -u avida/current/source/main/organism.hh:1.21 avida/current/source/main/organism.hh:1.21.2.1
--- avida/current/source/main/organism.hh:1.21 Sat May 17 02:48:09 2003
+++ avida/current/source/main/organism.hh Tue Aug 19 10:49:29 2003
@@ -12,6 +12,7 @@
#include "../tools/merit.hh"
#include "../tools/tBuffer.hh"
+#include "../tools/string.hh"
#include "../defs.hh"
@@ -28,6 +29,7 @@
class cHardwareBase;
class cLineage;
class cPopulation;
+class cOrgMessage;
/**
* The cOrganism class controls the running and manages all the statistics
@@ -58,6 +60,9 @@
#endif
static int instance_count;
+ tBuffer<cOrgMessage> inbox;
+ tBuffer<cOrgMessage> sent;
+
public:
void PrintStatus(std::ostream & fp);
@@ -80,6 +85,7 @@
void Rotate(int direction) { pop_interface.Rotate(direction); }
void DoBreakpoint() { pop_interface.Breakpoint(); }
int GetInput() { return pop_interface.GetInput(); }
+ int GetInputAt(int & input_pointer) { return pop_interface.GetInputAt(input_pointer); }
void Die() { pop_interface.Die(); }
int GetCellID() { return pop_interface.GetCellID(); }
int GetDebugInfo() { return pop_interface.Debug(); }
@@ -88,6 +94,10 @@
void DoInput(const int value, tBuffer<int> & in_buf, tBuffer<int> & out_buf);
void DoOutput(const int value, tBuffer<int> & in_buf, tBuffer<int> &out_buf);
+ // NEW - message stuff
+ void SendMessage(cOrgMessage & mess);
+ bool ReceiveMessage(cOrgMessage & mess);
+
int OK();
double GetTestFitness();
@@ -147,7 +157,12 @@
cLocalMutations & GetLocalMutations() { return mut_info; }
const cPopulationInterface & PopInterface() const { return pop_interface; }
cPopulationInterface & PopInterface() { return pop_interface; }
+
+ // yes, this is a huge hack, but a lot of code uses the
+ // original GetGenome() call - law
+ //const tArray<cGenome> & GetGenomeArray() const;
const cGenome & GetGenome() const { return initial_genome; }
+ //const tArray<cGenome> & GetGenome4Stack() const;
int GetCurGestation() const;
const cPhenotype & GetPhenotype() const { return phenotype; }
Index: avida/current/source/main/phenotype.cc
diff -u avida/current/source/main/phenotype.cc:1.32 avida/current/source/main/phenotype.cc:1.32.2.1
--- avida/current/source/main/phenotype.cc:1.32 Sat May 17 14:23:26 2003
+++ avida/current/source/main/phenotype.cc Tue Aug 19 10:49:29 2003
@@ -25,6 +25,7 @@
, last_task_count(environment.GetTaskLib().GetSize())
, last_reaction_count(environment.GetReactionLib().GetSize())
, last_inst_count(environment.GetInstSet().GetSize())
+ , sensed_resources(environment.GetResourceLib().GetSize())
{
}
@@ -52,7 +53,7 @@
assert(time_used >= 0);
assert(age >= 0);
assert(child_copied_size >= 0);
-
+ assert(to_die == false);
return true;
}
@@ -91,6 +92,9 @@
cur_task_count.SetAll(0);
cur_reaction_count.SetAll(0);
cur_inst_count.SetAll(0);
+ for (int j = 0; j < sensed_resources.GetSize(); j++)
+ sensed_resources[j] = parent_phenotype.sensed_resources[j];
+
// Copy last values from parent
last_merit_base = parent_phenotype.last_merit_base;
@@ -120,6 +124,7 @@
is_multi_thread = parent_phenotype.is_multi_thread;
parent_true = parent_phenotype.copy_true;
parent_sex = parent_phenotype.divide_sex;
+ to_die = false;
// Setup child info...
copy_true = false;
@@ -159,6 +164,7 @@
cur_task_count.SetAll(0);
cur_reaction_count.SetAll(0);
cur_inst_count.SetAll(0);
+ sensed_resources.SetAll(0);
// Copy last values from parent
last_merit_base = _length;
@@ -186,6 +192,7 @@
is_multi_thread = false;
parent_true = true;
parent_sex = false;
+ to_die = false;
// Setup child info...
copy_true = false;
@@ -210,7 +217,7 @@
// Update these values as needed...
int cur_merit_base = CalcSizeMerit(genome_length,copied_size,executed_size);
merit = cur_merit_base * cur_bonus;
- assert(merit.GetDouble() != 0);
+ assert(merit.GetDouble() >= 0.0);
genome_length = _length;
(void) copied_size; // Unchanged
@@ -308,6 +315,7 @@
cur_task_count.SetAll(0);
cur_reaction_count.SetAll(0);
cur_inst_count.SetAll(0);
+ sensed_resources.SetAll(-1.0);
// Setup other miscellaneous values...
num_divides++;
@@ -379,10 +387,21 @@
cur_bonus *= result.GetMultBonus();
cur_bonus += result.GetAddBonus();
+ // Bonus should never go negative...
+ if (cur_bonus < 0.0) cur_bonus = 0.0;
+
// Denote consumed resources...
for (int i = 0; i < res_in.GetSize(); i++) {
res_change[i] = result.GetProduced(i) - result.GetConsumed(i);
}
+
+ //Put in detected resources
+ for (int j = 0; j < res_in.GetSize(); j++)
+ if(result.GetDetected(j) != -1.0)
+ sensed_resources[j] = result.GetDetected(j);
+
+ //Kill any cells that did lethal reactions
+ //to_die = result.GetLethal();
return true;
}
Index: avida/current/source/main/phenotype.hh
diff -u avida/current/source/main/phenotype.hh:1.34 avida/current/source/main/phenotype.hh:1.34.2.1
--- avida/current/source/main/phenotype.hh:1.34 Sat May 17 12:33:53 2003
+++ avida/current/source/main/phenotype.hh Tue Aug 19 10:49:29 2003
@@ -54,14 +54,16 @@
int gestation_time; // CPU cycles to produce offspring (or be produced)
int gestation_start; // Total instructions executed at last divide.
double fitness; // Relative efective replication rate...
- double div_type; // Type of the divide command used
+ double div_type; // Type of the divide command used
// 2. These are "in progress" variables, updated as the organism operates
double cur_bonus; // Current Bonus
+ bool to_die; // Has executed a fatal reaction
int cur_num_errors; // Total instructions executed illeagally.
tArray<int> cur_task_count; // Total times each task was performed
tArray<int> cur_reaction_count; // Total times each reaction was triggered.
tArray<int> cur_inst_count; // Intruction exection counter
+ tArray<double> sensed_resources; // Resources of which the organism is explictly aware
// 3. These mark the status of "in progess" variables at the last divide.
double last_merit_base; // Either constant or based on genome length.
@@ -98,9 +100,6 @@
bool last_child_fertile; // Was the child being born to be fertile?
int child_copied_size; // Instruction copied into child.
-private:
- static int CalcSizeMerit(int full_size, int copied_size, int exe_size);
-
public:
cPhenotype(const cEnvironment & environment);
~cPhenotype();
@@ -129,6 +128,14 @@
bool LoadState(std::ifstream & fp);
void PrintStatus(std::ostream & fp);
+ // Some useful methods...
+ static int CalcSizeMerit(int full_size, int copied_size, int exe_size);
+ double CalcFitnessRatio() {
+ const int merit_base =
+ CalcSizeMerit(genome_length,copied_size,executed_size);
+ const double cur_fitness = merit_base * cur_bonus / time_used;
+ return cur_fitness / last_fitness;
+ }
///////////////////// Accessors -- Retrieving ////////////////////
const cEnvironment & GetEnvironment() const { return environment; };
@@ -152,6 +159,8 @@
double GetCurBonus() const
{ assert(initialized == true); return cur_bonus; }
+ bool GetToDie() const
+ { assert(initialized == true); return to_die; }
int GetCurNumErrors()const
{ assert(initialized == true); return cur_num_errors; }
const tArray<int> & GetCurTaskCount() const
@@ -160,6 +169,9 @@
{ assert(initialized == true); return cur_reaction_count;}
const tArray<int> & GetCurInstCount() const
{ assert(initialized == true); return cur_inst_count; }
+
+ double GetSensedResource(int _in)
+ { assert(initialized == true); return sensed_resources[_in]; }
double GetLastMeritBase() const
{ assert(initialized == true); return last_merit_base; }
Index: avida/current/source/main/pop_interface.cc
diff -u avida/current/source/main/pop_interface.cc:1.11 avida/current/source/main/pop_interface.cc:1.11.2.1
--- avida/current/source/main/pop_interface.cc:1.11 Tue Apr 1 07:06:27 2003
+++ avida/current/source/main/pop_interface.cc Tue Aug 19 10:49:29 2003
@@ -27,10 +27,12 @@
, fun_breakpoint(NULL)
, fun_test_fitness(NULL)
, fun_get_input(NULL)
+ , fun_get_input_at(NULL)
, fun_debug(NULL)
, fun_get_resources(NULL)
, fun_update_resources(NULL)
, fun_kill_cell(NULL)
+ , fun_send_message(NULL)
{
}
@@ -56,6 +58,7 @@
fun_get_resources = in_interface.fun_get_resources;
fun_update_resources = in_interface.fun_update_resources;
fun_kill_cell = in_interface.fun_kill_cell;
+ fun_send_message = in_interface.fun_send_message;
}
cHardwareBase * cPopulationInterface::NewHardware(cOrganism * owner)
@@ -134,6 +137,12 @@
return (*fun_get_input)(population, cell_id);
}
+int cPopulationInterface::GetInputAt(int & input_pointer)
+{
+ assert(fun_get_input_at != NULL);
+ return (*fun_get_input_at)(population, cell_id, input_pointer);
+}
+
int cPopulationInterface::Debug()
{
assert(fun_debug != NULL);
@@ -157,4 +166,10 @@
{
if (fun_kill_cell == NULL) return;
(*fun_kill_cell)(population, cell_id);
+}
+
+bool cPopulationInterface::SendMessage(cOrgMessage & mess)
+{
+ if (fun_send_message == NULL) return false;
+ return (*fun_send_message)(population, cell_id, mess);
}
Index: avida/current/source/main/pop_interface.hh
diff -u avida/current/source/main/pop_interface.hh:1.9 avida/current/source/main/pop_interface.hh:1.9.2.1
--- avida/current/source/main/pop_interface.hh:1.9 Tue Apr 1 07:06:29 2003
+++ avida/current/source/main/pop_interface.hh Tue Aug 19 10:49:29 2003
@@ -17,6 +17,7 @@
class cHardwareBase;
class cOrganism;
class cPopulation;
+class cOrgMessage;
typedef cHardwareBase * (*tFunNewHardware)(cPopulation *pop, cOrganism *owner);
typedef void (*tFunRecycle)(cHardwareBase * out_hardware);
@@ -30,12 +31,14 @@
typedef void (*tFunBreakpoint)();
typedef double (*tFunTestFitness)(cPopulation * pop, int cell_id);
typedef int (*tFunGetInput)(cPopulation * pop, int cell_id);
+typedef int (*tFunGetInputAt)(cPopulation * pop, int cell_id, int & input_pointer);
typedef int (*tFunDebug)(cPopulation * pop, int cell_id);
typedef const tArray<double> & (*tFunGetResources)
(cPopulation * pop, int cell_id);
typedef void (*tFunUpdateResources)
(cPopulation * pop, int cell_id, const tArray<double> & res_change);
typedef void (*tFunKillCell)(cPopulation * pop, int death_id);
+typedef bool (*tFunSendMessage)(cPopulation * pop, int cell_id, cOrgMessage & mess);
class cPopulationInterface {
private:
@@ -53,10 +56,12 @@
tFunBreakpoint fun_breakpoint;
tFunTestFitness fun_test_fitness;
tFunGetInput fun_get_input;
+ tFunGetInputAt fun_get_input_at;
tFunDebug fun_debug;
tFunGetResources fun_get_resources;
tFunUpdateResources fun_update_resources;
tFunKillCell fun_kill_cell;
+ tFunSendMessage fun_send_message;
public:
cPopulationInterface();
~cPopulationInterface();
@@ -78,11 +83,13 @@
void SetFun_Breakpoint(tFunBreakpoint fun) { fun_breakpoint = fun; }
void SetFun_TestFitness(tFunTestFitness fun) { fun_test_fitness = fun; }
void SetFun_GetInput(tFunGetInput fun) { fun_get_input = fun; }
+ void SetFun_GetInputAt(tFunGetInputAt fun) { fun_get_input_at = fun; }
void SetFun_Debug(tFunDebug fun) { fun_debug = fun; }
void SetFun_GetResources(tFunGetResources fun) { fun_get_resources = fun; }
void SetFun_UpdateResources(tFunUpdateResources fun)
{ fun_update_resources = fun; }
void SetFun_KillCell(tFunKillCell fun) { fun_kill_cell = fun; }
+ void SetFun_SendMessage(tFunSendMessage fun) { fun_send_message = fun; }
void CopyCallbacks(cPopulationInterface & in_interface);
// Activate callbacks...
@@ -97,10 +104,12 @@
void Breakpoint();
double TestFitness();
int GetInput();
+ int GetInputAt(int & input_pointer);
int Debug();
const tArray<double> & GetResources();
void UpdateResources(const tArray<double> & res_change);
void Die();
+ bool SendMessage(cOrgMessage & mess);
};
#endif
Index: avida/current/source/main/population.cc
diff -u avida/current/source/main/population.cc:1.109 avida/current/source/main/population.cc:1.109.2.1
--- avida/current/source/main/population.cc:1.109 Tue May 20 14:07:00 2003
+++ avida/current/source/main/population.cc Tue Aug 19 10:49:29 2003
@@ -76,26 +76,76 @@
// Avida specific information.
world_x = cConfig::GetWorldX();
world_y = cConfig::GetWorldY();
+ int geometry = cConfig::GetWorldGeometry();
const int num_cells = world_x * world_y;
cout << "Building world " << world_x << "x" << world_y
<< " = " << num_cells << " organisms." << endl;
+ if (geometry == GEOMETRY_GRID) {
+ cout << "Geometry: Bounded grid" << endl;
+ } else if (geometry == GEOMETRY_TORUS) {
+ cout << "Geometry: Torus" << endl;
+ } else {
+ cout << "Geometry: Unknown" << endl;
+ }
cell_array.Resize(num_cells);
resource_count.ResizeSpatialGrids(world_x, world_y);
-
+
+ bool bottom_flag, top_flag, right_flag, left_flag;
for (int cell_id = 0; cell_id < num_cells; cell_id++) {
+ int x = cell_id % world_x;
+ int y = cell_id / world_x;
cell_array[cell_id].Setup(cell_id, default_mut_rates);
+
+ if ((y == 0) && (geometry == GEOMETRY_GRID)) {
+ bottom_flag = false;
+ } else {
+ bottom_flag = true;
+ }
+ if ((y == world_y-1) && (geometry == GEOMETRY_GRID)) {
+ top_flag = false;
+ } else {
+ top_flag = true;
+ }
+ if ((x == 0) && (geometry == GEOMETRY_GRID)) {
+ left_flag = false;
+ } else {
+ left_flag = true;
+ }
+ if ((x == world_x-1) && (geometry == GEOMETRY_GRID)) {
+ right_flag = false;
+ } else {
+ right_flag = true;
+ }
+
// Setup the connection list for each cell. (Clockwise from -1 to 1)
- tList<cPopulationCell> & conn_list = cell_array[cell_id].ConnectionList();
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, -1, -1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, 0, -1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, +1, -1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, +1, 0)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, +1, +1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, 0, +1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, -1, +1)]));
- conn_list.Push(&(cell_array[Neighbor(cell_id, world_x, world_y, -1, 0)]));
+
+ tList<cPopulationCell> & conn_list=cell_array[cell_id].ConnectionList();
+ if (bottom_flag && left_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, -1, -1)]));
+ }
+ if (bottom_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, 0, -1)]));
+ }
+ if (bottom_flag && right_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, +1, -1)]));
+ }
+ if (right_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, +1, 0)]));
+ }
+ if (top_flag && right_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, +1, +1)]));
+ }
+ if (top_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, 0, +1)]));
+ }
+ if (top_flag && left_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, -1, +1)]));
+ }
+ if (left_flag) {
+ conn_list.Push(&(cell_array[Neighbor(cell_id,world_x,world_y, -1, 0)]));
+ }
// Setup the reaper queue...
if (cConfig::GetBirthMethod() == POSITION_CHILD_FULL_SOUP_ELDEST) {
@@ -1039,6 +1089,7 @@
<< mem.AsString() << endl;
}
}
+ return true;
}
bool cPopulation::OK()
@@ -1070,8 +1121,8 @@
* this organism.
**/
-void cPopulation::Inject(const cGenome & genome, int cell_id, double merit,
- int lineage_label, double neutral )
+void cPopulation::Inject(const cGenome & genome, int cell_id, double merit,
+ int lineage_label, double neutral, int mem_space )
{
// If an invalid cell was given, choose a new ID for it.
if (cell_id < 0) {
@@ -1083,14 +1134,21 @@
}
}
- InjectGenome( cell_id, genome );
- cPhenotype & phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
- phenotype.SetNeutralMetric(neutral);
-
- if (merit > 0) phenotype.SetMerit( cMerit(merit) );
- schedule->Adjust(cell_id, phenotype.GetMerit());
-
- LineageSetupOrganism(GetCell(cell_id).GetOrganism(), 0, lineage_label);
+ if(mem_space==0) {
+ InjectGenome( cell_id, genome);
+ cPhenotype & phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
+ phenotype.SetNeutralMetric(neutral);
+
+ if (merit > 0) phenotype.SetMerit( cMerit(merit) );
+ schedule->Adjust(cell_id, phenotype.GetMerit());
+
+ LineageSetupOrganism(GetCell(cell_id).GetOrganism(), 0, lineage_label);
+ }
+ else
+ {
+ GetCell(cell_id).GetOrganism()->GetHardware().Inject_Host(cCodeLabel(), genome);
+ }
+
}
Index: avida/current/source/main/population.hh
diff -u avida/current/source/main/population.hh:1.55 avida/current/source/main/population.hh:1.55.2.1
--- avida/current/source/main/population.hh:1.55 Sat May 17 14:54:55 2003
+++ avida/current/source/main/population.hh Tue Aug 19 10:49:29 2003
@@ -102,7 +102,7 @@
// Inject and organism from the outside world.
void Inject(const cGenome & genome, int cell_id=-1, double merit=-1,
- int lineage_label=0, double neutral_metric=0 );
+ int lineage_label=0, double neutral_metric=0, int mem_space=0 );
// Deactivate an organism in the population (required for deactivations)
void KillOrganism(cPopulationCell & in_cell);
Index: avida/current/source/main/population_cell.cc
diff -u avida/current/source/main/population_cell.cc:1.8 avida/current/source/main/population_cell.cc:1.8.2.1
--- avida/current/source/main/population_cell.cc:1.8 Sat May 17 02:48:10 2003
+++ avida/current/source/main/population_cell.cc Tue Aug 19 10:49:29 2003
@@ -82,13 +82,17 @@
return input_array[cur_input++];
}
+int cPopulationCell::GetInputAt(int & input_pointer)
+{
+ if (input_pointer >= IO_SIZE) input_pointer = 0;
+ return input_array[input_pointer++];
+}
int cPopulationCell::GetInput(int id)
{
assert(id >= 0 && id < IO_SIZE);
return input_array[id];
}
-
void cPopulationCell::InsertOrganism(cOrganism & new_org)
{
Index: avida/current/source/main/population_cell.hh
diff -u avida/current/source/main/population_cell.hh:1.7 avida/current/source/main/population_cell.hh:1.7.2.1
--- avida/current/source/main/population_cell.hh:1.7 Sat May 17 02:48:10 2003
+++ avida/current/source/main/population_cell.hh Tue Aug 19 10:49:29 2003
@@ -52,7 +52,8 @@
const cMutationRates & MutationRates() const { return mutation_rates; }
cMutationRates & MutationRates() { return mutation_rates; }
int GetInput();
- int GetInput(int id);
+ int GetInput(int);
+ int GetInputAt(int & input_pointer);
int GetID() const { return cell_id; }
int GetOrganismCount() const { return organism_count; }
Index: avida/current/source/main/reaction.cc
diff -u avida/current/source/main/reaction.cc:1.5 avida/current/source/main/reaction.cc:1.5.2.1
--- avida/current/source/main/reaction.cc:1.5 Sat May 17 02:48:10 2003
+++ avida/current/source/main/reaction.cc Tue Aug 19 10:49:29 2003
@@ -27,6 +27,10 @@
, max_fraction(1.0)
, product(NULL)
, conversion(1.0)
+ , lethal(0)
+ , detect(NULL)
+ , detection_threshold(0.0)
+ , detection_error(0.0)
{
}
Index: avida/current/source/main/reaction.hh
diff -u avida/current/source/main/reaction.hh:1.3 avida/current/source/main/reaction.hh:1.3.4.1
--- avida/current/source/main/reaction.hh:1.3 Fri Oct 12 05:22:55 2001
+++ avida/current/source/main/reaction.hh Tue Aug 19 10:49:29 2003
@@ -32,6 +32,10 @@
double max_fraction; // Max fraction of avaiable resources useable.
cResource * product; // Output resource.
double conversion; // Conversion factor.
+ bool lethal; // Lethality of reaction
+ cResource * detect; // Resource Measured
+ double detection_threshold; //Minimum quantity of resource to register as present
+ double detection_error; //Var of Detection Event (as % of resource present)
public:
cReactionProcess();
~cReactionProcess();
@@ -44,6 +48,10 @@
double GetMaxFraction() const { return max_fraction; }
cResource * GetProduct() const { return product; }
double GetConversion() const { return conversion; }
+ bool GetLethal() const { return lethal; }
+ cResource * GetDetect() const { return detect; }
+ double GetDetectionThreshold() const { return detection_threshold; }
+ double GetDetectionError() const { return detection_error; }
void SetResource(cResource * _in) { resource = _in; }
void SetValue(double _in) { value = _in; }
@@ -53,6 +61,10 @@
void SetMaxFraction(double _in) { max_fraction = _in; }
void SetProduct(cResource * _in) { product = _in; }
void SetConversion(double _in) { conversion = _in; }
+ void SetLethal(int _in) { lethal = _in; }
+ void SetDetect(cResource * _in) { detect = _in; }
+ void SetDetectionThreshold(double _in) { detection_threshold = _in; }
+ void SetDetectionError(double _in) { detection_error = _in; }
};
class cReactionRequisite {
Index: avida/current/source/main/reaction_result.cc
diff -u avida/current/source/main/reaction_result.cc:1.2 avida/current/source/main/reaction_result.cc:1.2.2.1
--- avida/current/source/main/reaction_result.cc:1.2 Sat May 17 02:48:10 2003
+++ avida/current/source/main/reaction_result.cc Tue Aug 19 10:49:29 2003
@@ -13,10 +13,12 @@
const int num_reactions)
: resources_consumed(num_resources)
, resources_produced(num_resources)
+ , resources_detected(num_resources)
, tasks_done(num_tasks)
, reactions_triggered(num_reactions)
, bonus_add(0.0)
, bonus_mult(1.0)
+ , lethal(false)
, active_reaction(false)
{
}
@@ -43,8 +45,9 @@
if (active_reaction == true) return;
// To activate the reaction, we must initialize all counter settings.
- resources_consumed.SetAll(0);
- resources_produced.SetAll(0);
+ resources_consumed.SetAll(0.0);
+ resources_produced.SetAll(0.0);
+ resources_detected.SetAll(-1.0);
tasks_done.SetAll(false);
reactions_triggered.SetAll(false);
@@ -67,6 +70,18 @@
}
+void cReactionResult::Detect(int id, double num)
+{
+ ActivateReaction();
+ resources_detected[id] += num;
+}
+
+void cReactionResult::Lethal(bool flag)
+{
+ ActivateReaction();
+ lethal = flag;
+}
+
void cReactionResult::MarkTask(int id)
{
ActivateReaction();
@@ -106,6 +121,18 @@
{
if (GetActive() == false) return 0.0;
return resources_produced[id];
+}
+
+double cReactionResult::GetDetected(int id)
+{
+ if (GetActive() == false) return 0.0;
+ return resources_detected[id];
+}
+
+bool cReactionResult::GetLethal()
+{
+ if (GetActive() == false) return false;
+ return lethal;
}
bool cReactionResult::ReactionTriggered(int id)
Index: avida/current/source/main/reaction_result.hh
diff -u avida/current/source/main/reaction_result.hh:1.1 avida/current/source/main/reaction_result.hh:1.1.4.1
--- avida/current/source/main/reaction_result.hh:1.1 Sat Oct 27 12:21:33 2001
+++ avida/current/source/main/reaction_result.hh Tue Aug 19 10:49:29 2003
@@ -14,13 +14,13 @@
private:
tArray<double> resources_consumed;
tArray<double> resources_produced;
+ tArray<double> resources_detected; //Initialize to -1.0
tArray<bool> tasks_done;
tArray<bool> reactions_triggered;
double bonus_add;
double bonus_mult;
-
+ bool lethal;
bool active_reaction;
-
inline void ActivateReaction();
public:
cReactionResult(const int num_resources, const int num_tasks,
@@ -31,6 +31,8 @@
void Consume(int id, double num);
void Produce(int id, double num);
+ void Detect(int id, double num);
+ void Lethal(bool num);
void MarkTask(int id);
void MarkReaction(int id);
void AddBonus(double value);
@@ -38,6 +40,8 @@
double GetConsumed(int id);
double GetProduced(int id);
+ double GetDetected(int id);
+ bool GetLethal();
bool ReactionTriggered(int id);
bool TaskDone(int id);
double GetAddBonus();
Index: avida/current/source/qt-viewer/Makefile.am
diff -u avida/current/source/qt-viewer/Makefile.am:1.46.2.2 avida/current/source/qt-viewer/Makefile.am:1.46.2.3
--- avida/current/source/qt-viewer/Makefile.am:1.46.2.2 Wed Jun 4 09:36:34 2003
+++ avida/current/source/qt-viewer/Makefile.am Tue Aug 19 10:49:30 2003
@@ -173,3 +173,4 @@
setup_wizard_constants.cc \
setup_wizard_page.cc \
setup_wizard_page2.cc
+
Index: avida/current/source/qt-viewer/event_chooser.cpp
diff -u avida/current/source/qt-viewer/event_chooser.cpp:1.1.2.1 avida/current/source/qt-viewer/event_chooser.cpp:1.1.2.2
--- avida/current/source/qt-viewer/event_chooser.cpp:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/event_chooser.cpp Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form implementation generated from reading ui file 'event_chooser.ui'
**
-** Created: Wed Jun 4 11:40:24 2003
-** by: The User Interface Compiler ($Id: event_chooser.cpp,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:30 2003
+** by: The User Interface Compiler ($Id: event_chooser.cpp,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/event_chooser.h
diff -u avida/current/source/qt-viewer/event_chooser.h:1.1.2.1 avida/current/source/qt-viewer/event_chooser.h:1.1.2.2
--- avida/current/source/qt-viewer/event_chooser.h:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/event_chooser.h Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form interface generated from reading ui file 'event_chooser.ui'
**
-** Created: Wed Jun 4 11:40:24 2003
-** by: The User Interface Compiler ($Id: event_chooser.h,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:30 2003
+** by: The User Interface Compiler ($Id: event_chooser.h,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/event_list_editor.cpp
diff -u avida/current/source/qt-viewer/event_list_editor.cpp:1.1.2.1 avida/current/source/qt-viewer/event_list_editor.cpp:1.1.2.2
--- avida/current/source/qt-viewer/event_list_editor.cpp:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/event_list_editor.cpp Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form implementation generated from reading ui file 'event_list_editor.ui'
**
-** Created: Wed Jun 4 11:40:22 2003
-** by: The User Interface Compiler ($Id: event_list_editor.cpp,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: event_list_editor.cpp,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/event_list_editor.h
diff -u avida/current/source/qt-viewer/event_list_editor.h:1.1.2.1 avida/current/source/qt-viewer/event_list_editor.h:1.1.2.2
--- avida/current/source/qt-viewer/event_list_editor.h:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/event_list_editor.h Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form interface generated from reading ui file 'event_list_editor.ui'
**
-** Created: Wed Jun 4 11:40:22 2003
-** by: The User Interface Compiler ($Id: event_list_editor.h,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: event_list_editor.h,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/godbox.cpp
diff -u avida/current/source/qt-viewer/godbox.cpp:1.1.2.1 avida/current/source/qt-viewer/godbox.cpp:1.1.2.2
--- avida/current/source/qt-viewer/godbox.cpp:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/godbox.cpp Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form implementation generated from reading ui file 'godbox.ui'
**
-** Created: Wed Jun 4 11:40:21 2003
-** by: The User Interface Compiler ($Id: godbox.cpp,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: godbox.cpp,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/godbox.h
diff -u avida/current/source/qt-viewer/godbox.h:1.1.2.1 avida/current/source/qt-viewer/godbox.h:1.1.2.2
--- avida/current/source/qt-viewer/godbox.h:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/godbox.h Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form interface generated from reading ui file 'godbox.ui'
**
-** Created: Wed Jun 4 11:40:21 2003
-** by: The User Interface Compiler ($Id: godbox.h,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: godbox.h,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/map_view.cc
diff -u avida/current/source/qt-viewer/map_view.cc:1.11 avida/current/source/qt-viewer/map_view.cc:1.11.2.1
--- avida/current/source/qt-viewer/map_view.cc:1.11 Sat May 17 12:33:56 2003
+++ avida/current/source/qt-viewer/map_view.cc Tue Aug 19 10:49:30 2003
@@ -11,6 +11,7 @@
#include <qlayout.h>
#include <qslider.h>
#include <qcombobox.h>
+#include <qspinbox.h>
using namespace std;
@@ -93,19 +94,21 @@
m_mode_combo->setCurrentItem(3);
setMapMode( 3 );
+ // add box for zoom value
hlayout->addWidget( new QLabel( "Zoom: ", this ) );
- m_zoom_slider = new QSlider( QSlider::Horizontal, this );
- m_zoom_slider->setRange( 10, 500 );
- // m_zoom_slider->setTracking( false );
- hlayout->addWidget( m_zoom_slider, 5 );
+ m_zoom_spinbox = new QSpinBox( this );
+ m_zoom_spinbox->setMinValue( 10 );
+ m_zoom_spinbox->setMaxValue( 500 );
+ m_zoom_spinbox->setLineStep( 10 );
+ hlayout->addWidget( m_zoom_spinbox);
layout->addLayout( hlayout );
- connect( m_zoom_slider, SIGNAL( valueChanged ( int ) ),
+ connect( m_zoom_spinbox, SIGNAL( valueChanged ( int ) ),
this, SLOT( generateZoomValue( int ) ) );
connect( this, SIGNAL( zoomValueChanged( double ) ),
m_map_view_widget, SLOT( setZoomFactor( double ) ) );
- m_zoom_slider->setValue( 50 );
+ m_zoom_spinbox->setValue( 50 );
// activate the layout
layout->activate();
@@ -125,7 +128,7 @@
void
MapView::repaintMap()
{
- m_map_view_widget->drawViewport();
+ m_map_view_widget->drawViewport(false);
}
void
Index: avida/current/source/qt-viewer/map_view.hh
diff -u avida/current/source/qt-viewer/map_view.hh:1.8 avida/current/source/qt-viewer/map_view.hh:1.8.2.1
--- avida/current/source/qt-viewer/map_view.hh:1.8 Sat May 17 02:48:11 2003
+++ avida/current/source/qt-viewer/map_view.hh Tue Aug 19 10:49:30 2003
@@ -16,6 +16,7 @@
class QSlider;
class QComboBox;
+class QSpinBox;
//class cPopulation;
class avd_MissionControl;
@@ -28,7 +29,7 @@
avd_MissionControl *m_mission_control; // pointer to avida population
MapViewWidget *m_map_view_widget; // the main widget
ColorScaleWidget *m_color_scale_widget; // the color scale widget
- QSlider *m_zoom_slider;
+ QSpinBox *m_zoom_spinbox;
QSlider *m_center_x_slider;
QSlider *m_center_y_slider;
QComboBox *m_mode_combo;
Index: avida/current/source/qt-viewer/map_view_widget.cc
diff -u avida/current/source/qt-viewer/map_view_widget.cc:1.13 avida/current/source/qt-viewer/map_view_widget.cc:1.13.2.1
--- avida/current/source/qt-viewer/map_view_widget.cc:1.13 Sat May 17 12:33:57 2003
+++ avida/current/source/qt-viewer/map_view_widget.cc Tue Aug 19 10:49:30 2003
@@ -79,7 +79,7 @@
{
// uncomment the following line if you want to play around
// with the automatic centering after zoom.
-//#define __AUTO_CENTER_ON_ZOOM__
+#define __AUTO_CENTER_ON_ZOOM__
if ( value > 0 ){
#ifdef __AUTO_CENTER_ON_ZOOM__
@@ -87,6 +87,7 @@
#endif
m_zoom = value;
+
blockSignals( true ); // block all signals (we want to draw only once).
@@ -111,15 +112,34 @@
// get the current center:
#ifdef __AUTO_CENTER_ON_ZOOM__
- int cx = contentsX() + visibleWidth()/2;
- int cy = contentsY() + visibleHeight()/2;
+
+ int width;
+ int height;
+
+ // use appropriate width to calculate new center, mapsize if it's
+ // smaller than visible area, otherwise visible area
+ if( visibleWidth() < m_world_x*old_zoom*m_cell_width )
+ width = visibleWidth();
+ else
+ width = m_world_x*old_zoom*m_cell_width;
+ if( visibleHeight() < m_world_y*old_zoom*m_cell_height )
+ height = visibleHeight();
+ else
+ height = m_world_y*old_zoom*m_cell_height;
+
// recalculate the new center:
- cx = (int) (cx*m_zoom/old_zoom);
- cy = (int) (cy*m_zoom/old_zoom);
+ double dcx = contentsX() + width/2.;
+ double dcy = contentsY() + height/2.;
+ int cx = (int) (dcx*m_zoom/old_zoom);
+ int cy = (int) (dcy*m_zoom/old_zoom);
center( cx, cy ); // make sure the center stays the same after zoom
#endif
- drawViewport();
+ //if zooming out so map is getting smaller, first erase then draw
+ bool redraw = false;
+ if (old_zoom > m_zoom) redraw = true;
+
+ drawViewport(redraw);
blockSignals( false ); // now we can allow signals again.
}
@@ -135,7 +155,7 @@
// reverse offset for better user experience
m_x_offset = m_world_x - 1 - value;
allChanged(); // mark all cells as changed
- drawViewport();
+ drawViewport(false);
}
}
@@ -146,7 +166,7 @@
// reverse offset for better user experience
m_y_offset = m_world_y - 1 - value;
allChanged(); // mark all cells as changed
- drawViewport();
+ drawViewport(false);
}
}
@@ -154,7 +174,7 @@
MapViewWidget::setMapMode( MapViewCellColorUtil::MapMode mode )
{
m_color_util->setMapMode( mode );
- drawViewport();
+ drawViewport(false);
}
void
@@ -240,9 +260,9 @@
void
-MapViewWidget::drawViewport()
+MapViewWidget::drawViewport(bool redraw)
{
- viewport()->repaint( false );
+ viewport()->repaint( redraw );
}
void
@@ -350,7 +370,7 @@
emit cellSelected( m_x_selected
+ m_world_x * m_y_selected );
- drawViewport();
+ drawViewport(false);
}
//#include "map_view_widget.moc"
Index: avida/current/source/qt-viewer/map_view_widget.hh
diff -u avida/current/source/qt-viewer/map_view_widget.hh:1.9 avida/current/source/qt-viewer/map_view_widget.hh:1.9.2.1
--- avida/current/source/qt-viewer/map_view_widget.hh:1.9 Sat May 17 02:48:11 2003
+++ avida/current/source/qt-viewer/map_view_widget.hh Tue Aug 19 10:49:30 2003
@@ -152,7 +152,7 @@
/**
* Redraws everything.
**/
- void drawViewport();
+ void drawViewport(bool redraw);
/**
Index: avida/current/source/qt-viewer/plot_select_dia.cpp
diff -u avida/current/source/qt-viewer/plot_select_dia.cpp:1.1.2.1 avida/current/source/qt-viewer/plot_select_dia.cpp:1.1.2.2
--- avida/current/source/qt-viewer/plot_select_dia.cpp:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/plot_select_dia.cpp Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form implementation generated from reading ui file 'plot_select_dia.ui'
**
-** Created: Wed Jun 4 11:40:21 2003
-** by: The User Interface Compiler ($Id: plot_select_dia.cpp,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: plot_select_dia.cpp,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/plot_select_dia.h
diff -u avida/current/source/qt-viewer/plot_select_dia.h:1.1.2.1 avida/current/source/qt-viewer/plot_select_dia.h:1.1.2.2
--- avida/current/source/qt-viewer/plot_select_dia.h:1.1.2.1 Wed Jun 4 09:42:42 2003
+++ avida/current/source/qt-viewer/plot_select_dia.h Tue Aug 19 10:49:30 2003
@@ -1,8 +1,8 @@
/****************************************************************************
** Form interface generated from reading ui file 'plot_select_dia.ui'
**
-** Created: Wed Jun 4 11:40:21 2003
-** by: The User Interface Compiler ($Id: plot_select_dia.h,v 1.1.2.1 2003/06/04 16:42:42 goingssh Exp $)
+** Created: Thu Aug 7 14:17:29 2003
+** by: The User Interface Compiler ($Id: plot_select_dia.h,v 1.1.2.2 2003/08/19 17:49:30 goingssh Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
Index: avida/current/source/qt-viewer/population_cell_wrapper.hh
diff -u avida/current/source/qt-viewer/population_cell_wrapper.hh:1.4.2.1 avida/current/source/qt-viewer/population_cell_wrapper.hh:1.4.2.2
--- avida/current/source/qt-viewer/population_cell_wrapper.hh:1.4.2.1 Wed Jun 4 09:42:26 2003
+++ avida/current/source/qt-viewer/population_cell_wrapper.hh Tue Aug 19 10:49:30 2003
@@ -60,7 +60,7 @@
* PopulationCellWrapper instance.
*
* @short Encapsulates an Avida population cell and changes to its data.
- * @version $Id: population_cell_wrapper.hh,v 1.4.2.1 2003/06/04 16:42:26 goingssh Exp $
+ * @version $Id: population_cell_wrapper.hh,v 1.4.2.2 2003/08/19 17:49:30 goingssh Exp $
* @see avd_CellViewListItem
* @see avd_WidgetListItem
* @see avd_WidgetList
Index: avida/current/source/qt-viewer/qt-viewer.pro
diff -u avida/current/source/qt-viewer/qt-viewer.pro:1.3.2.1 avida/current/source/qt-viewer/qt-viewer.pro:1.3.2.2
--- avida/current/source/qt-viewer/qt-viewer.pro:1.3.2.1 Fri May 23 16:22:31 2003
+++ avida/current/source/qt-viewer/qt-viewer.pro Tue Aug 19 10:49:30 2003
@@ -6,9 +6,13 @@
DESTDIR = ../../work
CONFIG *= qt thread
CONFIG *= cpu event main trio tools
-CONFIG += console
+# These must be conditional on platform type. If they are active under
+# macx then the installation breaks.
+win32 {
+CONFIG += console
QMAKE_LFLAGS_CONSOLE += /FORCE:MULTIPLE
+}
OBJECTS_DIR = objs
MOC_DIR = moc
Index: avida/current/source/qt-viewer/setup_avida.cc
diff -u avida/current/source/qt-viewer/setup_avida.cc:1.21.2.1 avida/current/source/qt-viewer/setup_avida.cc:1.21.2.2
--- avida/current/source/qt-viewer/setup_avida.cc:1.21.2.1 Fri May 23 12:05:38 2003
+++ avida/current/source/qt-viewer/setup_avida.cc Tue Aug 19 10:49:30 2003
@@ -80,16 +80,12 @@
}
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardwareCPU::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPUOriginal(cConfig::GetInstFilename(),
environment.GetInstSet());
}
else if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK) {
-#ifdef USE_INST_SET_CODE
environment.GetInstSet().SetInstLib(cHardware4Stack::GetInstLib());
-#endif /* USE_INST_SET_CODE */
cHardwareUtil::LoadInstSet_CPU4Stack(cConfig::GetInstFilename(),
environment.GetInstSet());
}
Index: avida/current/source/qt-viewer/wizard.ui
diff -u avida/current/source/qt-viewer/wizard.ui:1.7.2.1 avida/current/source/qt-viewer/wizard.ui:1.7.2.2
--- avida/current/source/qt-viewer/wizard.ui:1.7.2.1 Wed Jun 4 09:42:26 2003
+++ avida/current/source/qt-viewer/wizard.ui Tue Aug 19 10:49:30 2003
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>SetupAssistant</class>
<widget class="QWizard">
<property name="name">
Index: avida/current/source/qt-viewer/exp/avd_widget_list.hh
diff -u avida/current/source/qt-viewer/exp/avd_widget_list.hh:1.6.2.1 avida/current/source/qt-viewer/exp/avd_widget_list.hh:1.6.2.2
--- avida/current/source/qt-viewer/exp/avd_widget_list.hh:1.6.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/qt-viewer/exp/avd_widget_list.hh Tue Aug 19 10:49:30 2003
@@ -37,7 +37,7 @@
* its subclasses.
*
* @short A scrollable collapsible container of other widgets.
- * @version $Id: avd_widget_list.hh,v 1.6.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * @version $Id: avd_widget_list.hh,v 1.6.2.2 2003/08/19 17:49:30 goingssh Exp $
* @see avd_WidgetListItem
*/
class avd_WidgetList : public QWidget {
Index: avida/current/source/qt-viewer/exp/avd_widget_list_item.hh
diff -u avida/current/source/qt-viewer/exp/avd_widget_list_item.hh:1.5.2.1 avida/current/source/qt-viewer/exp/avd_widget_list_item.hh:1.5.2.2
--- avida/current/source/qt-viewer/exp/avd_widget_list_item.hh:1.5.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/qt-viewer/exp/avd_widget_list_item.hh Tue Aug 19 10:49:31 2003
@@ -27,7 +27,7 @@
* forming a collapsible hierarchial view of widgets.
*
* @short A labeled collapsible container of other widgets.
- * @version $Id: avd_widget_list_item.hh,v 1.5.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * @version $Id: avd_widget_list_item.hh,v 1.5.2.2 2003/08/19 17:49:31 goingssh Exp $
* @see avd_WidgetList
*/
class avd_WidgetListItem : public QWidget{
Index: avida/current/source/qt-viewer/exp/avd_widget_list_item_container.hh
diff -u avida/current/source/qt-viewer/exp/avd_widget_list_item_container.hh:1.5.2.1 avida/current/source/qt-viewer/exp/avd_widget_list_item_container.hh:1.5.2.2
--- avida/current/source/qt-viewer/exp/avd_widget_list_item_container.hh:1.5.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/qt-viewer/exp/avd_widget_list_item_container.hh Tue Aug 19 10:49:31 2003
@@ -20,7 +20,7 @@
* vertical layout.
*
* @short Part of the avd_WidgetListItem.
- * @version $Id: avd_widget_list_item_container.hh,v 1.5.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * @version $Id: avd_widget_list_item_container.hh,v 1.5.2.2 2003/08/19 17:49:31 goingssh Exp $
* @see avd_WidgetListItem
* @see avd_WidgetList
*/
Index: avida/current/source/support/genesis
diff -u avida/current/source/support/genesis:1.39 avida/current/source/support/genesis:1.39.2.1
--- avida/current/source/support/genesis:1.39 Sun May 18 20:27:49 2003
+++ avida/current/source/support/genesis Tue Aug 19 10:49:31 2003
@@ -3,7 +3,7 @@
# For more information, see doc/genesis.html
#############################################################################
-VERSION_ID 2.0b1 # Do not change this value!
+VERSION_ID 2.0b4 # Do not change this value!
### Architecture Variables ###
MAX_UPDATES -1 # Maximum updates to run simulation (-1 = no limit)
@@ -13,6 +13,8 @@
# 1 = MAX_UPDATES _AND_ MAX_GENERATIONS is reached
WORLD-X 60 # Width of the world in Avida mode.
WORLD-Y 60 # Height of the world in Avida mode.
+WORLD_GEOMETRY 2 # 1 = Bounded Grid
+ # 2 = Torus (Default)
RANDOM_SEED 0 # Random number seed. (0 for based on time)
HARDWARE_TYPE 0 # 0 = Original CPUs
# 1 = New, Stack-based CPUs
Index: avida/current/source/third-party/trio-1.9/example.c
diff -u avida/current/source/third-party/trio-1.9/example.c:1.3.2.1 avida/current/source/third-party/trio-1.9/example.c:1.3.2.2
--- avida/current/source/third-party/trio-1.9/example.c:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/example.c Tue Aug 19 10:49:31 2003
@@ -32,7 +32,7 @@
# define LONGEST LONGLONG
#endif
-static TRIO_CONST char rcsid[] = "@(#)$Id: example.c,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $";
+static TRIO_CONST char rcsid[] = "@(#)$Id: example.c,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $";
/*************************************************************************
*
Index: avida/current/source/third-party/trio-1.9/regression.c
diff -u avida/current/source/third-party/trio-1.9/regression.c:1.3.2.1 avida/current/source/third-party/trio-1.9/regression.c:1.3.2.2
--- avida/current/source/third-party/trio-1.9/regression.c:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/regression.c Tue Aug 19 10:49:31 2003
@@ -33,7 +33,7 @@
#define DOUBLE_EQUAL(x,y) (((x)>(y)-DBL_EPSILON) && ((x)<(y)+DBL_EPSILON))
#define FLOAT_EQUAL(x,y) (((x)>(y)-FLT_EPSILON) && ((x)<(y)+FLT_EPSILON))
-static TRIO_CONST char rcsid[] = "@(#)$Id: regression.c,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $";
+static TRIO_CONST char rcsid[] = "@(#)$Id: regression.c,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $";
/*************************************************************************
Index: avida/current/source/third-party/trio-1.9/strio.h
diff -u avida/current/source/third-party/trio-1.9/strio.h:1.3.2.1 avida/current/source/third-party/trio-1.9/strio.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/strio.h:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/strio.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: strio.h,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: strio.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/trio.c
diff -u avida/current/source/third-party/trio-1.9/trio.c:1.4.2.1 avida/current/source/third-party/trio-1.9/trio.c:1.4.2.2
--- avida/current/source/third-party/trio-1.9/trio.c:1.4.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/trio.c Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: trio.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: trio.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
*
@@ -720,7 +720,7 @@
*
*************************************************************************/
-static TRIO_CONST char rcsid[] = "@(#)$Id: trio.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $";
+static TRIO_CONST char rcsid[] = "@(#)$Id: trio.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $";
/*
* Need this to workaround a parser bug in HP C/iX compiler that fails
Index: avida/current/source/third-party/trio-1.9/trio.h
diff -u avida/current/source/third-party/trio-1.9/trio.h:1.3.2.1 avida/current/source/third-party/trio-1.9/trio.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/trio.h:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/trio.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: trio.h,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: trio.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 1998 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/triodef.h
diff -u avida/current/source/third-party/trio-1.9/triodef.h:1.4.2.1 avida/current/source/third-party/trio-1.9/triodef.h:1.4.2.2
--- avida/current/source/third-party/trio-1.9/triodef.h:1.4.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/triodef.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: triodef.h,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: triodef.h,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese <breese at users.sourceforge.net>
*
Index: avida/current/source/third-party/trio-1.9/trionan.c
diff -u avida/current/source/third-party/trio-1.9/trionan.c:1.4.2.1 avida/current/source/third-party/trio-1.9/trionan.c:1.4.2.2
--- avida/current/source/third-party/trio-1.9/trionan.c:1.4.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/trionan.c Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: trionan.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: trionan.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese <breese at users.sourceforge.net>
*
@@ -106,7 +106,7 @@
* Constants
*/
-static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $";
+static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $";
#if defined(USE_IEEE_754)
Index: avida/current/source/third-party/trio-1.9/trionan.h
diff -u avida/current/source/third-party/trio-1.9/trionan.h:1.3.2.1 avida/current/source/third-party/trio-1.9/trionan.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/trionan.h:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/trionan.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: trionan.h,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: trionan.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese <breese at users.sourceforge.net>
*
Index: avida/current/source/third-party/trio-1.9/triop.h
diff -u avida/current/source/third-party/trio-1.9/triop.h:1.3.2.1 avida/current/source/third-party/trio-1.9/triop.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/triop.h:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/triop.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: triop.h,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: triop.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2000 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/triostr.c
diff -u avida/current/source/third-party/trio-1.9/triostr.c:1.4.2.1 avida/current/source/third-party/trio-1.9/triostr.c:1.4.2.2
--- avida/current/source/third-party/trio-1.9/triostr.c:1.4.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/triostr.c Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: triostr.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: triostr.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
@@ -88,7 +88,7 @@
*/
#if !defined(TRIO_MINIMAL)
-static TRIO_CONST char rcsid[] = "@(#)$Id: triostr.c,v 1.4.2.1 2003/06/04 16:42:27 goingssh Exp $";
+static TRIO_CONST char rcsid[] = "@(#)$Id: triostr.c,v 1.4.2.2 2003/08/19 17:49:31 goingssh Exp $";
#endif
/*************************************************************************
Index: avida/current/source/third-party/trio-1.9/triostr.h
diff -u avida/current/source/third-party/trio-1.9/triostr.h:1.3.2.1 avida/current/source/third-party/trio-1.9/triostr.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/triostr.h:1.3.2.1 Wed Jun 4 09:42:27 2003
+++ avida/current/source/third-party/trio-1.9/triostr.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: triostr.h,v 1.3.2.1 2003/06/04 16:42:27 goingssh Exp $
+ * $Id: triostr.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc_dynamic.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc_dynamic.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc_dynamic.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc_dynamic.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc_dynamic.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc_dynamic.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc_dynamic.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc_printf.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc_printf.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc_printf.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc_printf.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc_printf.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc_printf.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc_printf.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc_register.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc_register.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc_register.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc_register.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc_register.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc_register.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc_register.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc_scanf.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc_scanf.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc_scanf.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc_scanf.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc_scanf.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc_scanf.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc_scanf.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/third-party/trio-1.9/doc/doc_static.h
diff -u avida/current/source/third-party/trio-1.9/doc/doc_static.h:1.3.2.1 avida/current/source/third-party/trio-1.9/doc/doc_static.h:1.3.2.2
--- avida/current/source/third-party/trio-1.9/doc/doc_static.h:1.3.2.1 Wed Jun 4 09:42:28 2003
+++ avida/current/source/third-party/trio-1.9/doc/doc_static.h Tue Aug 19 10:49:31 2003
@@ -1,6 +1,6 @@
/*************************************************************************
*
- * $Id: doc_static.h,v 1.3.2.1 2003/06/04 16:42:28 goingssh Exp $
+ * $Id: doc_static.h,v 1.3.2.2 2003/08/19 17:49:31 goingssh Exp $
*
* Copyright (C) 2001 Bjorn Reese and Daniel Stenberg.
*
Index: avida/current/source/tools/datafile.cc
diff -u avida/current/source/tools/datafile.cc:1.10 avida/current/source/tools/datafile.cc:1.10.2.1
--- avida/current/source/tools/datafile.cc:1.10 Sat May 17 02:48:15 2003
+++ avida/current/source/tools/datafile.cc Tue Aug 19 10:49:31 2003
@@ -81,6 +81,14 @@
}
}
+void cDataFile::WriteBlockElement(int i, int element, int x_size)
+{
+ m_fp << i << " ";
+ if (((element + 1) % x_size) == 0) {
+ m_fp << "\n";
+ }
+}
+
void cDataFile::WriteColumnDesc( const char * descr )
{
if ( !m_descr_written ){
More information about the Avida-cvs
mailing list