Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Basic prisoner's dilemma? Date: Mon, 18 Apr 2011 13:34:36 -0400 Organization: albasani.net Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net welC0ri3gcR2KSTGPcw+K0d+FWGzaCWi1G1gc1zZRsJOgplTTwzE29fhT/zF26Uz9/Aqgn/FlTS876n3Icz9sNjwW7SkqjK9DAzajQdZOL5oFL3Ik0awjIF2iLx+ASxX NNTP-Posting-Date: Mon, 18 Apr 2011 17:34:32 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="MwNRoNroAoVwcTa2gY7guRhRpOpjRSGPSZ+/hm2Q/leyJGSL5OWof6mkClh3xNCRw5OZKeAyDwmWSxB1OPSOSWRYwm9w9g9LcR28ZwdwhRAwwWrhowRGbqUSdlWjfanK"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:1PWeaM5nSCnknORDpgI1aePZ6JU= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3111 Daniele Futtorovic wrote: > Basic tit-for-tat is as follows: > - if it's the first time you encounter that opponent (this implies you > keep a 'memory' of previous encounters), cooperate. > - otherwise, replicate that opponent's last move. > > In code (assuming oppHistory contains only the history with "this"): > > public String chooseAction( > ArrayList myHistory, ArrayList oppHistory) > { > return oppHistory.isEmpty() ? "COOPERATE" > : oppHistory.get( oppHistory.size() - 1 > ); > } > (or oppHistory.get(0), depending on whether it's used as a FIFO or a LIFO). > > > You can add various tricks, but don't expect to get far with them, > because tit-for-tat is the evolutionary stable strategy. > > If you're interested in the topic apart from the programming aspect, I > *very* strongly suggest you read Dawkins' "Selfish Gene" and "Blind > Watchmaker". Even if you're not, by the way -- those are IMHO must-reads. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg