Java

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old August 3rd, 2011, 05:41 PM
xterra3202 xterra3202 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 1 xterra3202 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 26 sec
Reputation Power: 0
Prisoner's Dilemma Strategy Help

All,

Well I'm obviously new here and new to programming as well. I am almost complete with my first course and we are working with the iterated Prisoner's Dilemma using a genetic algorithm to play the game. I have managed to code just about everything except for the strategy and the memory for the previous three moves in the game. Any advice or help to program the strategy and memory would be great. The basic strategy is the tit-for-tat that works best in the PD. Below is the sample code for the player class of the program which is where the actually memory and strategy need to be coded (I have highlighted the needed area in red). If you need the entire program thus far I can email that if needed. Thanks so much for the help and advice.

Tim

PS- I am using NetBeans 7.0


<<Start Code>>

package tournament;

import java.util.Random;

/**
*
* @author
*/
public class Player {

private boolean Move;
private int Payoff;
private int [] Memory;
private int MoveCount;
private Random r = new Random();
private int totalPayoff;

public void setTotalPayoff(int totalPayoff) {
this.totalPayoff = totalPayoff;
}

public int getTotalPayoff() {
return totalPayoff;
}
boolean [] DNA = new boolean [64];

public void setDNA(boolean[] DNA) {
this.DNA = DNA;
}

public boolean[] getDNA() {
return DNA;
}


public int getMoveCount() {
return MoveCount;
}

public void setMoveCount(int MoveCount) {
this.MoveCount = MoveCount;
}



public boolean isMove() {
return Move;
}

public void setMove(boolean Move) {
this.Move = Move;

}

/**
* Gets the Payoff value
* @return The value of the Payoff
*/
public int getPayoff() {
return Payoff;

}

/**
* Sets the value of Payoff
* @param Payoff
*/
public void setPayoff(int Payoff) {
this.Payoff = Payoff;
MoveCount++;
addTotMemory(Payoff);
}

/**
* Default Constructor
*/
public Player() {
MoveCount = 0;
Move = true;
Payoff = 0;
Memory = new int [3];
for (int i=0; i<64; i++)
DNA[i]=r.nextBoolean();
}


public void strategy()
{
// TODO wtrite some strtegy
if(MoveCount <3)
{
Move = r.nextBoolean();
}
else
{
//Figure out how to code one of the three startegies
}
}

private void addTotMemory(int Payoff) {
if(MoveCount<3)
Memory[MoveCount]= Payoff;
else
{
//how to represent the memory the map of the code GCT the number or an array
//and somehow figure it out map or array would be a good starting point
//but have to figure out how to do a map.

}
}




}

<<End Code>>

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > Prisoner's Dilemma Strategy Help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap