[Avida-SVN] r1499 - in development: source/cpu source/main support/config support/scripts
barrick at myxo.css.msu.edu
barrick at myxo.css.msu.edu
Tue Apr 24 00:20:04 PDT 2007
Author: barrick
Date: 2007-04-24 03:20:04 -0400 (Tue, 24 Apr 2007)
New Revision: 1499
Modified:
development/source/cpu/cHardwareCPU.cc
development/source/cpu/cHardwareCPU.h
development/source/main/cAvidaConfig.h
development/source/main/cOrganism.cc
development/source/main/cPhenotype.cc
development/source/main/cPhenotype.h
development/support/config/avida.cfg
development/support/scripts/trace_movie.pl
Log:
Various minor Promoter Model related tweaks..
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/cpu/cHardwareCPU.cc 2007-04-24 07:20:04 UTC (rev 1499)
@@ -196,9 +196,9 @@
tInstLibEntry<tMethod>("buy", &cHardwareCPU::Inst_Buy),
tInstLibEntry<tMethod>("send", &cHardwareCPU::Inst_Send),
tInstLibEntry<tMethod>("receive", &cHardwareCPU::Inst_Receive),
- tInstLibEntry<tMethod>("sense", &cHardwareCPU::Inst_SenseLog2),
- tInstLibEntry<tMethod>("sense-unit", &cHardwareCPU::Inst_SenseUnit),
- tInstLibEntry<tMethod>("sense-m100", &cHardwareCPU::Inst_SenseMult100),
+ tInstLibEntry<tMethod>("sense", &cHardwareCPU::Inst_SenseLog2), // If you add more sense instructions
+ tInstLibEntry<tMethod>("sense-unit", &cHardwareCPU::Inst_SenseUnit), // and want to keep stats, also add
+ tInstLibEntry<tMethod>("sense-m100", &cHardwareCPU::Inst_SenseMult100), // the names to cStats::cStats() @JEB
tInstLibEntry<tMethod>("donate-rnd", &cHardwareCPU::Inst_DonateRandom),
tInstLibEntry<tMethod>("donate-kin", &cHardwareCPU::Inst_DonateKin),
@@ -331,6 +331,8 @@
tInstLibEntry<tMethod>("down-reg-*", &cHardwareCPU::Inst_DownRegulatePromoter),
tInstLibEntry<tMethod>("up-reg", &cHardwareCPU::Inst_UpRegulatePromoterNop),
tInstLibEntry<tMethod>("down-reg", &cHardwareCPU::Inst_DownRegulatePromoterNop),
+ tInstLibEntry<tMethod>("up-reg>0", &cHardwareCPU::Inst_UpRegulatePromoterNopIfGT0),
+ tInstLibEntry<tMethod>("down-reg>0", &cHardwareCPU::Inst_DownRegulatePromoterNopIfGT0),
tInstLibEntry<tMethod>("terminate", &cHardwareCPU::Inst_Terminate),
tInstLibEntry<tMethod>("promoter", &cHardwareCPU::Inst_Promoter),
tInstLibEntry<tMethod>("decay-reg", &cHardwareCPU::Inst_DecayRegulation),
@@ -459,10 +461,10 @@
cPhenotype & phenotype = organism->GetPhenotype();
- //First instruction - check whether we should be starting at a promoter.
- if (phenotype.GetTimeUsed() == 0)
+ if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1)
{
- if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1) Inst_Terminate(m_world->GetDefaultContext());
+ //First instruction - check whether we should be starting at a promoter.
+ if (phenotype.GetTimeUsed() == 0) Inst_Terminate(m_world->GetDefaultContext());
}
phenotype.IncTimeUsed();
@@ -479,14 +481,6 @@
// Setup the hardware for the next instruction to be executed.
ThreadNext();
- // In the promoter model, there may be a chance of termination
- // that causes execution to start at a new instruction
- const double processivity = m_world->GetConfig().PROMOTER_PROCESSIVITY.Get();
- if (processivity < 1)
- {
- if ( ctx.GetRandom().P(1-processivity) ) Inst_Terminate(ctx);
- }
-
m_advance_ip = true;
IP().Adjust();
@@ -499,6 +493,9 @@
// Print the status of this CPU at each step...
if (m_tracer != NULL) m_tracer->TraceHardware(*this);
+ // For tracing when termination occurs...
+ if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1) organism->GetPhenotype().SetTerminated(false);
+
// Find the instruction to be executed
const cInstruction& cur_inst = IP().GetInst();
@@ -526,8 +523,26 @@
// Pay the additional death_cost of the instruction now
phenotype.IncTimeUsed(addl_time_cost);
+
+ // In the promoter model, there may be a chance of termination
+ // that causes execution to start at a new instruction (per instruction executed)
+ if ( m_world->GetConfig().PROMOTERS_ENABLED.Get() )
+ {
+ const double processivity = m_world->GetConfig().PROMOTER_PROCESSIVITY_INST.Get();
+ if ( ctx.GetRandom().P(1-processivity) ) Inst_Terminate(ctx);
+ }
} // if exec
+ // In the promoter model, there may be a chance of termination
+ // that causes execution to start at a new instruction (per cpu cycle executed)
+ // @JEB - since processivities usually v. close to 1 it doesn't
+ // improve speed much to combine with "per instruction" block
+ if ( m_world->GetConfig().PROMOTERS_ENABLED.Get() )
+ {
+ const double processivity = m_world->GetConfig().PROMOTER_PROCESSIVITY.Get();
+ if ( ctx.GetRandom().P(1-processivity) ) Inst_Terminate(ctx);
+ }
+
} // Previous was executed once for each thread...
// Kill creatures who have reached their max num of instructions executed
@@ -2954,16 +2969,16 @@
// Otherwise sum all valid resources that it might refer to
// (this will only be ONE if the label was of the maximum length).
int resource_result = 0;
+ double dresource_result = 0;
for (int i = start_index; i <= end_index; i++)
{
// if it's a valid resource
if (i < res_count.GetSize())
{
- if (conversion_method == 0) // Log2
+ if (conversion_method == 0) // Log
{
- // (alternately you could assign min_int for zero resources, but
- // that would cause wierdness when adding sense values together)
- if (res_count[i] > 0) resource_result += (int)(log(res_count[i])/log(base));
+ // for log, add together and then take log
+ dresource_result += (double) res_count[i];
}
else if (conversion_method == 1) // Addition of multiplied resource amount
{
@@ -2973,6 +2988,15 @@
}
}
}
+
+ // Take the log after adding resource amounts together!
+ // Otherwise
+ if (conversion_method == 0) // Log2
+ {
+ // You really shouldn't be using the log method if you can get to zero resources
+ assert(dresource_result != 0);
+ resource_result = (int)(log(dresource_result)/log(base));
+ }
//Dump this value into an arbitrary register: BX
GetRegister(reg_to_set) = resource_result;
@@ -3681,22 +3705,14 @@
}
search_head++;
}
-
- // Debugging code
- /*
- tArray<double> w = organism->GetPhenotype().GetPromoterWeights();
- cerr << "Promoter Weights..." << endl;
- for (int i = 0; i < w.GetSize(); i++) {
- cerr << i << " " << w[i] << endl;
- }
- */
}
// Adjust the weight at promoter positions that match the downstream nop pattern
void cHardwareCPU::RegulatePromoterNop(cAvidaContext& ctx, bool up)
{
static cInstruction promoter_inst = GetInstSet().GetInst(cStringUtil::Stringf("promoter"));
-
+ const int max_distance_to_promoter = 10;
+
// Look for the label directly (no complement)
// Save the position before the label, so we don't count it as a regulatory site
int start_pos = IP().GetPosition();
@@ -3723,12 +3739,11 @@
if (i == GetLabel().GetSize())
{
cHeadCPU change_head(match_head);
- for (int j=0; j < 5; j++)
+ for (int j=0; j < max_distance_to_promoter; j++)
{
change_head++;
if (change_head.GetInst() == promoter_inst) {
-
if (change_head.GetPosition() < organism->GetPhenotype().GetCurPromoterWeights().GetSize())
{
organism->GetPhenotype().RegulatePromoter(change_head.GetPosition(), up);
@@ -3736,8 +3751,8 @@
/*
else
{
- // I can't seem to get resizing promoter arrays on allocate to work
- // promoter weights still get unsynched from the genome size somewhere.
+ // I can't seem to get resizing promoter arrays on memory allocation to work.
+ // Promoter weights still get unsynched from the genome size somewhere. @JEB
cout << change_head.GetPosition() << endl;
cout << organism->GetPhenotype().GetCurPromoterWeights().GetSize() << endl;
cout << GetMemory().GetSize() << endl;
@@ -3748,17 +3763,15 @@
}
}
} while ( start_pos != search_head.GetPosition() );
-
- // Debugging code
- /*
- tArray<double> w = organism->GetPhenotype().GetPromoterWeights();
- cerr << "Promoter Weights..." << endl;
- for (int i = 0; i < w.GetSize(); i++) {
- cerr << i << " " << w[i] << endl;
- }
- */
}
+// Adjust the weight at promoter positions that match the downstream nop pattern
+void cHardwareCPU::RegulatePromoterNopIfGT0(cAvidaContext& ctx, bool up)
+{
+ // whether we do regulation is related to BX
+ double reg = (double) GetRegister(REG_BX);
+ if (reg > 0) RegulatePromoterNop(ctx, up);
+}
// Move execution to a new promoter
bool cHardwareCPU::Inst_Terminate(cAvidaContext& ctx)
@@ -3772,6 +3785,7 @@
// We want to execute the promoter that we land on.
m_advance_ip = false;
+ organism->GetPhenotype().SetTerminated(true);
//organism->ClearInput();
Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/cpu/cHardwareCPU.h 2007-04-24 07:20:04 UTC (rev 1499)
@@ -523,9 +523,10 @@
bool Inst_DownRegulatePromoter(cAvidaContext& ctx) { RegulatePromoter(ctx, false); return true; }
void RegulatePromoterNop(cAvidaContext& ctx, bool up);
bool Inst_UpRegulatePromoterNop(cAvidaContext& ctx) { RegulatePromoterNop(ctx, true); return true; }
- bool Inst_DownRegulatePromoterNop(cAvidaContext& ctx) { RegulatePromoterNop(ctx, false); return true; }
- bool Inst_UpRegulatePromoterNopDecay(cAvidaContext& ctx);
- bool Inst_DownRegulatePromoterNopDecay(cAvidaContext& ctx);
+ bool Inst_DownRegulatePromoterNop(cAvidaContext& ctx) { RegulatePromoterNop(ctx, false); return true; }
+ void RegulatePromoterNopIfGT0(cAvidaContext& ctx, bool up);
+ bool Inst_UpRegulatePromoterNopIfGT0(cAvidaContext& ctx) { RegulatePromoterNopIfGT0(ctx, true); return true; }
+ bool Inst_DownRegulatePromoterNopIfGT0(cAvidaContext& ctx) { RegulatePromoterNopIfGT0(ctx, false); return true; }
bool Inst_Terminate(cAvidaContext& ctx);
bool Inst_Promoter(cAvidaContext& ctx);
bool Inst_DecayRegulation(cAvidaContext& ctx);
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/main/cAvidaConfig.h 2007-04-24 07:20:04 UTC (rev 1499)
@@ -291,10 +291,11 @@
CONFIG_ADD_GROUP(PROMOTER_GROUP, "Promoters");
CONFIG_ADD_VAR(PROMOTERS_ENABLED, int, 0, "Use the promoter/terminator execution scheme.\nCertain instructions must also be included.");
- CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY, double, 1.0, "Chance of not terminating before executing each instruction.");
+ CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY, double, 1.0, "Chance of not terminating after each cpu cycle.");
+ CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY_INST, double, 1.0, "Chance of not terminating after each instruction.");
CONFIG_ADD_VAR(PROMOTER_BG_STRENGTH, double, 0, "Probability of positions that are not promoter\ninstructions initiating execution (promoters are 1).");
CONFIG_ADD_VAR(REGULATION_STRENGTH, double, 1, "Strength added or subtracted to a promoter by regulation.");
- CONFIG_ADD_VAR(REGULATION_DECAY_FRAC, double, 0.1, "Fraction of regulation that decays away. \n(Max regulation = REGULATION_STRENGTH / REGULATION_DECAY_FRAC)");
+ CONFIG_ADD_VAR(REGULATION_DECAY_FRAC, double, 0.1, "Fraction of regulation that decays away. \nMax regulation = 2^(REGULATION_STRENGTH/REGULATION_DECAY_FRAC)");
CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");
CONFIG_ADD_VAR(TRACK_MAIN_LINEAGE, int, 1, "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/main/cOrganism.cc 2007-04-24 07:20:04 UTC (rev 1499)
@@ -368,7 +368,6 @@
m_output_buf.Add(value);
tArray<double> res_change(resource_count.GetSize());
tArray<int> insts_triggered;
- bool clear_input;
cTaskContext taskctx(m_interface, m_input_buf, m_output_buf, other_input_list, other_output_list, false, completed);
m_phenotype.TestOutput(ctx, taskctx, resource_count, res_change, insts_triggered);
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/main/cPhenotype.cc 2007-04-24 07:20:04 UTC (rev 1499)
@@ -55,6 +55,7 @@
, last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
, last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
, last_sense_count(m_world->GetStats().GetSenseSize())
+ , promoter_last_inst_terminated(false)
{
}
@@ -813,6 +814,15 @@
if (cur_promoter_weights[i] != m_world->GetConfig().PROMOTER_BG_STRENGTH.Get()) fp << i << " (" << cur_promoter_weights[i] << ") ";
}
fp << endl;
+
+ if (promoter_last_inst_terminated)
+ {
+ fp << "Terminated!" << endl;
+ }
+ else
+ {
+ fp << "No termination..." << endl;
+ }
}
}
@@ -884,8 +894,8 @@
for ( int i = (clear ? 0 : old_size); i<_genome.GetSize(); i++)
{
base_promoter_weights[i] = 1;
- promoter_repression[i] = 1;
- promoter_activation[i] = 1;
+ promoter_repression[i] = 0;
+ promoter_activation[i] = 0;
// Now change the weights at instructions that are not promoters if called for
if ( _genome[i] != promoter_inst)
@@ -902,7 +912,8 @@
{
promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
- cur_promoter_weights[i] = base_promoter_weights[i] * promoter_activation[i] / promoter_repression[i];
+ cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2)) / exp((1+promoter_repression[i])*log(2));
+
}
}
@@ -912,14 +923,14 @@
assert ( (promoter_activation.GetSize() > 0) && (promoter_activation.GetSize() > 0) );
if (up) {
+ promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
promoter_activation[i] += m_world->GetConfig().REGULATION_STRENGTH.Get();
- promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
}
else {
+ promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
promoter_repression[i] += m_world->GetConfig().REGULATION_STRENGTH.Get();
- promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
}
- cur_promoter_weights[i] = base_promoter_weights[i] * promoter_activation[i] / promoter_repression[i];
+ cur_promoter_weights[i] = base_promoter_weights[i] * exp((1+promoter_activation[i])*log(2)) / exp((1+promoter_repression[i])*log(2));
}
Modified: development/source/main/cPhenotype.h
===================================================================
--- development/source/main/cPhenotype.h 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/source/main/cPhenotype.h 2007-04-24 07:20:04 UTC (rev 1499)
@@ -117,6 +117,7 @@
tArray<double> cur_promoter_weights; // Current of starting execution from each position, adjusted for regulation; @JEB
tArray<double> promoter_activation; // Amount of positive regulation in play at each site; @JEB
tArray<double> promoter_repression; // Amount of negative regulation in play at each site; @JEB
+ bool promoter_last_inst_terminated; // Did terminatin occur when executing the last instruction
tHashTable<void*, cTaskState*> m_task_states;
@@ -326,6 +327,7 @@
void SetupPromoterWeights(const cGenome & _genome, const bool clear = false);
void DecayAllPromoterRegulation();
void RegulatePromoter(const int i, const bool up );
+ void SetTerminated(bool _in) { promoter_last_inst_terminated = _in; }
void IncAge() { assert(initialized == true); age++; }
void IncCPUCyclesUsed() { assert(initialized == true); cpu_cycles_used++; }
Modified: development/support/config/avida.cfg
===================================================================
--- development/support/config/avida.cfg 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/support/config/avida.cfg 2007-04-24 07:20:04 UTC (rev 1499)
@@ -142,10 +142,16 @@
# 3 = Merit prop. to full size
# 4 = Merit prop. to min of executed or copied size
# 5 = Merit prop. to sqrt of the minimum size
+ # 6 = Merit prop. to num times MERIT_BONUS_INST is in genome.
BASE_CONST_MERIT 100 # Base merit when BASE_MERIT_METHOD set to 0
DEFAULT_BONUS 1.0 # Initial bonus before any tasks
MERIT_DEFAULT_BONUS 0 # Scale the merit of an offspring by the default bonus
# rather than the accumulated bonus of the parent?
+MERIT_BONUS_INST 0 # in BASE_MERIT_METHOD 6, this sets which instruction counts (-1=none, 0= 1st in INST_SET.)
+MERIT_BONUS_EFFECT 0 # in BASE_MERIT_METHOD 6, this sets how much merit is earned per INST (-1=penalty, 0= no effect.)
+FITNESS_VALLEY 0 # in BASE_MERIT_METHOD 6, this creates valleys from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP (0= off, 1=on)
+FITNESS_VALLEY_START 0 # if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)
+FITNESS_VALLEY_STOP 0 # if FITNESS_VALLEY =1, orgs with num_key_instructions from FITNESS_VALLEY_START to FITNESS_VALLEY_STOP get fitness 1 (lowest)
MAX_CPU_THREADS 1 # Number of Threads a CPU can spawn
THREAD_SLICING_METHOD 0 # Formula for and organism's thread slicing
# (num_threads-1) * THREAD_SLICING_METHOD + 1
@@ -160,14 +166,15 @@
### PROMOTER_GROUP ###
# Promoters
-PROMOTERS_ENABLED 0 # Use the promoter/terminator execution scheme.
- # Certain instructions must also be included.
-PROMOTER_PROCESSIVITY 1.0 # Chance of not terminating before executing each instruction.
-PROMOTER_BG_STRENGTH 0 # Probability of positions that are not promoter
- # instructions initiating execution (promoters are 1).
-REGULATION_STRENGTH 1 # Strength added or subtracted to a promoter by regulation.
-REGULATION_DECAY_FRAC 0.1 # Fraction of regulation that decays away.
- # (Max regulation = REGULATION_STRENGTH / REGULATION_DECAY_FRAC)
+PROMOTERS_ENABLED 0 # Use the promoter/terminator execution scheme.
+ # Certain instructions must also be included.
+PROMOTER_PROCESSIVITY 1.0 # Chance of not terminating after each cpu cycle.
+PROMOTER_PROCESSIVITY_INST 1.0 # Chance of not terminating after each instruction.
+PROMOTER_BG_STRENGTH 0 # Probability of positions that are not promoter
+ # instructions initiating execution (promoters are 1).
+REGULATION_STRENGTH 1 # Strength added or subtracted to a promoter by regulation.
+REGULATION_DECAY_FRAC 0.1 # Fraction of regulation that decays away.
+ # Max regulation = 2^(REGULATION_STRENGTH/REGULATION_DECAY_FRAC)
### GENEOLOGY_GROUP ###
# Geneology
Modified: development/support/scripts/trace_movie.pl
===================================================================
--- development/support/scripts/trace_movie.pl 2007-04-23 13:34:27 UTC (rev 1498)
+++ development/support/scripts/trace_movie.pl 2007-04-24 07:20:04 UTC (rev 1499)
@@ -66,7 +66,7 @@
use Pod::Usage;
my ($help, $man);
my $frame_limit = 1000;
-my ($input, $output, $trace, $movie, $collapse_frames);
+my ($input, $output, $trace, $movie, $collapse_frames, $gray_unvisited_instructions);
#pod2usage(1) if (scalar @ARGV == 0);
GetOptions(
'help|?' => \$help, 'man' => \$man,
@@ -76,6 +76,7 @@
'movie|m' => \$movie,
'frame-limit|f=s' => \$frame_limit,
'collapse|c' => \$collapse_frames,
+ 'gray|g' => \$gray_unvisited_instructions,
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
@@ -162,8 +163,21 @@
#print "$original_line\n" if (scalar @{$t->{tasks}} != 9);
+ #optional lines are inserted here
+
#Next line is blank
$on_line = <TRACE>;
+ chomp $on_line;
+ while ($on_line)
+ {
+ if ($on_line =~ m/Terminated!/)
+ {
+ $t->{terminated} = 1;
+ }
+
+ $on_line = <TRACE>;
+ chomp $on_line;
+ }
#Next line is Input (env)
#Next line is Input (buf)
@@ -184,7 +198,7 @@
}
#print Dumper($t);
- #Check to see if the last fram added was at the same location
+ #Check to see if the last frame added was at the same location
if ($collapse_frames && $trace[$#trace])
{
#print $trace[$#trace]->{'inst'} . " " . $t->{'inst'} . "\n";
@@ -311,6 +325,8 @@
'catch' => $max_label_size,
'sense-m100' => $max_label_size,
'sense-unit' => $max_label_size,
+ 'up-reg' => $max_label_size,
+ 'down-reg' => $max_label_size,
};
our @execution_flare_colors = (
@@ -340,14 +356,15 @@
#print Dumper($colors);
+#Draw a connecting line, vertically centered
+$img->line($inst_space_x,$inst_y + $inst_size_y / 2 ,(scalar @inst - 1) * ($inst_size_x + $inst_space_x), $inst_y + $inst_size_y / 2,$colors->{gray});
+
#Draw grayed out instructions for each box
for (my $i=0; $i< scalar @inst; $i++)
{
- draw_instruction($i, $colors->{gray});
+ draw_instruction( $i, ($gray_unvisited_instructions ? $colors->{gray} : undef) );
}
-#Draw a connecting line, vertically centered
-$img->line($inst_space_x,$inst_y + $inst_size_y / 2 ,(scalar @inst - 1) * ($inst_size_x + $inst_space_x), $inst_y + $inst_size_y / 2,$colors->{gray});
#Draw ALL nops in default colors
#foreach (my $i=0; $i < scalar @inst; $i++)
@@ -359,13 +376,15 @@
$arc_height = $arc_height_initial;
our @arc_memory;
-
my $frame;
#Now draw arrows showing execution
foreach (my $i=0; $i < scalar @trace; $i++)
{
- #Now draw over instructions that were used in their default colors
- draw_instruction($trace[$i]->{inst});
+ #Now draw over instructions that were used in their real colors, if gray background
+ if ($gray_unvisited_instructions)
+ {
+ draw_instruction($trace[$i]->{inst});
+ }
#Include nops as long as we find them and are within the limits of what the inst uses
my @nop_list;
@@ -384,10 +403,13 @@
$frame++;
die "Exceeded frame limit (-f)." if ($movie && ($frame > $frame_limit));
- if ($i!=0 and $trace[$i]->{inst} != $trace[$i-1]->{inst})
+ if ($trace[$i]->{inst} != $trace[$i-1]->{inst})
{
- my $key = "$trace[$i-1]->{inst}_$trace[$i]->{inst}";
+ my $new_arc = { '1' => $trace[$i]->{inst}, '2' => $trace[$i]->{inst} };
+ $new_arc->{1} = $trace[$i-1]->{inst} if ( ($i!=0) && (!$trace[$i]->{terminated}) );
+ my $key = "$new_arc->{1}_$new_arc->{2}";
+
#Increment the arc_height if drawing multiple connections of does not exist
if ($each_execution_once)
@@ -403,8 +425,8 @@
$arc_height += $arc_height_increment;
$drawn_connections->{$key} = $arc_height;
}
-
- my $new_arc = { 'h'=> $drawn_connections->{$key}, '1' => $trace[$i-1]->{inst}, '2' => $trace[$i]->{inst} };
+ $new_arc->{'h'} = $drawn_connections->{$key};
+
unshift @arc_memory, $new_arc;
#remove last arc
pop @arc_memory if (scalar @arc_memory > scalar @execution_flare_colors);
More information about the Avida-cvs
mailing list