Using Genetic Algorithms to Evolve Strategies for Rock-Paper-Scissors Game - Prof. Stephan, Assignments of Programming Languages

An assignment for a university course, cs 591, where students are required to use genetic algorithms (ga) to evolve strategies for the rock-paper-scissors (rps) game. The assignment involves modifying an existing ga or writing a new one, testing it against a nash strategy, changing the fitness function, and adding spatial structure to the population. The document also provides resources for downloading ga software and details about what to hand in.

Typology: Assignments

Pre 2010

Uploaded on 07/23/2009

koofers-user-vef
koofers-user-vef 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Using Genetic Algorithms to Play Rock-Paper-Scissors
Complex Adaptive Systems
CS 591, Section 8
Assignment 1
February 16, 2006
1 Introduction
The idea of this assignment is to use the genetic algorithm to evolve strategies for playing a sim-
ple two-person game known as Rock-Paper-Scissors (RPS). In RPS, each player has a choice of
three alternatives: Rock, Paper, and Scissors. After each player has made her choice, the winner
is determined as follows: Rock beats Scissors (by smashing the scissors); Paper beats Rock (by
wrapping the Rock); Scissors beats Paper (by cutting the paper). For one round of the game, all
choices have equal probability of winning, so no strategy is favored. However, the game becomes
more interesting when there are repeated interactions between the players. In this assignment we
will be as interested in the dynamics of a population of RPS players as we are in evolving a single
rule that plays the game well.
2 Assignment
You are free to choose any publicly available genetic algorithm software or to write your own using
the language of your choice. One possible choice is a very simple genetic algorithm written in C by
Gary Flake (see URLs below). If you choose to use Flake’s code, please note that it generates FSAs
for playing the Prisoner’s Dilemma. You will be using a different representation to play a different
game.
1. Due: March 1 Modify an existing GA (or write your own) to learn strategies for RPS.
(a) Test the GA against a simple Nash strategy (the strategy that chooses among the three
alternatives with equal probability). That is, evaluate an individual’s fitness by measur-
ing its success playing against the Nash strategy
(b) Change the fitness function so that an individual iplays against xother individuals
on each generation to determine i’s fitness. The best value for xwill depend on your
population size—-you will need to experiment with different values of xto learn which
values produce the most interesting dynamics. Each ivs. xinteraction consists of a
repeated RLP game, say for 51 rounds.
2. Due: March 13 Extend the model to include other representations and space.
(a) Design a representation that includes the Nash strategy. e.g., by encoding the strategy
as a set of probabilities, implement the strategy, and compare its performance with the
performance of the representation from Part I.
(b) Add space to the model, so that the population occupies a 2-Dimensional array, with one
individual (or a small number of individuals) occupying every cell in the array. Study
the effects of adding spatial structure to the population.
1
pf3

Partial preview of the text

Download Using Genetic Algorithms to Evolve Strategies for Rock-Paper-Scissors Game - Prof. Stephan and more Assignments Programming Languages in PDF only on Docsity!

Using Genetic Algorithms to Play Rock-Paper-Scissors

Complex Adaptive Systems

CS 591, Section 8

Assignment 1

February 16, 2006

1 Introduction

The idea of this assignment is to use the genetic algorithm to evolve strategies for playing a sim- ple two-person game known as Rock-Paper-Scissors (RPS). In RPS, each player has a choice of three alternatives: Rock, Paper, and Scissors. After each player has made her choice, the winner is determined as follows: Rock beats Scissors (by smashing the scissors); Paper beats Rock (by wrapping the Rock); Scissors beats Paper (by cutting the paper). For one round of the game, all choices have equal probability of winning, so no strategy is favored. However, the game becomes more interesting when there are repeated interactions between the players. In this assignment we will be as interested in the dynamics of a population of RPS players as we are in evolving a single rule that plays the game well.

2 Assignment

You are free to choose any publicly available genetic algorithm software or to write your own using the language of your choice. One possible choice is a very simple genetic algorithm written in C by Gary Flake (see URLs below). If you choose to use Flake’s code, please note that it generates FSAs for playing the Prisoner’s Dilemma. You will be using a different representation to play a different game.

  1. Due: March 1 Modify an existing GA (or write your own) to learn strategies for RPS.

(a) Test the GA against a simple Nash strategy (the strategy that chooses among the three alternatives with equal probability). That is, evaluate an individual’s fitness by measur- ing its success playing against the Nash strategy (b) Change the fitness function so that an individual i plays against x other individuals on each generation to determine i’s fitness. The best value for x will depend on your population size—-you will need to experiment with different values of x to learn which values produce the most interesting dynamics. Each i vs. x interaction consists of a repeated RLP game, say for 51 rounds.

  1. Due: March 13 Extend the model to include other representations and space.

(a) Design a representation that includes the Nash strategy. e.g., by encoding the strategy as a set of probabilities, implement the strategy, and compare its performance with the performance of the representation from Part I. (b) Add space to the model, so that the population occupies a 2-Dimensional array, with one individual (or a small number of individuals) occupying every cell in the array. Study the effects of adding spatial structure to the population.

3 Details

3.1 Representation

A suggested representation is to modify the representation described in class for the Prisoner’s Dilemma game. In that representation, a history of the past three moves is maintained and used as an index into an array that specifies what move to make. If you choose to maintain a history of three moves, then your strategy will have 3^6 possibilities rather than 2^6 (because there are three possible choices at each time step). This is only a suggestion. If you have an idea for a different representation, please discuss it with Stephanie ahead of time.

3.2 Questions

  1. What are the dynamics of the population of evolving strategies? Are their oscillations in the population or does it evolve to a steady state? Do the dynamics resemble those described in the Sato et al. paper?
  2. When you modify the representation to incorporate some nondeterminism, how do the dy- namics change?
  3. When you add space to the model, how do the dynamics change? How do the dynamics compare to those described in the Kerr et al. paper?

3.3 Software

Gary Flake’s book The Computational Beauty of Nature, published by MIT Press, has an excel- lent collection of software that accompanies it. The software, including the genetic algorithm, is available from http://mitpress.mit.edu/books/FLAOH/cbnhtml/source.html. The general download page is: http://mitpress.mit.edu/books/FLAOH/cbnhtml/download.html. There are UNIX, Mac, and Windows versions, both binary and source. The basic, architecture-independent (i.e. UNIX or Windows) source archive is: http://mitpress.mit.edu/books/FLAOH/cbnhtml/cbn-noarch-src+docs.tgz. The most rele- vant program for us is called gaipd (GA for Iterated Prisoner’s Dilemma). Another recommended package, although I haven’t personally tried it, is GAlib, available from http://lancet.mit.edu/ga/. This is a more recent industrial strength implementation.

3.4 What to hand in

You are allowed to work with one other partner, if you choose. On March 1 you are expected to hand in a working GA (source code listing), some plots of its performance (e.g., mean fitness plotted against generation), descriptions of examples of high-fitness individuals, and a 3-5 page writeup. On March 13, you should hand in an augmented writeup that describes your new representation, how the spatial algorithm works, any changes to the fitness function, your new results, the comparison between the various methods, and your conclusions.