| 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 |
nothing calls this directly
no test coverage detected