Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #3096
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!k3g2000prl.googlegroups.com!not-for-mail |
|---|---|
| From | theglazeb <theglazeb@gmail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Basic prisoner's dilemma? |
| Date | Sun, 17 Apr 2011 19:51:20 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 43 |
| Message-ID | <d97822e4-ee7c-458d-8818-07007fb714e8@k3g2000prl.googlegroups.com> (permalink) |
| NNTP-Posting-Host | 128.12.109.242 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Trace | posting.google.com 1303095080 31916 127.0.0.1 (18 Apr 2011 02:51:20 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Mon, 18 Apr 2011 02:51:20 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | k3g2000prl.googlegroups.com; posting-host=128.12.109.242; posting-account=1PELHwoAAACivrc1DNJ5MK4QDL6WZRCv |
| User-Agent | G2/1.0 |
| X-HTTP-UserAgent | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16,gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3096 |
Show key headers only | View raw
Hi there!
I was wondering if you were able to help with me a basic prisoner's
dilemma strategy? How would I implement a basic tit for tat strategy?
And perhaps try to avoid the "death spiral" from occurring when two
players use the tit for tat strategy?
See below
Thanks!
/*
* File: PDStrategy.java
* ---------------------
* This class encapsulates the strategy for an Iterated Prisoner's
* Dilemma game. To enter the contest, all you have to do is change
* the definition of chooseAction so that it takes account of the
* history and does something more clever than cooperating (or
* defecting) all the time.
*/
import java.util.*;
class PDStrategy {
/*
* Method: chooseAction
* --------------------
* This method determines the player's action for the current
* game, based on two ArrayLists containing the history of play:
* one for your algorithm and one for the opponent. Each of these
* ArrayLists contains strings, which are guaranteed to be one of
* the uppercase strings "COOPERATE" or "DEFECT". Your method
* should look at the history and return one of those two strings
* representing the action you take on the current round.
*/
public String chooseAction(ArrayList<String> myHistory,
ArrayList<String> oppHistory) {
return "COOPERATE"; //currently, it is only cooperating
}
}
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
Basic prisoner's dilemma? theglazeb <theglazeb@gmail.com> - 2011-04-17 19:51 -0700
Re: Basic prisoner's dilemma? Lew <noone@lewscanon.com> - 2011-04-17 23:15 -0400
Re: Basic prisoner's dilemma? Esmond Pitt <esmond.pitt@bigpond.com> - 2011-04-18 13:54 +1000
Re: Basic prisoner's dilemma? theglazeb <theglazeb@gmail.com> - 2011-04-17 22:08 -0700
Re: Basic prisoner's dilemma? Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-04-17 23:47 -0700
Re: Basic prisoner's dilemma? markspace <-@.> - 2011-04-18 00:14 -0700
Re: Basic prisoner's dilemma? rossum <rossum48@coldmail.com> - 2011-04-18 13:01 +0100
Re: Basic prisoner's dilemma? Bent C Dalager <bcd@pvv.ntnu.no> - 2011-04-18 13:38 +0000
Re: Basic prisoner's dilemma? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-18 19:22 +0200
Re: Basic prisoner's dilemma? Lew <noone@lewscanon.com> - 2011-04-18 13:34 -0400
Re: Basic prisoner's dilemma? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-18 21:26 +0200
Re: Basic prisoner's dilemma? Lew <noone@lewscanon.com> - 2011-04-18 16:33 -0400
Re: Basic prisoner's dilemma? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-04-18 23:50 +0200
Re: Basic prisoner's dilemma? Lew <noone@lewscanon.com> - 2011-04-18 18:37 -0400
Re: Basic prisoner's dilemma? markspace <-@.> - 2011-04-18 15:51 -0700
Re: Basic prisoner's dilemma? Michael Wojcik <mwojcik@newsguy.com> - 2011-04-19 16:14 -0400
csiph-web