Skip to content

Commit a4a81dc

Browse files
Merge pull request #256 from EliasH-E/docu-branch
Added more documentation
2 parents 53f22af + cbee3f9 commit a4a81dc

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

source/sgp_mode/GenomeLibrary.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ class ProgramBuilder : emp::vector<sgpl::Instruction<Spec>> {
265265
Add("SharedIO");
266266
}
267267

268+
269+
/**
270+
* Input: The number of steal instructions to add.
271+
*
272+
* Output: None.
273+
*
274+
* Purpose: Spread out steal instructions throughout the organim's genome in order to allow stealing
275+
* during a symbiont's entire genome and not just in one place. Without the spread of instructions symbionts were unable to steal regularly and died.
276+
*/
268277
void AddStartSteal(int steal_count){
269278

270279
if(steal_count > 0){
@@ -283,6 +292,14 @@ class ProgramBuilder : emp::vector<sgpl::Instruction<Spec>> {
283292

284293
}
285294

295+
/**
296+
* Input: The number of donate instructions to add.
297+
*
298+
* Output: None.
299+
*
300+
* Purpose: Spread out donate instructions throughout the organim's genome in order to allow donations
301+
* during a symbiont's entire genome and not just in one place. Without the spread of instructions symbionts were unable to donate regularly.
302+
*/
286303
void AddStartDonate(int donate_count){
287304

288305
if(donate_count > 0){

source/sgp_mode/HealthHost.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,40 @@ class HealthHost : public SGPHost {
5353
random, GetWorld(), sgp_config, GetCPU().GetProgram(), GetIntVal());
5454
return host_baby;
5555
}
56+
57+
/**
58+
* Input: An integer amount for the number of updates that are being transferred
59+
*
60+
* Output: None.
61+
*
62+
* Purpose: To change the number of cycles a host is set to give/be given.
63+
*/
5664
void CycleTransfer(int amount) override {
5765
cycles_given += amount;
5866
}
5967

68+
/**
69+
* Input: None.
70+
*
71+
* Output: A integer for the amount of cycles the host is set to give/be given.
72+
*
73+
* Purpose: For symbionts to check if their host already owes cycles.
74+
*/
6075
int GetCyclesGiven(){
6176
return cycles_given;
6277
}
6378

79+
/**
80+
* Input: None.
81+
*
82+
* Output: The string 'HealthHost', which is the name of this organism
83+
*
84+
* Purpose: Allows tests to check that an organism is of the proper type.
85+
*/
6486
std::string const GetName() override{
6587
return "HealthHost";
6688
}
89+
6790
/**
6891
* Input: The location of the host.
6992
*
@@ -201,4 +224,4 @@ class HealthHost : public SGPHost {
201224
};
202225

203226

204-
#endif // HEALTHHOST_H
227+
#endif // HEALTHHOST_H

source/sgp_mode/SGPWorldSetup.cc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
#include "SGPSymbiont.h"
88
#include "SGPWorld.h"
99

10+
11+
/**
12+
* Input: A pointer to a long for the number of hosts to add to the world
13+
*
14+
* Output: None
15+
*
16+
* Purpose: Adds a number of hosts of a set type to the world.
17+
*/
1018
void SGPWorld::SetupHosts(unsigned long *POP_SIZE) {
1119
for (size_t i = 0; i < *POP_SIZE; i++) {
1220
emp::Ptr<SGPHost> new_org;
@@ -59,6 +67,14 @@ void SGPWorld::SendToGraveyard(emp::Ptr<Organism> org) {
5967
SymWorld::SendToGraveyard(org);
6068
}
6169

70+
71+
/**
72+
* Input: An id for the the parent symbiont and a pointer to that symbiont.
73+
*
74+
* Output: The id of a host that can be infected by the symbiont
75+
*
76+
* Purpose: Searches through up to 10 hosts in the world to find a host that the symbiont can infect.
77+
*/
6278
int SGPWorld::GetNeighborHost (size_t id, emp::Ptr<Organism> symbiont){
6379
// Attempt to find host that matches some tasks
6480
for (int i = 0; i < 10; i++) {
@@ -129,7 +145,14 @@ bool SGPWorld::TaskMatchCheck(emp::Ptr<Organism> sym_parent, emp::Ptr<Organism>
129145
}
130146

131147

132-
148+
/**
149+
* Input: Pointers to a symbiont offspring and the position of the symbiont's parent.
150+
*
151+
* Output: Returns a WorldPosition pointer, a valid one for succesful
152+
* infection and an invalid for a failed infection
153+
*
154+
* Purpose: To get the location of where the symbiont offpsring can be added to.
155+
*/
133156
emp::WorldPosition SGPWorld::SymDoBirth(emp::Ptr<Organism> sym_baby, emp::WorldPosition parent_pos) {
134157
size_t i = parent_pos.GetPopID();
135158
emp::Ptr<Organism> parent = GetOrgPtr(i)->GetSymbionts()[parent_pos.GetIndex()-1];

0 commit comments

Comments
 (0)