|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.robot.SOCRobotNegotiator
public class SOCRobotNegotiator
Make and consider resource trade offers with other players.
Moved the routines that make and consider offers out of the robot brain.
Field Summary | |
---|---|
static int |
ACCEPT_OFFER
|
protected SOCRobotBrain |
brain
|
protected java.util.Stack<SOCPossiblePiece> |
buildingPlan
ourPlayerData 's building plan. |
static int |
COUNTER_OFFER
|
protected SOCRobotDM |
decisionMaker
|
protected SOCGame |
game
|
protected boolean[][] |
isSellingResource
|
protected java.util.Vector<SOCTradeOffer> |
offersMade
|
protected SOCPlayer |
ourPlayerData
|
private int |
ourPlayerNumber
ourPlayerData 's player number. |
protected SOCPlayerTracker |
ourPlayerTracker
|
protected java.util.HashMap<java.lang.Integer,SOCPlayerTracker> |
playerTrackers
|
static int |
REJECT_OFFER
|
protected int |
strategyType
|
protected SOCPossiblePiece[] |
targetPieces
|
protected boolean[][] |
wantsAnotherOffer
|
protected static int |
WIN_GAME_CUTOFF
|
Constructor Summary | |
---|---|
SOCRobotNegotiator(SOCRobotBrain br)
constructor |
Method Summary | |
---|---|
void |
addToOffersMade(SOCTradeOffer offer)
add an offer to the offers made list |
int |
considerOffer2(SOCTradeOffer offer,
int receiverNum)
consider an offer made by another player |
protected int |
getETAToTargetResources(SOCPlayer player,
SOCResourceSet targetResources,
SOCResourceSet giveSet,
SOCResourceSet getSet,
SOCBuildingSpeedEstimate estimate)
another aux function this one returns the number of rolls until we reach the target given a possible offer |
SOCTradeOffer |
getOfferToBank(SOCResourceSet targetResources)
|
SOCTradeOffer |
getOfferToBank(SOCResourceSet targetResources,
SOCResourceSet ourResources)
|
SOCTradeOffer |
makeCounterOffer(SOCTradeOffer originalOffer)
|
SOCTradeOffer |
makeOffer(SOCPossiblePiece targetPiece)
make an offer to another player |
protected SOCTradeOffer |
makeOfferAux(SOCResourceSet giveResourceSet,
SOCResourceSet getResourceSet,
int neededResource)
aux function for make offer |
void |
markAsNotSelling(int pn,
int rsrcType)
mark a player as not selling a resource |
void |
markAsNotWantingAnotherOffer(int pn,
int rsrcType)
mark a player as not wanting another offer |
void |
markAsSelling(int pn,
int rsrcType)
mark a player as willing to sell a resource |
void |
markAsWantsAnotherOffer(int pn,
int rsrcType)
mark a player as wanting another offer |
void |
resetIsSelling()
reset the isSellingResource array so that if the player has the resource, then he is selling it |
void |
resetOffersMade()
reset offers made |
void |
resetTargetPieces()
reset target pieces for all players |
void |
resetWantsAnotherOffer()
reset the wantsAnotherOffer array to all false |
void |
setTargetPiece(int pn,
SOCPossiblePiece piece)
set a target piece for a player |
boolean |
wantsAnotherOffer(int pn,
int rsrcType)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int WIN_GAME_CUTOFF
public static final int REJECT_OFFER
public static final int ACCEPT_OFFER
public static final int COUNTER_OFFER
protected SOCRobotBrain brain
protected int strategyType
protected SOCGame game
protected java.util.Stack<SOCPossiblePiece> buildingPlan
ourPlayerData
's building plan.
A stack of SOCPossiblePiece
.
protected java.util.HashMap<java.lang.Integer,SOCPlayerTracker> playerTrackers
protected SOCPlayerTracker ourPlayerTracker
protected final SOCPlayer ourPlayerData
private final int ourPlayerNumber
ourPlayerData
's player number.
protected SOCRobotDM decisionMaker
protected boolean[][] isSellingResource
protected boolean[][] wantsAnotherOffer
protected java.util.Vector<SOCTradeOffer> offersMade
protected SOCPossiblePiece[] targetPieces
Constructor Detail |
---|
public SOCRobotNegotiator(SOCRobotBrain br)
br
- the robot brainMethod Detail |
---|
public void resetTargetPieces()
public void setTargetPiece(int pn, SOCPossiblePiece piece)
pn
- the player numberpiece
- the piece that they want to build nextpublic void resetOffersMade()
public void addToOffersMade(SOCTradeOffer offer)
offer
- the offerpublic void resetIsSelling()
public void resetWantsAnotherOffer()
public void markAsNotSelling(int pn, int rsrcType)
pn
- the number of the playerrsrcType
- the type of resourcepublic void markAsSelling(int pn, int rsrcType)
pn
- the number of the playerrsrcType
- the type of resourcepublic void markAsNotWantingAnotherOffer(int pn, int rsrcType)
pn
- the number of the playerrsrcType
- the type of resourcepublic void markAsWantsAnotherOffer(int pn, int rsrcType)
pn
- the number of the playerrsrcType
- the type of resourcepublic boolean wantsAnotherOffer(int pn, int rsrcType)
pn
- the number of the playerrsrcType
- the type of resource
public SOCTradeOffer makeOffer(SOCPossiblePiece targetPiece)
targetPiece
- the piece that we want to build
protected SOCTradeOffer makeOfferAux(SOCResourceSet giveResourceSet, SOCResourceSet getResourceSet, int neededResource)
protected int getETAToTargetResources(SOCPlayer player, SOCResourceSet targetResources, SOCResourceSet giveSet, SOCResourceSet getSet, SOCBuildingSpeedEstimate estimate)
player
- our player datatargetResources
- the resources we wantgiveSet
- the set of resources we're givinggetSet
- the set of resources we're receivingestimate
- a SOCBuildingSpeedEstimate for our playerpublic int considerOffer2(SOCTradeOffer offer, int receiverNum)
offer
- the offer to considerreceiverNum
- the player number of the receiver
ACCEPT_OFFER
, REJECT_OFFER
, or COUNTER_OFFER
)public SOCTradeOffer makeCounterOffer(SOCTradeOffer originalOffer)
originalOffer
- the offer given to us
public SOCTradeOffer getOfferToBank(SOCResourceSet targetResources, SOCResourceSet ourResources)
targetResources
- what resources we wantourResources
- the resources we have
null
if ourResources
already contains all needed targetResources
public SOCTradeOffer getOfferToBank(SOCResourceSet targetResources)
targetResources
- what resources we want
null
if ourPlayerData.getResources()
already contains all needed targetResources
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |