- Chromosome design – Use a 5‑bit vector [g1 g2 g3 g4 g5] where g1= first move and g2–g5= moves for CC,CD,DC,DD (previous round).
- Decoder – A tiny function consults the chromosome to decide the next move. If there is no history yet, returng₁. Otherwise map the last round’s outcome to one of the remaining four genes and return that gene value. Decoder never changes.
- Define the payoff environment – Select the Prisoner’s Dilemma payoff numbers (e.g. Temptation=5, Reward=3, Punishment=1) and a game length (e.g. 150 rounds). All candidates will be evaluated under exactly the same conditions.
- Define the fitness function – For a given chromosome; Run a match against each benchmark opponent, summing your pay‑off each round. Average those pay‑offs.Return the negative of that average (MATLAB’s "ga" minimises the objective, so negating the score converts “high payoff is good” into “low objective is good”).
- Genetic loop – Initialise a random population of chromosomes; then for each generation: evaluation → selection → crossover → mutation (small bit‑flips) → next population.
- Stop condition – When best score plateaus or after a set number of generations.
- Read result – Inspect the best 5‑bit vector; it encodes a full memory‑1 strategy (e.g.,11010 = Tit‑for‑Tat, 11000 = Grim).
Genetic Algorithms implementation
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm currently having a problem in using genetic algorithms for the implementation of the iterated prisoner dilemma.
The main issues lies in the introduction of strategies to player, I.e. tit for tat and grim. I understand that the original genetic algorithms uses chromosomes as a way to stipulate agents strategy by telling them to cooperate or defect in specific period but do not tell them to play current period using outcomes from previous period.
Hence the question, can someone kindly point me in a direction where i can get started? Should i start paying attention to the chromosomes or should i pay attention to the strategy function? Thanks
0 Kommentare
Antworten (1)
TED MOSBY
am 12 Mai 2025
Bearbeitet: TED MOSBY
am 13 Mai 2025
Hi,
Your have to (1) choose an encoding that can express the kinds of memory‑based strategies (TitforTat, Grim, etc.), and (2) write a decoder that turns each chromosome into a callable strategy function.
You can follow the roadmap below to get started on iterative prisoners dilemma startegy using genetic algorithm in MATLAB:
Here is more information on MATLAB's function"ga":
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!