Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #3102
| Date | 2011-04-17 23:47 -0700 |
|---|---|
| From | Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Basic prisoner's dilemma? |
| References | <d97822e4-ee7c-458d-8818-07007fb714e8@k3g2000prl.googlegroups.com> <iogac0$lnc$1@news.albasani.net> <4dabb5e8$0$55571$c30e37c6@exi-reader.telstra.net> <3c4ead8c-1841-415f-8bbe-f716ab8f33a9@l14g2000pre.googlegroups.com> |
| Message-ID | <TeOdnbAv6u8TQzbQnZ2dnUVZ_oednZ2d@posted.palinacquisition> (permalink) |
On 4/17/11 10:08 PM, theglazeb wrote:
> [...] how could make it output random
> DEFECT or COOPERATE? and then following on that, how could I start
> thinking about a Tit for Tat strategy?
class Prisoner
{
private java.util.Random _rnd = new java.util.Random();
public String randomChoice()
{
return _rnd.nextBoolean() ? "DEFECT" : "COOPERATE";
}
public String titForTat(String opponentsLastChoice)
{
return opponentsLastChoice;
}
}
Incorporate those "algorithms" into your ArrayList-based code as needed.
For example:
class PDTitForTatStrategy extends PDStrategy
{
private Prisoner _prisoner = new Prisoner();
public String chooseAction(ArrayList<String> myHistory,
ArrayList<String> oppHistory)
{
return _prisoner.titForTat(oppHistory.get(oppHistory.size() - 1));
}
}
Or rework the logic so it's all in one class, or whatever you want to do.
Pete
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | 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