[Avida-SVN] r1487 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Apr 19 03:08:58 PDT 2007
Author: hjg
Date: 2007-04-19 06:08:57 -0400 (Thu, 19 Apr 2007)
New Revision: 1487
Modified:
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cTaskContext.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/main/cTaskLib.h
Log:
- constant # of states
- task - 5-tran reach 5, then plateau
- AddTransT - reset indices
- exponential reward for multiple trans
-This line, and those below, will be ignored--
M source/main/cTaskLib.h
M source/main/cTaskContext.h
M source/main/cTaskLib.cc
M source/main/cOrganism.cc
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-04-19 07:31:53 UTC (rev 1486)
+++ branches/uml/source/main/cOrganism.cc 2007-04-19 10:08:57 UTC (rev 1487)
@@ -124,13 +124,24 @@
actions.push_back("ac");
actions.push_back("ad");
+ // initialize w/ 10 states
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+ states.push_back(states.size());
+
trigger_index = 0;
action_index = 0;
guard_index = 0;
trans_label_index = 0;
orig_state_index = 0;
- dest_state_index = 0;
-// total_states = 0;
+ dest_state_index = 9;
}
@@ -820,6 +831,13 @@
}
transitions.push_back(t);
+
+ // reset all indices
+ orig_state_index = 0;
+ dest_state_index = 0;
+ trigger_index = 0;
+ action_index = 0;
+ guard_index = 0;
return true;
Modified: branches/uml/source/main/cTaskContext.h
===================================================================
--- branches/uml/source/main/cTaskContext.h 2007-04-19 07:31:53 UTC (rev 1486)
+++ branches/uml/source/main/cTaskContext.h 2007-04-19 10:08:57 UTC (rev 1487)
@@ -32,7 +32,7 @@
int net_completed;
tBuffer<int>* received_messages;
int logic_id;
- int task_failed;
+ int task_success_complete;
cTaskEntry* task_entry;
cOrganism* organism;
@@ -44,7 +44,7 @@
tBuffer<int>* in_received_messages = NULL, cOrganism* in_org = 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), organism(in_org), logic_id(0), task_entry(NULL), task_failed(1)
+ received_messages(in_received_messages), organism(in_org), logic_id(0), task_entry(NULL), task_success_complete(0)
{
}
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-04-19 07:31:53 UTC (rev 1486)
+++ branches/uml/source/main/cTaskLib.cc 2007-04-19 10:08:57 UTC (rev 1487)
@@ -349,6 +349,8 @@
NewTask(name, "Successfully ran hydra", &cTaskLib::Task_Hydra);
else if (name == "spin1") //
NewTask(name, "Successfully ran Spin", &cTaskLib::Task_SpinN1);
+ else if (name == "mult_trans") //
+ NewTask(name, "Successfully completed multiple transitions", &cTaskLib::Task_MultTrans);
// Make sure we have actually found a task
if (task_array.GetSize() == start_size) {
@@ -1858,10 +1860,11 @@
{
double bonus = 0.0;
if (ctx->organism->findTrans(0,1, "tagaaa")) {
+ ctx->task_success_complete = 1;
bonus = 1.0;
}
- ctx->task_failed = ctx->task_failed && bonus;
+// ctx->task_success_complete = 0;
return bonus;
}
@@ -1869,10 +1872,10 @@
{
double bonus = 0.0;
if (ctx->organism->findTrans(1,2, "tagdab")){
+ ctx->task_success_complete += 1;
bonus = 1.0;
}
- ctx->task_failed = ctx->task_failed && bonus;
return bonus;
}
@@ -1882,9 +1885,9 @@
double bonus = 0.0;
if (ctx->organism->findTrans(2,3, "tcgbac")){
bonus = 1.0;
+ ctx->task_success_complete += 1;
}
- ctx->task_failed = ctx->task_failed && bonus;
return bonus;
}
@@ -1893,10 +1896,10 @@
{
double bonus = 0.0;
if (ctx->organism->findTrans(3,4, "tbgcad")){
+ ctx->task_success_complete += 1;
bonus = 1.0;
}
- ctx->task_failed = ctx->task_failed && bonus;
return bonus;
}
@@ -1905,10 +1908,10 @@
{
double bonus = 0.0;
if (ctx->organism->findTrans(4,0, "tdgaac")){
+ ctx->task_success_complete += 1;
bonus = 1.0;
}
- ctx->task_failed = ctx->task_failed && bonus;
return bonus;
}
@@ -1932,21 +1935,22 @@
if (nt <= 5 ) {
return (nt/5);
} else{
- return 0.0;
+ return 1;
}
}
-
+// broken - 4/11
double cTaskLib::Task_Hydra(cTaskContext* ctx) const
{
cOrganism* organism = ctx->organism;
// Check for task success...
- if (ctx->task_failed == 0) {
+/* if (ctx->task_failed == 0) {
return 0;
}
-
+
+*/
m_world->GetStats().HydraAttempt();
double bonus = 0.0;
@@ -2011,7 +2015,7 @@
assert(done==subavida);
// if there are no errors, return 0 from hydraulic. otherwise, return non-zero.
- if(status != 0) {
+/* if(status != 0) {
ctx->task_failed = 0;
return 0.0;
} else {
@@ -2019,8 +2023,10 @@
m_world->GetStats().HydraPassed();
return 1.0;
}
+ */
}
+
double cTaskLib::SpinCoprocess(cTaskContext* ctx, const std::string& neverclaimFile) const {
cOrganism* organism = ctx->organism;
m_world->GetStats().SpinAttempt();
@@ -2044,10 +2050,12 @@
}
double cTaskLib::Task_SpinN1(cTaskContext* ctx) const {
- if (ctx->task_failed) {
+ //if (ctx->task_failed) {
return SpinCoprocess(ctx, "N1");
- }
+ //}
return 0.0;
}
-
+double cTaskLib::Task_MultTrans(cTaskContext* ctx) const {
+ return (2^ctx->task_success_complete);
+}
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-04-19 07:31:53 UTC (rev 1486)
+++ branches/uml/source/main/cTaskLib.h 2007-04-19 10:08:57 UTC (rev 1487)
@@ -241,6 +241,7 @@
double Task_Hydra(cTaskContext* ctx) const;
double SpinCoprocess(cTaskContext* ctx, const std::string& neverclaimFile) const;
double Task_SpinN1(cTaskContext* ctx) const;
+ double Task_MultTrans(cTaskContext* ctx) const;
};
More information about the Avida-cvs
mailing list