def action_bits(self): """ Returns the maximum number of bits required to represent an action. """ actions = [util.bits_required(action) for action in self.valid_actions] return max(actions)
def observation_bits(self): """ Returns the maximum number of bits required to represent an observation. """ observations = [ util.bits_required(obs) for obs in self.valid_observations ] return max(observations)
def action_bits(self): """ Returns the maximum number of bits required to represent an action. """ # TODO(DONE): implement bits_list = [] # Check the number of bits required to represent every action for action in self.valid_actions: bits_list.append(util.bits_required(action)) # Return the max number of bits required return max(bits_list)
def reward_bits(self): """ Returns the maximum number of bits required to represent a reward. """ # TODO(DONE): implement bits_list = [] # Check the number of bits required to represent every reward for reward in self.valid_rewards: bits_list.append(util.bits_required(reward)) # Return the max number of bits required return max(bits_list)
def action_bits(self): """ Returns the maximum number of bits required to represent an action. (Called `actionBits` in the C++ version.) """ # Find the largest sized observation. maximum_bits = 0 for action in self.valid_actions: bits_for_this_action = util.bits_required(action) if bits_for_this_action > maximum_bits: maximum_bits = bits_for_this_action # end if # end for return maximum_bits
def reward_bits(self): """ Returns the maximum number of bits required to represent a reward. (Called `rewardBits` in the C++ version) """ # Find the largest sized reward. maximum_bits = 0 for reward in self.valid_rewards: bits_for_this_reward = util.bits_required(reward) if bits_for_this_reward > maximum_bits: maximum_bits = bits_for_this_reward # end if # end for return maximum_bits
def reward_bits(self): """ Returns the maximum number of bits required to represent a reward. """ return util.bits_required(self.reward)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 22 17:05:54 2019 @author: andrewtanggara """ from pyaixi import agent, prediction, search, util from pyaixi.environment import Environment b = util.bits_required(7) print(b)