Skip to content

Commit

Permalink
Implemented turning on/off PD for specific agent types.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamAdli committed May 9, 2018
1 parent 223fcbc commit bc73f8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

public class PDAgentParams implements ParameterSerializable {

@ConfDisplayName("PD Enabled")
@ConfXMLTag("pdEnabled")
public boolean pdEnabled = true;

/**
* Use tit-for-tat strategy for prisoner's dilemma.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cobweb/cobweb2/plugins/pd/PDMutator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public void setParams(PDParams pdParams) {

@Override
public PDState stateForNewAgent(Agent agent) {
if (!params.enable)
if (!params.enable || !params.agentParams[agent.getType()].pdEnabled)
return null;

return new PDState(params.agentParams[agent.getType()].clone());
}

@Override
protected PDState stateFromParent(Agent agent, PDState parentState) {
if (!params.enable)
if (!params.enable || !params.agentParams[agent.getType()].pdEnabled)
return null;

return new PDState(parentState.agentParams.clone());
Expand Down

0 comments on commit bc73f8b

Please sign in to comment.