Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,487 changes: 1,487 additions & 0 deletions Default-Config-jsons/NandProgram100.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Default-Config-jsons/diff-reward-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"shared": {
"tasks": [
{"name": "NAND", "value": 1, "reward_mode": "add"},
{"name": "NOT", "value": 1, "reward_mode": "add"},
{"name": "OR_NOT", "value": 2, "reward_mode": "add"},
{"name": "AND", "value": 2, "reward_mode": "add"},
{"name": "OR", "value": 4, "reward_mode": "add"},
{"name": "AND_NOT", "value": 4, "reward_mode": "add"},
{"name": "NOR", "value": 8, "reward_mode": "add"},
{"name": "XOR", "value": 8, "reward_mode": "add"},
{"name": "EQU", "value": 16, "reward_mode": "add"}
]
}
}
6 changes: 3 additions & 3 deletions example-settings-cfg/NandProgram100.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"value1": 0,
"value2": 0
},
"bitstring": "0000000000000000000000000000000000000000000000000000000000000000",
"bitstring": "1111111111111111111111111111111111111111111111111111111111111111",
"descriptors": [
{
"key": "summary",
"value": "register a global jump-to destination, maybe terminate"
},
{
"key": "tag bits",
"value": "0000000000000000000000000000000000000000000000000000000000000000"
"value": "1111111111111111111111111111111111111111111111111111111111111111"
},
{
"key": "tag moniker",
"value": "sad ibex"
"value": "flawed mayfly"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions example-settings-cfg/NotNandProgram100.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"value1": 0,
"value2": 0
},
"bitstring": "0000000000000000000000000000000000000000000000000000000000000000",
"bitstring": "1111111111111111111111111111111111111111111111111111111111111111",
"descriptors": [
{
"key": "summary",
"value": "register a global jump-to destination, maybe terminate"
},
{
"key": "tag bits",
"value": "0000000000000000000000000000000000000000000000000000000000000000"
"value": "1111111111111111111111111111111111111111111111111111111111111111"
},
{
"key": "tag moniker",
"value": "sad ibex"
"value": "flawed mayfly"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions example-settings-cfg/NotProgram100.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"value1": 0,
"value2": 0
},
"bitstring": "0000000000000000000000000000000000000000000000000000000000000000",
"bitstring": "1111111111111111111111111111111111111111111111111111111111111111",
"descriptors": [
{
"key": "summary",
"value": "register a global jump-to destination, maybe terminate"
},
{
"key": "tag bits",
"value": "0000000000000000000000000000000000000000000000000000000000000000"
"value": "1111111111111111111111111111111111111111111111111111111111111111"
},
{
"key": "tag moniker",
"value": "sad ibex"
"value": "flawed mayfly"
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions example-settings-cfg/ReproProgram100.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"value1": 0,
"value2": 0
},
"bitstring": "0000000000000000000000000000000000000000000000000000000000000000",
"bitstring": "1111111111111111111111111111111111111111111111111111111111111111",
"descriptors": [
{
"key": "summary",
"value": "register a global jump-to destination, maybe terminate"
},
{
"key": "tag bits",
"value": "0000000000000000000000000000000000000000000000000000000000000000"
"value": "1111111111111111111111111111111111111111111111111111111111111111"
},
{
"key": "tag moniker",
"value": "sad ibex"
"value": "flawed mayfly"
}
]
},
Expand Down
14 changes: 0 additions & 14 deletions source/Organism.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ class Organism {
std::cout << "ClearReproSyms called from Organism" << std::endl;
throw "Organism method called!";
}
virtual void CycleTransfer(int _in) {
Comment thread
EliasH-E marked this conversation as resolved.
std::cout << "CycleTransfer called from Organism" << std::endl;
throw "Organism method called!";
}
virtual int GetCyclesGiven() const {
std::cout << "GetCyclesGiven called from Organism" << std::endl;
throw "Organism method called!";
}
//Bacterium functions
virtual double ProcessLysogenResources(double phage_inc_val) {
std::cout << "ProcessLysogenResources called from Organism" << std::endl;
Expand Down Expand Up @@ -376,11 +368,5 @@ class Organism {
}


//SGPMode Symbiont Functions
virtual float DoTaskInteraction(float score, size_t task_id) {
std::cout << "DoTaskInteraction called from Organism" << std::endl;
throw "Organism method called!";
}

};
#endif
2 changes: 2 additions & 0 deletions source/sgp_mode/ProgramBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,10 @@ class ProgramBuilder {
* Note: Warns if the program contains disabled instructions.
*/
program_t LoadProgramFile(const std::filesystem::path& path) {

program_t program(path);
RectifyWithWarning(program);

return program;
}

Expand Down
7 changes: 6 additions & 1 deletion source/sgp_mode/SGPConfigSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ EMP_EXTEND_CONFIG(SymConfigSGP, SymConfigBase,
GROUP(SGP_MUTATION, "SGP mutation group"),
VALUE(SGP_MUT_PER_BIT_RATE, double, 0.01, "Per-bit mutation rate for sgp programs"),

GROUP(CUSTOM_PROGRAM, "Custom Program Settings"),
VALUE(HOST_PROGRAM_PATH, std::string, "Default-Config-jsons/NandProgram100.json", "Json file that provides hosts a custom starting program"),
VALUE(SYM_PROGRAM_PATH, std::string, "Default-Config-jsons/NandProgram100.json", "Json file that provides symbionts a custom starting program"),


GROUP(STRESS, "Stress Settings"),
VALUE(ENABLE_STRESS, bool, false, "Stress interactions enabled?"),
VALUE(STRESS_TYPE, std::string, "mutualist", "What kind of stress symbionts should be incorporated in stressful environments? (Options: 'mutualist', 'parasite', 'neutral')"),
Expand Down Expand Up @@ -62,7 +67,7 @@ EMP_EXTEND_CONFIG(SymConfigSGP, SymConfigBase,
VALUE(PARASITE_BASE_TASK_VALUE_PROP, double, 0.25, "Proportion of task value (defined by environment) that parasites receive when they fail to interact with their host."),

GROUP(TASK_ENVIRONMENT, "Task environment settings"),
VALUE(TASK_ENV_CFG_PATH, std::string, "environment.json", "Json file that provides environment configuration"),
VALUE(TASK_ENV_CFG_PATH, std::string, "Default-Config-jsons/diff-reward-env.json", "Json file that provides environment configuration"),
VALUE(TASK_IO_BANK_SIZE, size_t, 100000, "How many possible task input/output combinations to pre-generate?"),
VALUE(TASK_IO_UNIQUE_OUTPUT, bool, true, "Should each output in the pregenerated io combinations be unique?"),
VALUE(HOST_ONLY_FIRST_TASK_CREDIT, bool, false, "Only give host credit for one task (whatever they do first)?"),
Expand Down
30 changes: 12 additions & 18 deletions source/sgp_mode/SGPHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SGPHost : public Host {
* object as my_config from superclass, but with the correct subtype.
*
*/
// emp::Ptr<SymConfigSGP> sgp_config;
emp::Ptr<SymConfigSGP> sgp_config;

// // Function to configure functionality.
// void ConfigureDefaults() {
Expand Down Expand Up @@ -81,8 +81,8 @@ class SGPHost : public Host {
) :
Host(_random, _world, _config, _intval, _syms, _repro_syms, _points),
hardware(_world, this),
my_world(_world)
// sgp_config(_config)
my_world(_world),
sgp_config(_config)
{ }

/**
Expand All @@ -100,8 +100,8 @@ class SGPHost : public Host {
) :
Host(_random, _world, _config, _intval, _syms, _repro_syms, _points),
hardware(_world, this, genome),
my_world(_world)
// sgp_config(_config)
my_world(_world),
sgp_config(_config)
{ }

SGPHost(const SGPHost& host) :
Expand Down Expand Up @@ -171,11 +171,6 @@ class SGPHost : public Host {
*/
void SetReproCount(size_t _in) { reproductions = _in; }

void SetLocation(emp::WorldPosition pos) {
hardware.GetCPUState().SetLocation(pos);
Host::SetLocation(pos);
}

void DecPoints(double amt) {
points -= amt;

Expand Down Expand Up @@ -263,7 +258,6 @@ class SGPHost : public Host {
if (GetDead()) {
return;
}

// NOTE - Discuss timing of endosym pre-process signal and host preprocess signal
// Currently endosyms go first and then hosts. This is to model endosyms
// having opportunity to steal / donate cpu cycles and then host responding
Expand All @@ -290,15 +284,15 @@ class SGPHost : public Host {
}
// Endosymbiont gains baseline number of CPU cycles
cur_symbiont->GetHardware().GetCPUState().GainCPUCycles(
my_world->GetConfig().CYCLES_PER_UPDATE()
sgp_config->CYCLES_PER_UPDATE()
);
my_world->TriggerBeforeEndoSymHostProcessSig(
{endosym_i + 1, GetLocation().GetIndex()},
*cur_symbiont,
this
);
}
my_world->before_host_cpu_exec_sig.Trigger(*this);
my_world->TriggerBeforeHostCPUExec(*this);

// Host may have died as a result of this signal.
if (GetDead()) {
Expand Down Expand Up @@ -326,10 +320,10 @@ class SGPHost : public Host {
AttemptReproduction(pos);
}

my_world->after_host_cpu_step_sig.Trigger(*this);
my_world->TriggerAfterHostCPUStep(*this);
// NOTE - Check death here?
}
my_world->after_host_cpu_exec_sig.Trigger(*this);
my_world->TriggerAfterHostCPUExec(*this);
// Handle any endosymbionts (configurable at setup-time)
// NOTE - is there any reason that this might need to be a functor?
ProcessEndosymbionts();
Expand All @@ -338,7 +332,7 @@ class SGPHost : public Host {
return;
}
GrowOlder();
my_world->after_host_process_sig.Trigger(*this);
my_world->TriggerAfterHostProcess(*this);
}

void ProcessEndosymbionts() {
Expand Down Expand Up @@ -388,7 +382,7 @@ class SGPHost : public Host {
* TODO: Perhaps Default mode should have something similar
*/
void AttemptReproduction(const emp::WorldPosition& pos) {
const double repro_cost = my_world->GetConfig().HOST_REPRO_RES();
const double repro_cost = sgp_config->HOST_REPRO_RES();
if (GetPoints() >= repro_cost) {
// Host pays cost
DecPoints(repro_cost);
Expand Down Expand Up @@ -434,7 +428,7 @@ class SGPHost : public Host {
// Is this a host task?
if (!task_env.IsHostTask(task_id)) continue;
// Not first task
const bool not_first_task = my_world->GetConfig().HOST_ONLY_FIRST_TASK_CREDIT() && cpu_state.GetFirstTaskPerformed().Any() && !cpu_state.GetFirstTaskPerformed().Get(task_id);
const bool not_first_task = sgp_config->HOST_ONLY_FIRST_TASK_CREDIT() && cpu_state.GetFirstTaskPerformed().Any() && !cpu_state.GetFirstTaskPerformed().Get(task_id);
if (not_first_task) {
continue;
}
Expand Down
16 changes: 8 additions & 8 deletions source/sgp_mode/SGPSymbiont.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SGPSymbiont : public Symbiont {
* object as my_config from superclass, but with the correct subtype.
*
*/
// emp::Ptr<SymConfigSGP> sgp_config = NULL;
emp::Ptr<SymConfigSGP> sgp_config = NULL;
public:
/**
* Constructs a new SGPSymbiont as an ancestor organism, with either a random
Expand All @@ -60,9 +60,10 @@ class SGPSymbiont : public Symbiont {
) :
Symbiont(_random, _world, _config, _intval, _points),
hardware(_world, this),
my_world(_world)
my_world(_world),
sgp_config(_config)
{
// sgp_config = _config;

}

/**
Expand All @@ -78,10 +79,9 @@ class SGPSymbiont : public Symbiont {
) :
Symbiont(_random, _world, _config, _intval, _points),
hardware(_world, this, genome),
my_world(_world)
{
// sgp_config = _config;
}
my_world(_world),
sgp_config(_config)
{}

SGPSymbiont(const SGPSymbiont& symbiont) :
Symbiont(symbiont),
Expand Down Expand Up @@ -220,7 +220,7 @@ class SGPSymbiont : public Symbiont {
if (GetDead()) {
return;
}

GetHardware().GetCPUState().SetLocation(pos);
if(my_host) my_world->TriggerBeforeEndoSymProcessSig(pos, *this, my_host); //Note: this is different than before_endosym_host_process_sig
// Cash in cycles for this update
Expand Down
Loading
Loading