Module: lib/strategies/avenger

Tit-for-tat with a twist: once the opponent has defected more than DEFECT_THRESHOLD the strategy opts to defect forevermore. No apologies!

Originally by Eugine_Nier.

Source:

(require("lib/strategies/avenger"))(history) → {Boolean}

Strategy function. Consumes history, returns a choice.

Parameters:
Name Type Description
history Array

An array of arrays of each strategy's choice from each round so far, as [[my_choice, their_choice], ...].

Source:
Returns:

A boolean representing whether the strategy chooses to cooperate (true) or defect (false).

Type
Boolean

Members

(inner, constant) DEFECT_THRESHOLD :Number

Type:
  • Number
Default Value:
  • 5
Source: