[Avida-SVN] r1119 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Dec 7 20:04:50 PST 2006
Author: hjg
Date: 2006-12-07 23:04:49 -0500 (Thu, 07 Dec 2006)
New Revision: 1119
Modified:
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cOrganism.h
branches/uml/source/main/cTaskLib.cc
Log:
Added 5-state GSM example and tasks for multiple-logic-hops.
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2006-12-07 21:32:51 UTC (rev 1118)
+++ branches/uml/source/main/cOrganism.cc 2006-12-08 04:04:49 UTC (rev 1119)
@@ -663,6 +663,10 @@
//cout << "added state named " << orig << endl;
uml_state_diagram[u].state_label = orig;
pos1->second = u;
+
+ // add to the map between position and label....
+ PosToStateLabel[states.size()] = orig;
+
} else {
u = pos1->second;
//cout << "found state named " << orig << endl;
@@ -675,6 +679,11 @@
//cout << "added state named " << dest << endl;
uml_state_diagram[v].state_label = dest;
pos2->second = v;
+
+ // add to map betweek positions and label.....
+ PosToStateLabel[states.size()] = orig;
+
+
} else {
v = pos2->second;
//cout << "found state named " << dest << endl;
@@ -1088,7 +1097,16 @@
cOrganism::State& cOrganism::getStateInPosition (int num)
{
+ /*std::pair<vertex_iterator, vertex_iterator>
+vertices(const adjacency_list& g)*/
+// Graph::vertex_iterator vi, vi_end;
+// tie(vi,vi_end) = vertices(uml_state_diagram);
+// vi+=num;
+ //graph_traits<Graph>::vertex_descriptor b = *vi;
+// return *vi;
+
int count = 0;
+ // This code uses a value ordering on the states (lowest number = position 0)
nsm_it i;
for (i=states.begin(); i!=states.end(); ++i)
{
@@ -1098,6 +1116,14 @@
count++;
}
return i->second;
+
+
+/*
+ int x = PosToStateLabel[num];
+ return (states[x]);
+*/
+
+
}
cOrganism::Graph& cOrganism::GetGraph()
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2006-12-07 21:32:51 UTC (rev 1118)
+++ branches/uml/source/main/cOrganism.h 2006-12-08 04:04:49 UTC (rev 1119)
@@ -114,6 +114,7 @@
typedef graph_traits<Graph>::out_edge_iterator oei;
+
protected:
cWorld* m_world;
@@ -161,6 +162,9 @@
std::string hil_begin;
std::string hil;
std::string hil_end;
+ std::map<int, int> PosToStateLabel; // a map that relates the number in which the state was inserted
+ // to the label the organism assigns it.
+
class cNetSupport
{
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2006-12-07 21:32:51 UTC (rev 1118)
+++ branches/uml/source/main/cTaskLib.cc 2006-12-08 04:04:49 UTC (rev 1119)
@@ -2116,6 +2116,7 @@
{
double bonus = 0.0;
+ // good for both bs and gsm
if (ctx->organism->findTrans(0, 1, 0)) {
bonus = 1.0;
}
@@ -2126,17 +2127,27 @@
{
double bonus = 0.0;
- if (ctx->organism->findTrans(1, 2, 1)) {
+ // good for both bs and gsm
+ // if (ctx->organism->findTrans(1, 2, 1)) {
+
+ // testing the creation of multiple trans to get reward concept
+ if ((ctx->organism->findTrans(1, 2, 1)) && (ctx->organism->findTrans(2, 3, 2))) {
+
bonus = 1.0;
}
return bonus;
}
+
double cTaskLib::Task_Transition2(cTaskContext* ctx) const
{
double bonus = 0.0;
- if (ctx->organism->findTrans(2, 1, 2)) {
+ // brightness sensor
+ // if (ctx->organism->findTrans(2, 1, 2)) {
+ // gsm:
+ if (ctx->organism->findTrans(2, 3, 2)) {
+
bonus = 1.0;
}
return bonus;
@@ -2146,7 +2157,11 @@
{
double bonus = 0.0;
- if (ctx->organism->findTrans(2, 1, 3)) {
+ // brightness sensor
+ // if (ctx->organism->findTrans(2, 1, 3)) {
+ // gsm:
+ if (ctx->organism->findTrans(3, 4, 3)) {
+
bonus = 1.0;
}
return bonus;
@@ -2156,7 +2171,10 @@
{
double bonus = 0.0;
- if (ctx->organism->findTrans(1, 3, 4)) {
+ // brightness sensor
+// if (ctx->organism->findTrans(1, 3, 4)) {
+ if (ctx->organism->findTrans(4, 1, 4)) {
+
bonus = 1.0;
}
return bonus;
More information about the Avida-cvs
mailing list