def decisionOptions(self, playerID): options = [] playerInfo = None mostInPot = 0 for playerInfo in self.playersInfo: if playerInfo.pot > mostInPot: mostInPot = playerInfo.pot if playerInfo.id == playerID: thisPlayer = playerInfo assert playerInfo != None options.append(decision.Decision(decision.Decision.GAMEQUIT)) options.append(decision.Decision(decision.Decision.FORFEIT)) if thisPlayer.isActive: #We're in a showdown if self.miscInfo[self.REVEAL_OR_FOLD]: options.append(decision.Decision(decision.Decision.FOLD)) options.append(decision.Decision(decision.Decision.REVEAL)) elif self.miscInfo[self.MUST_REVEAL]: options.append(decision.Decision(decision.Decision.REVEAL)) #Normal play else: #Unmatched raises in pot and we're not all in if thisPlayer.pot < mostInPot and thisPlayer.bank > 0 : options.append(decision.Decision(decision.Decision.CALL)) options.append(decision.Decision(decision.Decision.FOLD)) else: options.append(decision.Decision(decision.Decision.CHECK)) #We can also raise the stakes if we have the money (otherwise all we can do is call) if thisPlayer.bank > mostInPot-thisPlayer.pot: #Quickly check we're not the only player left in betting numCanStillCall = 0 for p in self.playersInfo: if p.isInHand and p.bank > mostInPot-p.pot: numCanStillCall += 1 if numCanStillCall > 1: options.append(decision.Decision(decision.Decision.RAISE)) else: options.append(decision.Decision(decision.Decision.WAIT)) return options
def giveDecision(self, theState): decisions = theState.decisionOptions(self.id) choice = random.randint(0, 100) theDecision = None #Generally waiting, folding, checking or revealing should always be an option for d in decisions: if (d.name == decision.Decision.WAIT or d.name == decision.Decision.FOLD or d.name == decision.Decision.CHECK or d.name == decision.Decision.REVEAL): theDecision = d #Sanity test that we could have checked, folded or revealed assert theDecision != None #More players, play less aggressively (2 players = 30%, 3 = 20%, 4 = 15%, ... 12 = 5%) numActive = 0 for p in theState.playersInfo: if p.isInGame: numActive += 1 raiseChance = 60 / numActive for p in theState.playersInfo: if p.id == self.id: me = p callAmount = theState.getCallAmount(me) if callAmount > me.bank: callAmount = me.bank possibleRaise = me.bank - callAmount #We'll call if the call amount is low, relative to our bank, or low relative to our pot callChance = raiseChance + 100 - int( 50 * (callAmount / (me.pot + callAmount + 1.0))) - int( 100 * (callAmount / (me.bank + callAmount + 1.0))) for d in decisions: if d.name == decision.Decision.CALL and choice > 99 - callChance: theDecision = d if d.name == decision.Decision.RAISE and choice > 99 - raiseChance and possibleRaise > 0: myRaise = possibleRaise if possibleRaise > 0: if choice > 99 - (raiseChance / 6): #go all-in myRaise = possibleRaise elif choice > 99 - (raiseChance / 3): #big raise myRaise = int(me.bank / 4) if myRaise > possibleRaise: myRaise = possibleRaise else: #small raise myRaise = int(me.bank / 8) if myRaise > possibleRaise: myRaise = possibleRaise theDecision = decision.Decision(decision.Decision.RAISE, myRaise) return theDecision
def getDecision(self, theState): if len(self.decisions) >= 1: d = self.decisions[0] self.decisions = self.decisions[1:] else: d = decision.Decision() return d
def assess_decision(self, choice, option): """ Takes a Choice and an option at that choice, and assesses how consistent that decision is with this player model from a prospective standpoint, returning a number between 0 (completely inconsistent) and 1 (perfectly consistent). """ self._synthesize_moe() dec = decision.Decision(choice) dec.add_prospective_impressions(self.priority_method, self._synthesized_mode_of_engagement) dec.select_option(option) return self.decision_method.consistency(dec)
def __init__(self, dataset_params, encoder_params, channel_params, decoder_params, decision_params): self.X = tf.compat.v1.placeholder(tf.float32, shape=(None, 13, dataset_params['n_features']), name="X") self.Noise = tf.compat.v1.placeholder(tf.float32, shape=(), name="Noise") # encoder -----Transmitter Model self._encoder = enc.Encoder(inputs=self.X, **encoder_params) self._z = self._encoder.get_latent_representation( ) # shape (?, 1, 104) # Stochastic Channel Model #print("self._z", self._z.shape) self._channel = sc.Channel(inputs=self._z, **channel_params) self._channelout = self._channel.get_ChannelOuput() # AWGN noise layer -----Channel Model(Part) w = noi.gaussian_noise_layer(input_layer=self._channelout, std=self.Noise) #print("w shape is: ", w.shape) w = tf.reshape(w, [-1, 476]) #print("w before complex is: ", w.shape) # convert to complex number and then slice w = RToC.get_c(w) #print("w after complex is: ", w.shape) # Slicer self.slice_output = tf.slice(w, [0, k1], [-1, k2 - k1 + 1]) #print("first slice is: ", self.slice_output.shape) # conver it back to real number self.slice_output = CToR.get_r(self.slice_output) #print("self.slice_output shape is: ", self.slice_output.shape) # decoder layer -input shape is (batch_size, 352)--Real self._decoder = dec.Decoder(inputs=self.slice_output, **decoder_params) u = self._decoder.get_outputs() # decision -----Receiver Model self._decision = decis.Decision(inputs=u, **decision_params) self._Xhat = self._decision.get_decision()
def make_decision(self, choice): """ Given a choice, creates a Decision object by building a decision model using an updated-if-necessary full mode of engagement and then deciding on an option using this player's DecisionMethod. Rolls outcomes and adds retrospective impressions to the created decision as well. """ # TODO: Some way to model cognitive dissonance + regret when a reveal # changes goals and/or brings new facts to light about an old decision? self._synthesize_moe() dec = decision.Decision(choice) dec.add_prospective_impressions(self.priority_method, self._synthesized_mode_of_engagement) selection = self.decision_method.decide(dec) dec.select_option(selection) dec.roll_outcomes() dec.add_retrospective_impressions() return decision
import pisqpipe as pp from pisqpipe import DEBUG_EVAL, DEBUG import decision as ai pp.infotext = 'name="pbrain-PARIS-LELEU.HUBERT", author="Cedric Cescutti & Hubert Leleu", version="1.2", country="France"' MAX_BOARD = 100 BOARD = [[0 for i in range(MAX_BOARD)] for j in range(MAX_BOARD)] GOMOKU_AI = ai.Decision(1, 1, 2, 0) def brain_init(): if pp.width < 5 or pp.height < 5: pp.pipeOut("ERROR size of the map") return if pp.width > MAX_BOARD or pp.height > MAX_BOARD: pp.pipeOut("ERROR Maximal map size is {}".format(MAX_BOARD)) return global BOARD BOARD = [[0 for i in range(pp.width)] for j in range(pp.height)] pp.pipeOut("OK") def brain_restart(): for y in range(pp.height): for x in range(pp.width): BOARD[y][x] = 0 pp.pipeOut("OK") def isFree(x, y):
def getDecision(self, gameState): default = decision.Decision() return default
def giveDecision(self, state): default = decision.Decision() return default
def getDecision(self, theState): for playersInfo in theState.playersInfo: if playersInfo.id == self.id: thisPlayerInfo = playersInfo if playersInfo.isActive == False and self.AUTO_PUSH_WAIT: #-------AUTO PUSH "WAIT" FOR INACTIVE PLAYERS------- # #--------------------------------------------------- return (decision.Decision(decision.Decision.WAIT)) #--------------------------------------------------- # #--------------------------------------------------- #First clear the screen - TURNED OFF os.system("clear") #Now display the game state self.drawState(theState) #Now get the user prompt theDecision = decision.Decision() if theState.miscInfo[ state.State.CONTINUE_ONLY] or thisPlayerInfo.isActive == False: print theState.miscInfo[state.State.CONTINUE_TEXT] print "Enter any input to continue." raw_input() else: #Normal state, we need to get the player's decision print " " print "Your options:" while True: #Now display the user options decisions = theState.decisionOptions(self.id) canCall = False canReveal = False for d in decisions: callAmount = theState.getCallAmount(thisPlayerInfo) if d.name == "CALL": dText = d.name + " (" + str(callAmount) + ")" canCall = True elif d.name == "RAISE" and callAmount > 0: dText = "RAISE (+" + str(callAmount) + " TO CALL)" elif d.name == "REVEAL": canReveal = True dText = "REVEAL" else: dText = d.name print dText print " " rawText = raw_input() splitText = rawText.split() if len(splitText) >= 1: decisionText = splitText[0].upper() else: decisionText = "" if len(splitText) > 1: try: decisionValue = int(splitText[1]) except ValueError: decisionValue = 0 else: decisionValue = 0 if decisionText == "W" or decisionText == "WAIT": theDecision = decision.Decision(decision.Decision.WAIT) elif decisionText == "F" or decisionText == "FOLD": theDecision = decision.Decision(decision.Decision.FOLD) elif decisionText == "C" or decisionText == "CHECK" or decisionText == "CALL": if not canCall or decisionText == "CHECK": theDecision = decision.Decision( decision.Decision.CHECK) elif canCall or decisionText == "CALL": theDecision = decision.Decision(decision.Decision.CALL) elif decisionText == "R" or decisionText == "RAISE" or decisionText == "REVEAL": if not canReveal or decisionText == "RAISE": theDecision = decision.Decision( decision.Decision.RAISE, decisionValue) elif canReveal or decisionText == "REVEAL": theDecision = decision.Decision( decision.Decision.REVEAL) elif decisionText == "FORFEIT": theDecision = decision.Decision(decision.Decision.FORFEIT) elif decisionText == "GAMEQUIT" or decisionText == "QUIT": theDecision = decision.Decision(decision.Decision.GAMEQUIT) if theState.isValidDecision(self.id, theDecision): break else: print "Sorry, you can't do that right now." return theDecision