示例#1
0
class BlackjackEnv(Environment):

  # the number of action values the environment accepts
  #indim = 2

  # the number of sensor values the environment produces
  #outdim = 21

  def __init__(self, GameDeck):
    self.gameDeck = GameDeck
    self.indim = 2
    self.outdim = 32

  def createHand(self):
    self.hand = BlackjackHand(self.gameDeck)
    self.hand.getHand()

  def getSensors(self):
    handValue = self.hand.getValue()-1
    return [float(handValue),]

  def performAction(self, action):
    if action == 0.:
      self.hand.hit()
    return action

  def reset(self):
    self.gameDeck.shuffleDeck()
    self.hand.getHand()
class BlackjackEnv(Environment):

    # the number of action values the environment accepts
    #indim = 2

    # the number of sensor values the environment produces
    #outdim = 21

    def __init__(self, GameDeck):
        self.gameDeck = GameDeck
        self.indim = 2
        self.outdim = 32

    def createHand(self):
        self.hand = BlackjackHand(self.gameDeck)
        self.hand.getHand()

    def getSensors(self):
        handValue = self.hand.getValue() - 1
        return [
            float(handValue),
        ]

    def performAction(self, action):
        if action == 0.:
            self.hand.hit()
        return action

    def reset(self):
        self.gameDeck.shuffleDeck()
        self.hand.getHand()
示例#3
0
class BlackjackDealer():

  def __init__(self,gameDeck):
    self.gameDeck = gameDeck

  def createHand(self):
    self.hand = BlackjackHand(self.gameDeck)
    self.hand.getHand()

  def getHand(self):
    return self.hand.Hand

  def getHandValue(self):
    return self.hand.getValue()

  def playHand(self):
    while self.hand.getValue() < 17:
      self.hand.hit()
示例#4
0
 def createHand(self):
   self.hand = BlackjackHand(self.gameDeck)
   self.hand.getHand()