MCPcopy Create free account
hub / github.com/devosoft/avida / Process

Method Process

avida-core/source/actions/PrintActions.cc:3849–3881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3847 }
3848 static const cString GetDescription() { return "Arguments: [string fname='']"; }
3849 void Process(cAvidaContext& ctx)
3850 {
3851 cString filename(m_filename);
3852 if (filename == "") filename.Set("grid_task.%d.dat", m_world->GetStats().GetUpdate());
3853 Avida::Output::FilePtr df = Avida::Output::File::CreateWithPath(m_world->GetNewWorld(), (const char*)filename);
3854 ofstream& fp = df->OFStream();
3855
3856 cPopulation* pop = &m_world->GetPopulation();
3857 cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU(ctx);
3858
3859 const int num_tasks = m_world->GetEnvironment().GetNumTasks();
3860
3861 for (int i = 0; i < pop->GetWorldY(); i++) {
3862 for (int j = 0; j < pop->GetWorldX(); j++) {
3863 int task_sum = -1;
3864 int cell_num = i * pop->GetWorldX() + j;
3865 if (pop->GetCell(cell_num).IsOccupied() == true) {
3866 task_sum = 0;
3867 cOrganism* organism = pop->GetCell(cell_num).GetOrganism();
3868 cCPUTestInfo test_info;
3869 testcpu->TestGenome(ctx, test_info, organism->GetGenome());
3870 cPhenotype& test_phenotype = test_info.GetTestPhenotype();
3871 for (int k = 0; k < num_tasks; k++) {
3872 if (test_phenotype.GetLastTaskCount()[k] > 0) task_sum += static_cast<int>(pow(2.0, k));
3873 }
3874 }
3875 fp << task_sum << " ";
3876 }
3877 fp << endl;
3878 }
3879
3880 delete testcpu;
3881 }
3882};
3883
3884

Callers

nothing calls this directly

Calls 12

GetUpdateMethod · 0.80
GetNewWorldMethod · 0.80
CreateTestCPUMethod · 0.80
GetWorldYMethod · 0.80
GetWorldXMethod · 0.80
IsOccupiedMethod · 0.80
TestGenomeMethod · 0.80
SetMethod · 0.45
GetStatsMethod · 0.45
GetNumTasksMethod · 0.45
GetCellMethod · 0.45
GetOrganismMethod · 0.45

Tested by

no test coverage detected