[Avida-cvs] [avida-svn] r976 - in branches/coopcomm: Avida.xcodeproj source/cpu source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Sat Sep 23 19:04:14 PDT 2006
Author: dknoester
Date: 2006-09-23 22:04:14 -0400 (Sat, 23 Sep 2006)
New Revision: 976
Removed:
branches/coopcomm/source/main/cOrgMessage.cc
Modified:
branches/coopcomm/Avida.xcodeproj/project.pbxproj
branches/coopcomm/source/cpu/cHardwareCPU.cc
branches/coopcomm/source/cpu/cHardwareCPU.h
branches/coopcomm/source/cpu/cTestCPUInterface.cc
branches/coopcomm/source/cpu/cTestCPUInterface.h
branches/coopcomm/source/main/cOrgInterface.h
branches/coopcomm/source/main/cOrgMessage.h
branches/coopcomm/source/main/cOrganism.cc
branches/coopcomm/source/main/cOrganism.h
branches/coopcomm/source/main/cPopulationCell.cc
branches/coopcomm/source/main/cPopulationCell.h
branches/coopcomm/source/main/cPopulationInterface.cc
branches/coopcomm/source/main/cPopulationInterface.h
branches/coopcomm/source/main/cTaskContext.h
branches/coopcomm/source/main/cTaskLib.cc
branches/coopcomm/source/main/cTaskLib.h
Log:
Current Head: 975
This is the first of a number of commits aimed at merging recent work on cooperative communication with the development branch of Avida (2.6+?).
This commit (re-)adds the following:
- Instructions for sending and receiving messages, and the associated
organism / cell infrastructure.
- Random per-cell identifiers and associated tracking.
- Current (as of 9/23) best-performing leader-election tasks, including:
MaxID (needs optimization)
SendID
SendNonID
SendSelf
Yet to be added:
- Logging / Statistics
Modified: branches/coopcomm/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/coopcomm/Avida.xcodeproj/project.pbxproj 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/Avida.xcodeproj/project.pbxproj 2006-09-24 02:04:14 UTC (rev 976)
@@ -10,7 +10,6 @@
7005A70409BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
7005A70609BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
7005A70809BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
- 7005A83209BA621F0007E16E /* cOrgMessage.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868808F49EA800FC65FE /* cOrgMessage.cc */; };
700E2996085A1F6000CF158A /* avida in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3164D07626CF3008F7A48 /* avida */; };
700E2AF8085DE50C00CF158A /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
700E2B87085DE54400CF158A /* avida-viewer in CopyFiles */ = {isa = PBXBuildFile; fileRef = 700E2B83085DE50C00CF158A /* avida-viewer */; };
@@ -107,9 +106,6 @@
709D924C0A5D950D00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
709D924D0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
709D924E0A5D950E00D6A163 /* cMutationalNeighborhood.cc in Sources */ = {isa = PBXBuildFile; fileRef = 709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */; };
- 70AA941A09D486CA006A24C8 /* system-alloc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCF50209CFB0B400924128 /* system-alloc.cc */; };
- 70AA941B09D486CB006A24C8 /* tcmalloc-logging.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCF57F09CFBD3D00924128 /* tcmalloc-logging.cc */; };
- 70AA941C09D486CD006A24C8 /* tcmalloc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCF56309CFBB9500924128 /* tcmalloc.cc */; };
70B0865908F4974300FC65FE /* cLandscape.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865108F4974300FC65FE /* cLandscape.cc */; };
70B0865C08F4974300FC65FE /* cLocalMutations.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865408F4974300FC65FE /* cLocalMutations.cc */; };
70B0865E08F4974300FC65FE /* cMutationLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865608F4974300FC65FE /* cMutationLib.cc */; };
@@ -123,7 +119,6 @@
70B0868D08F49EA800FC65FE /* cPopulation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868908F49EA800FC65FE /* cPopulation.cc */; };
70B0868E08F49EA800FC65FE /* cPopulationCell.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868A08F49EA800FC65FE /* cPopulationCell.cc */; };
70B0868F08F49EA800FC65FE /* cOrganism.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868708F49EA800FC65FE /* cOrganism.cc */; };
- 70B0869008F49EA800FC65FE /* cOrgMessage.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868808F49EA800FC65FE /* cOrgMessage.cc */; };
70B0869108F49EA800FC65FE /* cPopulation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868908F49EA800FC65FE /* cPopulation.cc */; };
70B0869208F49EA800FC65FE /* cPopulationCell.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868A08F49EA800FC65FE /* cPopulationCell.cc */; };
70B0869D08F49F4800FC65FE /* cPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0869C08F49F4800FC65FE /* cPhenotype.cc */; };
@@ -289,7 +284,6 @@
70DCACC0097AF7CC002F8733 /* cMutationLib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865608F4974300FC65FE /* cMutationLib.cc */; };
70DCACC1097AF7CC002F8733 /* cMutationRates.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865708F4974300FC65FE /* cMutationRates.cc */; };
70DCACC2097AF7CC002F8733 /* cOrganism.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868708F49EA800FC65FE /* cOrganism.cc */; };
- 70DCACC3097AF7CC002F8733 /* cOrgMessage.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868808F49EA800FC65FE /* cOrgMessage.cc */; };
70DCACC4097AF7CC002F8733 /* cPopulation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868908F49EA800FC65FE /* cPopulation.cc */; };
70DCACC5097AF7CC002F8733 /* cPopulationCell.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0868A08F49EA800FC65FE /* cPopulationCell.cc */; };
70DCACC6097AF7CC002F8733 /* cPhenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0869C08F49F4800FC65FE /* cPhenotype.cc */; };
@@ -354,7 +348,6 @@
70DCAD05097AF7CC002F8733 /* cDefaultAnalyzeDriver.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701D93E7094CBF71008B845F /* cDefaultAnalyzeDriver.cc */; };
70DCAD25097AF81A002F8733 /* cLexer.l in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAD21097AF81A002F8733 /* cLexer.l */; };
70DCAD2F097AF8BC002F8733 /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC57097AF730002F8733 /* main.cc */; };
- 70DCF66C09D4DE6500924128 /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
70F7D8CE09254787009E311D /* cFitnessMatrix.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB208DB7F8200068AC2 /* cFitnessMatrix.cc */; };
70F7DAF409290468009E311D /* cClassificationManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DAF009290468009E311D /* cClassificationManager.cc */; };
70F7DCA009293E76009E311D /* cClassificationManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DAF009290468009E311D /* cClassificationManager.cc */; };
@@ -380,16 +373,6 @@
};
/* End PBXBuildRule section */
-/* Begin PBXContainerItemProxy section */
- 70DCF67509D4E10500924128 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = DCC30C4D0762532C008F7A48 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 70AA941809D486AE006A24C8;
- remoteInfo = tcmalloc;
- };
-/* End PBXContainerItemProxy section */
-
/* Begin PBXCopyFilesBuildPhase section */
700E2B6D085DE50C00CF158A /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
@@ -623,7 +606,6 @@
709D92490A5D94FD00D6A163 /* cMutationalNeighborhood.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationalNeighborhood.h; sourceTree = "<group>"; };
709D924A0A5D94FD00D6A163 /* cMutationalNeighborhoodResults.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutationalNeighborhoodResults.h; sourceTree = "<group>"; };
709D924B0A5D950D00D6A163 /* cMutationalNeighborhood.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cMutationalNeighborhood.cc; sourceTree = "<group>"; };
- 70AA941909D486AE006A24C8 /* libtcmalloc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libtcmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
70B0864808F4972600FC65FE /* cLandscape.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLandscape.h; sourceTree = "<group>"; };
70B0864B08F4972600FC65FE /* cLocalMutations.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLocalMutations.h; sourceTree = "<group>"; };
70B0864C08F4972600FC65FE /* cMutation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cMutation.h; sourceTree = "<group>"; };
@@ -642,7 +624,6 @@
70B0868508F49E9700FC65FE /* cPopulation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPopulation.h; sourceTree = "<group>"; };
70B0868608F49E9700FC65FE /* cPopulationCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPopulationCell.h; sourceTree = "<group>"; };
70B0868708F49EA800FC65FE /* cOrganism.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cOrganism.cc; sourceTree = "<group>"; };
- 70B0868808F49EA800FC65FE /* cOrgMessage.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cOrgMessage.cc; sourceTree = "<group>"; };
70B0868908F49EA800FC65FE /* cPopulation.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPopulation.cc; sourceTree = "<group>"; };
70B0868A08F49EA800FC65FE /* cPopulationCell.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cPopulationCell.cc; sourceTree = "<group>"; };
70B0869B08F49F3900FC65FE /* cPhenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cPhenotype.h; sourceTree = "<group>"; };
@@ -952,13 +933,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- 70AA941709D486AE006A24C8 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
70DCAD07097AF7CC002F8733 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -970,7 +944,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 70DCF66C09D4DE6500924128 /* libtcmalloc.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1431,7 +1404,6 @@
70B0864F08F4972600FC65FE /* cMxCodeArray.h */,
70B0868708F49EA800FC65FE /* cOrganism.cc */,
70B0868308F49E9700FC65FE /* cOrganism.h */,
- 70B0868808F49EA800FC65FE /* cOrgMessage.cc */,
70B0868408F49E9700FC65FE /* cOrgMessage.h */,
70B0869C08F49F4800FC65FE /* cPhenotype.cc */,
70B0869B08F49F3900FC65FE /* cPhenotype.h */,
@@ -1719,23 +1691,12 @@
DCC3164D07626CF3008F7A48 /* avida */,
700E2B83085DE50C00CF158A /* avida-viewer */,
70DCAD1C097AF7CC002F8733 /* avida-s */,
- 70AA941909D486AE006A24C8 /* libtcmalloc.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
-/* Begin PBXHeadersBuildPhase section */
- 70AA941509D486AE006A24C8 /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
/* Begin PBXNativeTarget section */
700E2AF3085DE50C00CF158A /* avida-viewer */ = {
isa = PBXNativeTarget;
@@ -1755,23 +1716,6 @@
productReference = 700E2B83085DE50C00CF158A /* avida-viewer */;
productType = "com.apple.product-type.tool";
};
- 70AA941809D486AE006A24C8 /* tcmalloc */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 70AA942509D48715006A24C8 /* Build configuration list for PBXNativeTarget "tcmalloc" */;
- buildPhases = (
- 70AA941509D486AE006A24C8 /* Headers */,
- 70AA941609D486AE006A24C8 /* Sources */,
- 70AA941709D486AE006A24C8 /* Frameworks */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = tcmalloc;
- productName = tcmalloc;
- productReference = 70AA941909D486AE006A24C8 /* libtcmalloc.a */;
- productType = "com.apple.product-type.library.static";
- };
70DCAC9D097AF7CC002F8733 /* avida-s */ = {
isa = PBXNativeTarget;
buildConfigurationList = 70DCAD17097AF7CC002F8733 /* Build configuration list for PBXNativeTarget "avida-s" */;
@@ -1803,7 +1747,6 @@
buildRules = (
);
dependencies = (
- 70DCF67609D4E10500924128 /* PBXTargetDependency */,
);
name = avida;
productName = primitive;
@@ -1824,7 +1767,6 @@
DCC3164C07626CF3008F7A48 /* avida */,
70DCAC9D097AF7CC002F8733 /* avida-s */,
700E2AF3085DE50C00CF158A /* avida-viewer */,
- 70AA941809D486AE006A24C8 /* tcmalloc */,
);
};
/* End PBXProject section */
@@ -1841,7 +1783,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
- shellScript = "mkdir -p $DERIVED_FILE_DIR\nif (test -x /usr/bin/svn)\nthen svncmd=/usr/bin/svn\nelif (test -x /usr/local/bin/svn)\nthen svncmd=/usr/local/bin/svn\nelif (test -x /usr/local/svn/bin/svn)\nthen svncmd=/usr/local/svn/bin/svn\nelse\n echo \"Warning: 'svn' not found, please install subversion\"\n if [[ ! -f $DERIVED_FILE_DIR/revision.h ]]\n then\n echo \"#ifndef revision_h\" > $DERIVED_FILE_DIR/revision.h\n echo \"#define revision_h\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#define REVISION \\\"???\\\"\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#endif\" >> $DERIVED_FILE_DIR/revision.h\n fi\nfi\n\necho \"#ifndef revision_h\" > /tmp/newrev.tmp\necho \"#define revision_h\" >> /tmp/newrev.tmp\n$svncmd status -v Avida.xcodeproj/project.pbxproj | sed '1!d' | sed 's/[^ ]* *\\([0-9]*\\).*/#define REVISION \"\\1\"/' >> /tmp/newrev.tmp\necho \"#endif\" >> /tmp/newrev.tmp\n\nif [[ -f $DERIVED_FILE_DIR/revision.h ]]\nthen\n revdiff=`diff $DERIVED_FILE_DIR!
/revision.h /tmp/newrev.tmp`\nelse\n revdiff=\"yes\"\nfi\n\nif [[ -n \"$revdiff\" ]]\nthen\n echo \"New revision.h Generated\"\n cp /tmp/newrev.tmp $DERIVED_FILE_DIR/revision.h\n touch $SRCROOT/source/main/avida.cc\nfi\n\nrm /tmp/newrev.tmp\n";
+ shellScript = "mkdir -p $DERIVED_FILE_DIR\nif (test -x /usr/bin/svn)\nthen svncmd=/usr/bin/svn\nelif (test -x /usr/local/bin/svn)\nthen svncmd=/usr/local/bin/svn\nelif (test -x /usr/local/svn/bin/svn)\nthen svncmd=/usr/local/svn/bin/svn\nelif (test -x /opt/local/bin/svn)\nthen svncmd=/opt/local/bin/svn\nelse\n echo \"Warning: 'svn' not found, please install subversion\"\n if [[ ! -f $DERIVED_FILE_DIR/revision.h ]]\n then\n echo \"#ifndef revision_h\" > $DERIVED_FILE_DIR/revision.h\n echo \"#define revision_h\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#define REVISION \\\"???\\\"\" >> $DERIVED_FILE_DIR/revision.h\n echo \"#endif\" >> $DERIVED_FILE_DIR/revision.h\n fi\nfi\n\necho \"#ifndef revision_h\" > /tmp/newrev.tmp\necho \"#define revision_h\" >> /tmp/newrev.tmp\n$svncmd status -v Avida.xcodeproj/project.pbxproj | sed '1!d' | sed 's/[^ ]* *\\([0-9]*\\).*/#define REVISION \"\\1\"/' >> /tmp/newrev.tmp\necho \"#endif\" >> /tmp/newrev.tmp\n\nif [[ -f $DERI!
VED_FILE_DIR/revision.h ]]\nthen\n revdiff=`diff $DERIVED_FILE_DIR/revision.h /tmp/newrev.tmp`\nelse\n revdiff=\"yes\"\nfi\n\nif [[ -n \"$revdiff\" ]]\nthen\n echo \"New revision.h Generated\"\n cp /tmp/newrev.tmp $DERIVED_FILE_DIR/revision.h\n touch $SRCROOT/source/main/avida.cc\nfi\n\nrm /tmp/newrev.tmp\n";
};
704EAD9808FF3C1F005D5C24 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -1903,7 +1845,6 @@
70B0866708F4974300FC65FE /* cMutationRates.cc in Sources */,
70B0866808F4974300FC65FE /* cMxCodeArray.cc in Sources */,
70B0868F08F49EA800FC65FE /* cOrganism.cc in Sources */,
- 70B0869008F49EA800FC65FE /* cOrgMessage.cc in Sources */,
70B0869108F49EA800FC65FE /* cPopulation.cc in Sources */,
70B0869208F49EA800FC65FE /* cPopulationCell.cc in Sources */,
70B0869E08F49F4800FC65FE /* cPhenotype.cc in Sources */,
@@ -1998,16 +1939,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- 70AA941609D486AE006A24C8 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 70AA941A09D486CA006A24C8 /* system-alloc.cc in Sources */,
- 70AA941B09D486CB006A24C8 /* tcmalloc-logging.cc in Sources */,
- 70AA941C09D486CD006A24C8 /* tcmalloc.cc in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
70DCAC9F097AF7CC002F8733 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -2040,7 +1971,6 @@
70DCACC0097AF7CC002F8733 /* cMutationLib.cc in Sources */,
70DCACC1097AF7CC002F8733 /* cMutationRates.cc in Sources */,
70DCACC2097AF7CC002F8733 /* cOrganism.cc in Sources */,
- 70DCACC3097AF7CC002F8733 /* cOrgMessage.cc in Sources */,
70DCACC4097AF7CC002F8733 /* cPopulation.cc in Sources */,
70DCACC5097AF7CC002F8733 /* cPopulationCell.cc in Sources */,
70DCACC6097AF7CC002F8733 /* cPhenotype.cc in Sources */,
@@ -2225,7 +2155,6 @@
7054A17509A8014600038658 /* cAnalyzeJobQueue.cc in Sources */,
7054A1BA09A810CB00038658 /* cAnalyzeJobWorker.cc in Sources */,
7005A70809BA0FA90007E16E /* cTestCPUInterface.cc in Sources */,
- 7005A83209BA621F0007E16E /* cOrgMessage.cc in Sources */,
707AF0B209EAC7FD001AEA89 /* LandscapeActions.cc in Sources */,
705ACD4F0A13FED5002D5BA0 /* PrintActions.cc in Sources */,
708051B20A1F663100CBB8B6 /* SaveLoadActions.cc in Sources */,
@@ -2243,14 +2172,6 @@
};
/* End PBXSourcesBuildPhase section */
-/* Begin PBXTargetDependency section */
- 70DCF67609D4E10500924128 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 70AA941809D486AE006A24C8 /* tcmalloc */;
- targetProxy = 70DCF67509D4E10500924128 /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
/* Begin XCBuildConfiguration section */
700E2B7F085DE50C00CF158A /* Development */ = {
isa = XCBuildConfiguration;
@@ -2285,11 +2206,14 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_MODEL_CPU = G4;
+ HEADER_SEARCH_PATHS = "";
OTHER_LDFLAGS = (
"-multiply_defined",
suppress,
);
PRODUCT_NAME = avida;
+ SDKROOT = "";
+ USER_HEADER_SEARCH_PATHS = "";
};
name = Development;
};
@@ -2297,11 +2221,14 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_MODEL_CPU = G4;
+ HEADER_SEARCH_PATHS = "";
OTHER_LDFLAGS = (
"-multiply_defined",
suppress,
);
PRODUCT_NAME = avida;
+ SDKROOT = "";
+ USER_HEADER_SEARCH_PATHS = "";
};
name = "Deployment-G4";
};
@@ -2357,68 +2284,18 @@
};
name = "Deployment-G4";
};
- 70AA942609D48715006A24C8 /* Development */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_EXCEPTIONS = YES;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_THREADSAFE_STATICS = NO;
- INSTALL_PATH = /usr/local/lib;
- PREBINDING = NO;
- PRODUCT_NAME = tcmalloc;
- ZERO_LINK = YES;
- };
- name = Development;
- };
- 70AA942709D48715006A24C8 /* Deployment-G4 */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
- GCC_MODEL_TUNING = G4;
- GCC_THREADSAFE_STATICS = NO;
- PRODUCT_NAME = tcmalloc;
- };
- name = "Deployment-G4";
- };
- 70AA942809D48715006A24C8 /* Deployment-G5 */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
- GCC_MODEL_TUNING = G5;
- GCC_THREADSAFE_STATICS = NO;
- PRODUCT_NAME = tcmalloc;
- };
- name = "Deployment-G5";
- };
- 70AA942909D48715006A24C8 /* Profile */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_MODEL_TUNING = G5;
- GCC_THREADSAFE_STATICS = NO;
- PRODUCT_NAME = tcmalloc;
- };
- name = Profile;
- };
70B393DC0944CA6F0018F09D /* Deployment-G5 */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_MODEL_CPU = G4;
+ HEADER_SEARCH_PATHS = "";
OTHER_LDFLAGS = (
"-multiply_defined",
suppress,
);
PRODUCT_NAME = avida;
+ SDKROOT = "";
+ USER_HEADER_SEARCH_PATHS = "";
};
name = "Deployment-G5";
};
@@ -2426,11 +2303,14 @@
isa = XCBuildConfiguration;
buildSettings = {
GCC_MODEL_CPU = G4;
+ HEADER_SEARCH_PATHS = "";
OTHER_LDFLAGS = (
"-multiply_defined",
suppress,
);
PRODUCT_NAME = avida;
+ SDKROOT = "";
+ USER_HEADER_SEARCH_PATHS = "";
};
name = Profile;
};
@@ -2563,27 +2443,18 @@
};
name = Profile;
};
- E62620990A372B9900C07685 /* Deployment-Universal */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
- GCC_MODEL_TUNING = G5;
- GCC_THREADSAFE_STATICS = NO;
- PRODUCT_NAME = tcmalloc;
- };
- name = "Deployment-Universal";
- };
E626209A0A372B9900C07685 /* Deployment-Universal */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_MODEL_CPU = G4;
+ HEADER_SEARCH_PATHS = "";
OTHER_LDFLAGS = (
"-multiply_defined",
suppress,
);
PRODUCT_NAME = avida;
+ SDKROOT = "";
+ USER_HEADER_SEARCH_PATHS = "";
};
name = "Deployment-Universal";
};
@@ -2686,18 +2557,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = "Deployment-G4";
};
- 70AA942509D48715006A24C8 /* Build configuration list for PBXNativeTarget "tcmalloc" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 70AA942609D48715006A24C8 /* Development */,
- 70AA942709D48715006A24C8 /* Deployment-G4 */,
- 70AA942809D48715006A24C8 /* Deployment-G5 */,
- E62620990A372B9900C07685 /* Deployment-Universal */,
- 70AA942909D48715006A24C8 /* Profile */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = "Deployment-G4";
- };
70DCAD17097AF7CC002F8733 /* Build configuration list for PBXNativeTarget "avida-s" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Modified: branches/coopcomm/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/coopcomm/source/cpu/cHardwareCPU.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/cpu/cHardwareCPU.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -29,6 +29,7 @@
#include "cTestCPU.h"
#include "cWorldDriver.h"
#include "cWorld.h"
+#include "cOrgMessage.h"
#include <limits.h>
#include <fstream>
@@ -346,11 +347,13 @@
cInstEntryCPU("kazi5", &cHardwareCPU::Inst_Kazi5),
cInstEntryCPU("die", &cHardwareCPU::Inst_Die),
-
-
// Placebo instructions
// nop-x (included with nops)
- cInstEntryCPU("skip", &cHardwareCPU::Inst_Skip)
+ cInstEntryCPU("skip", &cHardwareCPU::Inst_Skip),
+
+ // Coop-comm
+ cInstEntryCPU("send-msg", &cHardwareCPU::Inst_SendMessage),
+ cInstEntryCPU("recv-msg", &cHardwareCPU::Inst_ReceiveMessage)
};
const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -3363,3 +3366,42 @@
return true;
}
+
+/*! Send a message to the organism that is currently faced by this cell,
+where the label field of sent message is from register ?BX?, and the data field
+is from register ~?BX?.
+*/
+bool cHardwareCPU::Inst_SendMessage(cAvidaContext& ctx)
+{
+ const int label_reg = FindModifiedRegister(REG_BX);
+ const int data_reg = FindNextRegister(label_reg);
+
+ cOrgMessage msg = cOrgMessage(organism);
+ msg.SetLabel(GetRegister(label_reg));
+ msg.SetData(GetRegister(data_reg));
+ return organism->SendMessage(ctx, msg);
+}
+
+
+/*! This method /attempts/ to receive a message -- It may not be possible, as in
+the case of an empty receive buffer.
+
+If a message is available, ?BX? is set to the message's label, and ~?BX? is set
+to its data.
+
+Note that though this instruction is named "receive," the act of bringing a
+message into the CPU is termed "retrieving a message."
+*/
+bool cHardwareCPU::Inst_ReceiveMessage(cAvidaContext& ctx)
+{
+ const cOrgMessage* msg = organism->RetrieveMessage();
+ if(msg==NULL)
+ return false;
+
+ const int label_reg = FindModifiedRegister(REG_BX);
+ const int data_reg = FindNextRegister(label_reg);
+
+ GetRegister(label_reg) = msg->GetLabel();
+ GetRegister(data_reg) = msg->GetData();
+ return true;
+}
Modified: branches/coopcomm/source/cpu/cHardwareCPU.h
===================================================================
--- branches/coopcomm/source/cpu/cHardwareCPU.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/cpu/cHardwareCPU.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -470,6 +470,10 @@
//// Placebo ////
bool Inst_Skip(cAvidaContext& ctx);
+
+ // Coop-comm
+ bool Inst_SendMessage(cAvidaContext& ctx); //!< Send a message to the faced organism.
+ bool Inst_ReceiveMessage(cAvidaContext& ctx); //!< Receive a message.
};
Modified: branches/coopcomm/source/cpu/cTestCPUInterface.cc
===================================================================
--- branches/coopcomm/source/cpu/cTestCPUInterface.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/cpu/cTestCPUInterface.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -71,11 +71,6 @@
// record the probability it used.
}
-bool cTestCPUInterface::SendMessage(cOrgMessage& mess)
-{
- return false;
-}
-
int cTestCPUInterface::ReceiveValue()
{
return m_testcpu->GetReceiveValue();
Modified: branches/coopcomm/source/cpu/cTestCPUInterface.h
===================================================================
--- branches/coopcomm/source/cpu/cTestCPUInterface.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/cpu/cTestCPUInterface.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -44,7 +44,6 @@
void UpdateResources(const tArray<double>& res_change);
void Die();
void Kaboom(int distance);
- bool SendMessage(cOrgMessage& mess);
cOrgSinkMessage* NetReceive() { return NULL; } // @DMB - todo: receive message
bool NetRemoteValidate(cAvidaContext& ctx, cOrgSinkMessage* msg) { return false; } // @DMB - todo: validate message
int ReceiveValue();
@@ -53,6 +52,9 @@
bool InjectParasite(cOrganism* parent, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
bool TestOnDivide() { return false; }
+
+ bool SendMessage(cOrgMessage& mess) { return false; }
+ int GetRandomCellID() { return 0; }
};
Modified: branches/coopcomm/source/main/cOrgInterface.h
===================================================================
--- branches/coopcomm/source/main/cOrgInterface.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cOrgInterface.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -44,7 +44,6 @@
virtual void UpdateResources(const tArray<double>& res_change) = 0;
virtual void Die() = 0;
virtual void Kaboom(int distance) = 0;
- virtual bool SendMessage(cOrgMessage& mess) = 0;
virtual cOrgSinkMessage* NetReceive() = 0;
virtual bool NetRemoteValidate(cAvidaContext& ctx, cOrgSinkMessage* msg) = 0;
virtual int ReceiveValue() = 0;
@@ -53,6 +52,9 @@
virtual bool InjectParasite(cOrganism* parent, const cGenome& injected_code) = 0;
virtual bool UpdateMerit(double new_merit) = 0;
virtual bool TestOnDivide() = 0;
+
+ virtual bool SendMessage(cOrgMessage& msg) = 0;
+ virtual int GetRandomCellID() = 0; //!< Returns the random cell ID for the cell in which this organism lives.
};
#endif
Deleted: branches/coopcomm/source/main/cOrgMessage.cc
===================================================================
--- branches/coopcomm/source/main/cOrgMessage.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cOrgMessage.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -1,37 +0,0 @@
-/*
- * cOrgMessage.cc
- * Avida
- *
- * Called "org_message.cc" prior to 12/5/05.
- * Copyright 2005-2006 Michigan State University. All rights reserved.
- * Copyright 1993-2003 California Institute of Technology.
- *
- */
-
-#include "cOrgMessage.h"
-
-#include <sstream>
-
-void cOrgMessage::SetData(int in_data)
-{
- std::stringstream ss;
- ss << in_data;
- ss >> data;
-}
-
-void cOrgMessage::SetData(double in_data)
-{
- std::stringstream ss;
- ss << in_data;
- ss >> data;
-}
-
-void cOrgMessage::GetData(int & in_data)
-{
- in_data=atoi(data.c_str());
-}
-
-void cOrgMessage::GetData(double & in_data)
-{
- in_data=atof(data.c_str());
-}
Modified: branches/coopcomm/source/main/cOrgMessage.h
===================================================================
--- branches/coopcomm/source/main/cOrgMessage.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cOrgMessage.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -11,36 +11,49 @@
#ifndef cOrgMessage_h
#define cOrgMessage_h
-#include <string>
+#include <functional>
+#include "cOrganism.h"
+
class cOrgMessage
{
private:
- int time;
- int sender_id;
- int recipient_id;
- std::string label;
- std::string data;
-
+ cOrganism* m_pSender;
+ cOrganism* m_pReceiver;
+ int m_data;
+ int m_label;
+
public:
- cOrgMessage() : time(-1), sender_id(-1), recipient_id(-1), label(""), data("") { ; }
- cOrgMessage(std::string in_label, std::string in_data) { label = in_label; data = in_data; }
+ cOrgMessage(cOrganism* sender) :
+ m_pSender(sender),
+ m_pReceiver(NULL),
+ m_data(0),
+ m_label(0)
+ { }
- void SetTime(int in_time) { time = in_time; }
- void SetSenderID(int in_id) { sender_id = in_id; }
- void SetRecipientID(int in_id) { recipient_id = in_id; }
- void SetLabel(int in_label) { label = in_label; }
+ cOrganism* GetSender() { return m_pSender; }
+ cOrganism* GetReceiver() { return m_pReceiver; }
+ void SetReceiver(cOrganism* recvr) { m_pReceiver = recvr; }
- void SetData(std::string in_data) { data = in_data; }
- void SetData(int in_data);
- void SetData(double in_data);
+ int GetData() const { return m_data; }
+ int GetLabel() const { return m_label; }
- void GetData(std::string & in_data) { in_data=data; }
- void GetData(int & in_data);
- void GetData(double & in_data);
+ void SetData(int data) { m_data = data; }
+ void SetLabel(int label) { m_label = label; }
};
+/*! \brief An STL-compatible comparator for cOrgMessages.
+Returns a boolean representing whether the data field of arg1 is less than the
+data field of arg2.
+*/
+struct cOrgMessage_Less : public std::binary_function<cOrgMessage, cOrgMessage, bool> {
+ bool operator()(const cOrgMessage& a, const cOrgMessage& b) const {
+ return a.GetData() < b.GetData();
+ }
+};
+
+
#ifdef ENABLE_UNIT_TESTS
namespace nOrgMessage {
/**
Modified: branches/coopcomm/source/main/cOrganism.cc
===================================================================
--- branches/coopcomm/source/main/cOrganism.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cOrganism.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -53,11 +53,10 @@
, max_executed(-1)
, lineage_label(-1)
, lineage(NULL)
- , inbox(0)
- , sent(0)
, m_net(NULL)
, received_messages(RECEIVED_MESSAGES_SIZE)
, is_running(false)
+ , m_retrieve_pos(0)
{
// Initialization of structures...
m_hardware = m_world->GetHardwareManager().Create(this);
@@ -208,24 +207,7 @@
}
}
-void cOrganism::SendMessage(cOrgMessage & mess)
-{
- assert(m_interface);
- if(m_interface->SendMessage(mess))
- sent.Add(mess);
- else
- {
- //perhaps some kind of message error buffer?
- }
-}
-bool cOrganism::ReceiveMessage(cOrgMessage & mess)
-{
- inbox.Add(mess);
- return true;
-}
-
-
void cOrganism::NetGet(cAvidaContext& ctx, int& value, int& seq)
{
assert(m_net);
@@ -519,3 +501,87 @@
phenotype.IncErrors();
}
+
+
+/*! Attempt to send the message (which is actually based on the facing of the
+cell), and if successful, store the sent message, check to see if sending this
+message completed any tasks, and run any message-specific callbacks.
+*/
+bool cOrganism::SendMessage(cAvidaContext& ctx, cOrgMessage& msg)
+{
+ assert(m_interface);
+ if(m_interface->SendMessage(msg)) {
+ // store the message.
+ m_sent_messages.push_back(msg);
+
+ assert(m_interface);
+ const tArray<double>& resource_count = m_interface->GetResources();
+
+ tList<tBuffer<int> > other_input_list;
+ tList<tBuffer<int> > other_output_list;
+
+ // If tasks require us to consider neighbor inputs, collect them...
+ if (m_world->GetEnvironment().GetTaskLib().UseNeighborInput() == true) {
+ const int num_neighbors = m_interface->GetNumNeighbors();
+ for (int i = 0; i < num_neighbors; i++) {
+ m_interface->Rotate();
+ cOrganism * cur_neighbor = m_interface->GetNeighbor();
+ if (cur_neighbor == NULL) continue;
+
+ other_input_list.Push( &(cur_neighbor->input_buf) );
+ }
+ }
+
+ // If tasks require us to consider neighbor outputs, collect them...
+ if (m_world->GetEnvironment().GetTaskLib().UseNeighborOutput() == true) {
+ const int num_neighbors = m_interface->GetNumNeighbors();
+ for (int i = 0; i < num_neighbors; i++) {
+ m_interface->Rotate();
+ cOrganism * cur_neighbor = m_interface->GetNeighbor();
+ if (cur_neighbor == NULL) continue;
+
+ other_output_list.Push( &(cur_neighbor->output_buf) );
+ }
+ }
+
+ // Do the testing of tasks performed...
+ tArray<double> res_change(resource_count.GetSize());
+ tArray<int> insts_triggered;
+ cTaskContext taskctx(input_buf, output_buf, other_input_list,
+ other_output_list, false, false, NULL, &msg);
+ phenotype.TestOutput(ctx, taskctx, send_buf, receive_buf, resource_count, res_change, insts_triggered);
+ m_interface->UpdateResources(res_change);
+
+ for (int i = 0; i < insts_triggered.GetSize(); i++) {
+ const int cur_inst = insts_triggered[i];
+ m_hardware->ProcessBonusInst(ctx, cInstruction(cur_inst) );
+ }
+
+ // RunCallbacks();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+/*! Add this message to the list of messages that this organism has received.
+*/
+bool cOrganism::ReceiveMessage(cOrgMessage& msg)
+{
+ m_received_messages.push_back(msg);
+ return true;
+}
+
+
+/*! Check to see if this organism has actually received a message that can be
+retrieved, and if so, return it.
+*/
+const cOrgMessage* cOrganism::RetrieveMessage()
+{
+ if((m_retrieve_pos+1) > m_received_messages.size()) {
+ return NULL;
+ } else {
+ return &m_received_messages.at(m_retrieve_pos++);
+ }
+}
Modified: branches/coopcomm/source/main/cOrganism.h
===================================================================
--- branches/coopcomm/source/main/cOrganism.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cOrganism.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -12,6 +12,7 @@
#define cOrganism_h
#include <fstream>
+#include <vector>
#ifndef cCPUMemory_h
#include "cCPUMemory.h"
@@ -56,6 +57,7 @@
#include "cSaleItem.h"
#endif
+
/**
* The cOrganism class controls the running and manages all the statistics
* about a creature. Effectively the chemistry acting on the genome.
@@ -74,6 +76,9 @@
class cOrganism
{
+public:
+ typedef std::vector<cOrgMessage> t_message_list; //!< Container for cOrgMessages.
+
protected:
cWorld* m_world;
cHardwareBase* m_hardware; // The actual machinary running this organism.
@@ -109,9 +114,6 @@
int lineage_label; // a lineages tag; inherited unchanged in offspring
cLineage* lineage; // A lineage descriptor... (different from label)
- tBuffer<cOrgMessage> inbox;
- tBuffer<cOrgMessage> sent;
-
class cNetSupport
{
public:
@@ -132,6 +134,13 @@
bool is_running; // Does this organism have the CPU?
+ // Coop-comm
+ t_message_list m_sent_messages; //!< List of messages that this organism has sent, in order.
+ t_message_list m_received_messages; //!< List of messages that this organism has received, in order.
+ // t_message_list m_retrieved_messages; //!< List of messages that this organism has retrieved, in order.
+ t_message_list::size_type m_retrieve_pos; //!< Index of the message that will be returned on next RetrieveMessage().
+
+
cOrganism(); // @not_implemented
cOrganism(const cOrganism&); // @not_implemented
cOrganism& operator=(const cOrganism&); // @not_implemented
@@ -165,10 +174,6 @@
void DoInput(const int value);
void DoOutput(cAvidaContext& ctx, const int value);
- // Message stuff
- void SendMessage(cOrgMessage & mess);
- bool ReceiveMessage(cOrgMessage & mess);
-
// Network Stuff
void NetGet(cAvidaContext& ctx, int& value, int& seq);
void NetSend(cAvidaContext& ctx, int value);
@@ -212,7 +217,6 @@
double GetInjectInsProb() const { return MutationRates().GetInjectInsProb(); }
double GetInjectDelProb() const { return MutationRates().GetInjectDelProb(); }
double GetInjectMutProb() const { return MutationRates().GetInjectMutProb(); }
-
bool GetTestOnDivide() const;
bool GetFailImplicit() const;
@@ -271,6 +275,15 @@
// Other Special Functions
void Fault(int fault_loc, int fault_type, cString fault_desc="");
+
+
+ // Coop-comm
+ bool SendMessage(cAvidaContext& ctx, cOrgMessage& msg); //!< Called when this organism attempts to send a message.
+ bool ReceiveMessage(cOrgMessage& msg); //!< Called when this organism has been sent a message.
+ const cOrgMessage* RetrieveMessage(); //!< Called when this organism attempts to move a received message into its CPU.
+ //! Returns the random cell ID for the cell in which this organism lives.
+ int GetRandomCellID() const { assert(m_interface); return m_interface->GetRandomCellID(); }
+ t_message_list& GetReceivedMessages() { return m_received_messages; }
};
@@ -286,4 +299,3 @@
#endif
#endif
-
Modified: branches/coopcomm/source/main/cPopulationCell.cc
===================================================================
--- branches/coopcomm/source/main/cPopulationCell.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cPopulationCell.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -7,6 +7,7 @@
* Copyright 1993-2003 California Institute of Technology.
*
*/
+#include <cstdlib>
#include "cPopulationCell.h"
@@ -17,6 +18,9 @@
using namespace std;
+cPopulationCell::t_id_map cPopulationCell::s_rand_ids;
+
+
cPopulationCell::cPopulationCell()
: m_world(NULL)
, organism(NULL)
@@ -65,6 +69,9 @@
{
m_world = world;
cell_id = in_id;
+ m_rand_id = (int)random();
+ s_rand_ids.insert(std::make_pair(m_rand_id, this));
+
if (mutation_rates == NULL)
mutation_rates = new cMutationRates(in_rates);
else
@@ -135,3 +142,14 @@
// Nothing for the moment...
return true;
}
+
+
+/*! Returns the current maximum random cell ID. If there is no current maximum,
+0 is returned.
+*/
+int cPopulationCell::GetMaxRandomCellID()
+{
+ if(s_rand_ids.size()==0) return 0;
+
+ return s_rand_ids.rbegin()->first;
+}
Modified: branches/coopcomm/source/main/cPopulationCell.h
===================================================================
--- branches/coopcomm/source/main/cPopulationCell.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cPopulationCell.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -12,6 +12,7 @@
#define cPopulationCell_h
#include <fstream>
+#include <map>
#ifndef cMutationRates_h
#include "cMutationRates.h"
@@ -30,7 +31,10 @@
class cPopulationCell
{
+public:
friend class cPopulation;
+ typedef std::map<int,cPopulationCell*> t_id_map;
+
private:
cWorld* m_world;
cOrganism* organism; // The occupent of this cell.
@@ -42,6 +46,8 @@
int cell_id; // Unique id for position of cell in population.
int organism_count; // Total number of orgs to ever inhabit this cell.
+ int m_rand_id; //!< Random identifier for this cell.
+ static t_id_map s_rand_ids; //!< Container for m_rand_id -> cell* mappings.
void InsertOrganism(cOrganism & new_org);
cOrganism* RemoveOrganism();
@@ -68,8 +74,13 @@
int GetOrganismCount() const { return organism_count; }
bool IsOccupied() const { return organism != NULL; }
-
bool OK();
+
+ //! Returns the random ID for this cell.
+ int GetRandomCellID() const { return m_rand_id; }
+ //! Returns a boolean representing whether or not the given ID belongs to a cell.
+ static int IsRandomCellID(int id) { return s_rand_ids.find(id)!=s_rand_ids.end(); }
+ static int GetMaxRandomCellID(); //! Returns the current maximum random cell ID.
};
Modified: branches/coopcomm/source/main/cPopulationInterface.cc
===================================================================
--- branches/coopcomm/source/main/cPopulationInterface.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cPopulationInterface.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -102,17 +102,6 @@
m_world->GetPopulation().Kaboom(cell, distance);
}
-bool cPopulationInterface::SendMessage(cOrgMessage & mess)
-{
- mess.SetSenderID(m_cell_id);
- mess.SetTime(m_world->GetStats().GetUpdate());
- cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
- if(cell.ConnectionList().GetFirst() == NULL)
- return false;
- mess.SetRecipientID(cell.ConnectionList().GetFirst()->GetID());
- return cell.ConnectionList().GetFirst()->GetOrganism()->ReceiveMessage(mess);
-}
-
cOrgSinkMessage* cPopulationInterface::NetReceive()
{
cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
@@ -200,3 +189,24 @@
{
return m_world->GetTestOnDivide();
}
+
+
+/*! Send a message to the faced organism, failing if this cell does not have
+neighbors or if the cell currently faced is not occupied. Set the receiver
+parameter for the message being sent.
+*/
+bool cPopulationInterface::SendMessage(cOrgMessage & msg)
+{
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
+ if((cell.ConnectionList().GetFirst() == NULL) || !cell.IsOccupied())
+ return false;
+ cOrganism* recvr = cell.ConnectionList().GetFirst()->GetOrganism();
+ msg.SetReceiver(recvr);
+ return recvr->ReceiveMessage(msg);
+}
+
+
+int cPopulationInterface::GetRandomCellID()
+{
+ return m_world->GetPopulation().GetCell(m_cell_id).GetRandomCellID();
+}
Modified: branches/coopcomm/source/main/cPopulationInterface.h
===================================================================
--- branches/coopcomm/source/main/cPopulationInterface.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cPopulationInterface.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -53,7 +53,6 @@
void UpdateResources(const tArray<double>& res_change);
void Die();
void Kaboom(int distance);
- bool SendMessage(cOrgMessage& mess);
cOrgSinkMessage* NetReceive();
bool NetRemoteValidate(cAvidaContext& ctx, cOrgSinkMessage* msg);
int ReceiveValue();
@@ -62,6 +61,9 @@
bool InjectParasite(cOrganism* parent, const cGenome& injected_code);
bool UpdateMerit(double new_merit);
bool TestOnDivide();
+
+ bool SendMessage(cOrgMessage& msg); //!< Sends a message to the organism that is currently faced.
+ int GetRandomCellID(); //!< Returns the random cell ID for the cell in which this organism lives.
};
Modified: branches/coopcomm/source/main/cTaskContext.h
===================================================================
--- branches/coopcomm/source/main/cTaskContext.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cTaskContext.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -17,12 +17,16 @@
#include "tList.h"
#endif
+#include "cOrgMessage.h"
+
+
class cTaskEntry;
class cTaskContext
{
friend class cTaskLib;
+
private:
const tBuffer<int>& input_buffer;
const tBuffer<int>& output_buffer;
@@ -34,18 +38,29 @@
int logic_id;
cTaskEntry* task_entry;
+ cOrgMessage* m_pMessage;
public:
- cTaskContext(const tBuffer<int>& inputs, const tBuffer<int>& outputs, const tList<tBuffer<int> >& other_inputs,
- const tList<tBuffer<int> >& other_outputs, bool in_net_valid, int in_net_completed,
- tBuffer<int>* in_received_messages = NULL)
- : input_buffer(inputs), output_buffer(outputs), other_input_buffers(other_inputs),
- other_output_buffers(other_outputs), net_valid(in_net_valid), net_completed(in_net_completed),
- received_messages(in_received_messages), logic_id(0), task_entry(NULL)
+ cTaskContext(const tBuffer<int>& inputs, const tBuffer<int>& outputs,
+ const tList<tBuffer<int> >& other_inputs,
+ const tList<tBuffer<int> >& other_outputs, bool in_net_valid,
+ int in_net_completed, tBuffer<int>* in_received_messages=NULL,
+ cOrgMessage* msg=NULL) :
+ input_buffer(inputs),
+ output_buffer(outputs),
+ other_input_buffers(other_inputs),
+ other_output_buffers(other_outputs),
+ net_valid(in_net_valid),
+ net_completed(in_net_completed),
+ received_messages(in_received_messages),
+ logic_id(0),
+ task_entry(NULL),
+ m_pMessage(msg)
{
}
void SetTaskEntry(cTaskEntry* in_entry) { task_entry = in_entry; }
+ cOrgMessage* GetMessage() { return m_pMessage; }
};
Modified: branches/coopcomm/source/main/cTaskLib.cc
===================================================================
--- branches/coopcomm/source/main/cTaskLib.cc 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cTaskLib.cc 2006-09-24 02:04:14 UTC (rev 976)
@@ -8,9 +8,13 @@
*
*/
+#include <algorithm>
+#include <functional>
+
#include "cTaskLib.h"
#include "cArgSchema.h"
+#include "cPopulationCell.h"
#include <stdlib.h>
extern "C" {
@@ -341,6 +345,15 @@
else if (name == "net_receive")
NewTask(name, "Successfully Received Network Message", &cTaskLib::Task_NetReceive);
+ // Coop-comm Tasks
+ if(name == "max-id")
+ NewTask(name, "Rewards sending max(received data, organism ID) iff data is a cell ID.", &cTaskLib::Task_MaxID);
+ else if(name == "send-id")
+ NewTask(name, "Reward the sending of an ID as the data field of a message.", &cTaskLib::Task_SendID);
+ else if(name == "send-non-id")
+ NewTask(name, "Reward sending a message that does NOT have an ID as the data field.", &cTaskLib::Task_SendNonID);
+ else if(name == "send-self")
+ NewTask(name, "Reward the sending of the sender's ID.", &cTaskLib::Task_SendSelf);
// Make sure we have actually found a task
@@ -1859,3 +1872,80 @@
if (ctx->net_valid) return 1.0;
return 0.0;
}
+
+
+/*! This task rewards an organism for sending a message where the data field of
+the message contains the maximum ID that this organism is capable of knowing.
+Specifically, this task rewards the max(max(received msgs), self.ID).
+
+If the sent message's data field is not an ID, or the receive-message buffer is
+empty, no reward is given.
+*/
+double cTaskLib::Task_MaxID(cTaskContext* ctx) const
+{
+ cOrgMessage* msg = ctx->GetMessage();
+ if(msg == NULL) return 0.0;
+
+ cOrganism::t_message_list& received_msgs = msg->GetSender()->GetReceivedMessages();
+ if(!cPopulationCell::IsRandomCellID(msg->GetData()) || received_msgs.empty())
+ return 0.0;
+
+ // Find the maximum ID in the receive buffer for the sender. Uses the message_less
+ // comparator (above).
+ cOrganism::t_message_list::iterator i=std::max_element(received_msgs.begin(),
+ received_msgs.end(),
+ cOrgMessage_Less());
+
+ // Check the sent data against max(received message, self.ID).
+ if(msg->GetData() == std::max(i->GetData(), msg->GetSender()->GetRandomCellID()))
+ return 1.0;
+
+ return 0.0;
+}
+
+
+/*! This task rewards an organism for sending a message where the data field
+of the message contains any organism's ID (including the sender's). There are
+no restrictions on /how/ this ID was determined.
+*/
+double cTaskLib::Task_SendID(cTaskContext* ctx) const
+{
+ cOrgMessage* msg = ctx->GetMessage();
+ if(msg==NULL) return 0.0;
+
+ if(cPopulationCell::IsRandomCellID(msg->GetData()))
+ return 1.0;
+
+ return 0.0;
+}
+
+
+/*! This task 'rewards' an organism for sending a message where the data field of
+the message is not an ID. This task is usually configured as a penalty, e.g.,
+"process:value=.25:type=mult" in the environment file.
+*/
+double cTaskLib::Task_SendNonID(cTaskContext* ctx) const
+{
+ cOrgMessage* msg = ctx->GetMessage();
+ if(msg == NULL) return 0.0;
+
+ if(!cPopulationCell::IsRandomCellID(msg->GetData()))
+ return 1.0;
+
+ return 0.0;
+}
+
+
+/*! This task rewards an organism for sending a message where the data field
+of the message contains the sender's ID.
+*/
+double cTaskLib::Task_SendSelf(cTaskContext* ctx) const
+{
+ cOrgMessage* msg = ctx->GetMessage();
+ if(msg==NULL) return 0.0;
+
+ if(msg->GetData() == msg->GetSender()->GetRandomCellID())
+ return 1.0;
+
+ return 0.0;
+}
Modified: branches/coopcomm/source/main/cTaskLib.h
===================================================================
--- branches/coopcomm/source/main/cTaskLib.h 2006-09-24 01:38:17 UTC (rev 975)
+++ branches/coopcomm/source/main/cTaskLib.h 2006-09-24 02:04:14 UTC (rev 976)
@@ -229,6 +229,12 @@
// Network Tasks
double Task_NetSend(cTaskContext* ctx) const;
double Task_NetReceive(cTaskContext* ctx) const;
+
+ // Coop-comm Tasks
+ double Task_MaxID(cTaskContext* ctx) const; //!< Rewards an organism for sending its max known ID.
+ double Task_SendID(cTaskContext* ctx) const; //!< Rewards an organism for sending an ID.
+ double Task_SendNonID(cTaskContext* ctx) const; //!< Rewards an organism for not sending an ID.
+ double Task_SendSelf(cTaskContext* ctx) const; //!< Rewards an organism for sending its ID.
};
More information about the Avida-cvs
mailing list