def str_HP_builder(self): str_HP = " (" + "d".join( str(z) for z in (self.first + math_floor((self.lvl - 1) / 2), self.health_type[1])) + " + " + str( ((10 + self.health_type[0]) * self.first) + math_floor(self.lvl / 2) * self.health_type[1]) + ")" return str_HP
def caster_init_(self): self.caster_kind = "Ancestor Speaker" self.caster_lvl = math_floor(1 * self.first / 2 + self.caster_type * self.lvl) self.school_lvl = math_floor(1 * self.first / 2 + self.school_type * self.lvl) self.school_skills = self.school_lvl * 2 self.MP = 5 * self.first + 2 * self.caster_lvl
def caster_init_(self): self.caster_kind = "Enlightened" self.caster_lvl = 1 * self.first + math_floor( self.caster_type * self.lvl) self.school_lvl = 1 * self.first + math_floor( self.school_type * self.lvl) self.school_skills = self.school_lvl * 2 self.MP = 6 * self.first + 3 * self.caster_lvl
def calculate_saves(self): self.soul = 10 + math_floor( self.lvl * TemplateClass.medium_save) #max soul + mod self.mind = 10 + math_floor( self.lvl * TemplateClass.poor_save) #max mind + mod self.mobil = 10 + math_floor( self.lvl * TemplateClass.good_save) #max mobil + mod self.tough = 10 + math_floor( self.lvl * TemplateClass.great_save) #max tough + mod
def floor(value, mod=1): """ x == floor(x, a) + mod(x, a) FOR ALL a, x RETURN None WHEN GIVEN INVALID ARGUMENTS """ if value == None: return None elif mod <= 0: return None elif mod == 1: return int(math_floor(value)) elif is_integer(mod): return int(math_floor(value / mod)) * mod else: return math_floor(value / mod) * mod
def floor(self): """ Returns: floor: Unit The unit rounded down to the nearest integer """ return Unit(math_floor(self.magnitude), self.unit)
def ceiling(value, mod=1): """ RETURN SMALLEST INTEGER GREATER THAN value """ if value == None: return None mod = int(mod) v = int(math_floor(value + mod)) return v - (v % mod)
def __init__(self, lvl, first=False, HP=None): self.get_cls_var() self.lvl = lvl self.first = first if HP == None: first_HP = (first * (10 + self.health_type[0] + self.randHP())) even_HP = math_floor(lvl / 2) * self.health_type[0] odd_HP = sum( [self.randHP() for _ in range(math_floor((lvl - 1) / 2))]) self.HP = first_HP + even_HP + odd_HP #first + even + odd else: if lvl % 2: self.HP += self.randHP() else: self.HP += self.health_type[0] self.calculate_saves() self.endu_times = 1 * first + math_floor( (lvl - 1) / 2) #endurance modifier self.attack = math_floor(lvl * self.attack_type) #base attack self.defence = math_floor(self.defence_type * lvl) #defense vs effects self.skill = self.skills_type * lvl # + INT MOD self.get_table() self.caster_init_()
def dertermine_top_icon(self): if not self.items: self._change_top('default') return total = 0 num_items = len(self.items) for i, _item in enumerate(self.items): # Use first 'icon' for the top icon(so no last_build indicator) item = self.items[_item].split('-')[0] if 'default' is self.config.reverse_score_map[item]: continue total += self.config.reverse_score_map[item] end = int(math_floor(total / num_items)) icon = end / 20 * 20 self._change_top(self.config.score_map[icon])
def random_mini_batches(X, Y, mini_batch_size=64, seed=0): """ Creates a list of random mini-batches from (X, Y) Arguments: X -- input data, of shape (input size, number of examples) Y -- true output vector, of shape (1, number of examples) mini_batch_size -- size of the mini-batches, integer Returns: mini_batches -- list of synchronous (mini_batch_X, mini_batch_Y) """ np.random.seed(seed) # To make your "random" mini-batches the same as ours m = X.shape[1] # number of training examples mini_batches = [] # Step 1: Shuffle (X, Y) permutation = list(np.random.permutation(m)) shuffled_X = X[:, permutation] shuffled_Y = Y[:, permutation].reshape((1, m)) # Step 2: Partition (shuffled_X, shuffled_Y). Minus the end case. num_complete_minibatches = math_floor( m / mini_batch_size ) # number of mini batches of size mini_batch_size in your partitionning for k in range(0, num_complete_minibatches): mini_batch_X = shuffled_X[:, k * mini_batch_size:(k + 1) * mini_batch_size] mini_batch_Y = shuffled_Y[:, k * mini_batch_size:(k + 1) * mini_batch_size] mini_batch = (mini_batch_X, mini_batch_Y) mini_batches.append(mini_batch) # Handling the end case (last mini-batch < mini_batch_size) if m % mini_batch_size != 0: mini_batch_X = shuffled_X[:, num_complete_minibatches * mini_batch_size:m] mini_batch_Y = shuffled_Y[:, num_complete_minibatches * mini_batch_size:m] mini_batch = (mini_batch_X, mini_batch_Y) mini_batches.append(mini_batch) return mini_batches
def calculate_HD(self): if self.eq.armor.slot_name == "Armor": ar = self.eq.armor.HD else: ar = 0 if self.eq.hands[1].slot_name == "Shield": sh = self.eq.hands[1].HD or 0 else: sh = 0 ag = self.get_core_modifier("AGY") it = self.get_core_modifier("ITU") ba = math_floor(self.defence_base / 2) #Ba|Ar |Sh|Ag |It |Ma|Na|Ba |Si|Fe|An temp_modifier = [1, ar, 0, ag, it, 0, 0, ba, 0, 0, 0] self.HD = { x: [i * j for i, j in zip(temp_modifier, y)] for x, y in hit_difficulty_set.items() }
def best_tick(largest, most_ticks): """Generate a 'nice' interval for graphs given a max value and most number of intervals Arguments: largest: - A number which represents the greatest amount that needs to be displayed. most_ticks: - A integer which represents the most number of intervals that should be displayed. Returns: A number: that is the best unit of increment for the input data. """ minimum = largest / most_ticks#minimum increment magnitude = 10 ** math_floor(math_log(minimum, 10)) residual = minimum / magnitude#most significant digit of the minimum increment if residual > 5: tick = 10 * magnitude elif residual > 2: tick = 5 * magnitude elif residual > 1: tick = 2 * magnitude else: tick = magnitude return tick
def get_core_modifier(self, name): if name in stats_name: return math_floor((self.stats[name] / 2))
def round_half_up(n, decimals=0): from math import floor as math_floor multiplier = 10**decimals return math_floor(n * multiplier + 0.5) / multiplier
def get_floor_by_position(self, position): floor_idx = math_floor(position / self.floor_dist + .01) return self.floors[floor_idx]