def __init__(self,techID, name, sprite_pos, move_border, attribute_prev,worn_equipment, AI_style, corps_style, corps_lvl, move_groups, personal_id, behavior, attack_were, possible_effect, effect_duration, effect_probability, message, anger = 'None', anger_monster = 'None', def_flee = 0, def_teleport= 0, def_potion = 0, range_shoot = 0, close_steal = 0, close_flame = 0, num_special = 2): self.techID = techID self.name = name self.sprite_pos = sprite_pos self.move_border = move_border self.lvl = 0 self.attribute_prev = attribute_prev self.basic_attribute = attribute(2,2,2,2,2,1,2) self.lp = self.basic_attribute.max_lp self.worn_equipment = worn_equipment self.AI_style = AI_style self.corps_style = corps_style self.corps_lvl = corps_lvl self.move_groups = move_groups self.personal_id = personal_id self.behavior = behavior self.attack_were = attack_were self.possible_effect = possible_effect self.effect_duration = effect_duration self.effect_probability = effect_probability self.message = message self.anger = anger self.anger_monster = anger_monster self.def_flee = def_flee self.def_teleport = def_teleport self.def_potion = def_potion self.range_shoot = range_shoot self.close_steal = close_steal self.close_flame = close_flame self.num_special = num_special self.move_done = 0
def __init__(self, techID, name, sprite_pos, move_border, attribute_prev, worn_equipment, AI_style, corps_style, corps_lvl, move_groups, personal_id, behavior, attack_were, possible_effect, effect_duration, effect_probability, message, anger='None', anger_monster='None', def_flee=0, def_teleport=0, def_potion=0, range_shoot=0, close_steal=0, close_flame=0, num_special=2): self.techID = techID self.name = name self.sprite_pos = sprite_pos self.move_border = move_border self.lvl = 0 self.attribute_prev = attribute_prev self.basic_attribute = attribute(2, 2, 2, 2, 2, 1, 2) self.lp = self.basic_attribute.max_lp self.worn_equipment = worn_equipment self.AI_style = AI_style self.corps_style = corps_style self.corps_lvl = corps_lvl self.move_groups = move_groups self.personal_id = personal_id self.behavior = behavior self.attack_were = attack_were self.possible_effect = possible_effect self.effect_duration = effect_duration self.effect_probability = effect_probability self.message = message self.anger = anger self.anger_monster = anger_monster self.def_flee = def_flee self.def_teleport = def_teleport self.def_potion = def_potion self.range_shoot = range_shoot self.close_steal = close_steal self.close_flame = close_flame self.num_special = num_special self.move_done = 0
from monster import monster from attribute import attribute import pickle as p ml = [] techID = 0 #grassland monster ml.append([]) a = attribute(2,2,2,2,2,2,3,0,0,0,0) m=monster(techID,'angry dryade','overworld',0,2,a,'hostile','dryade',1,False,True, 'attack_magic', ('Head','Body','Legs'), None, 0, 0, 'None') techID+=1 ml[0].append(m) a = attribute(1,1,1,1,10,1,3,0,0,0,0) m=monster(techID,'grassland snake','overworld',1,1,a,'hostile','animal',1,False,False, 'attack_melee', ('Legs', 'Feet'), 'poisoned', 10, 20, 'Poison runs trough your veins!') techID+=1 ml[0].append(m) a = attribute(0,0,0,0,0,1,0,0,0,0,0) m=monster(techID,'rabbit','overworld',2,0,a,'flee','animal',1,False,False, 'attack_melee', ('Feet'), None, 0, 0, 'None') techID+=1 ml[0].append(m) a = attribute(1,2,1,2,2,2,3,0,0,0,0) m=monster(techID,'green blob','overworld',3,4,a,'hostile','vanish',5,False,False, 'attack_melee', ('Head','Body','Legs','Feet'), None, 0, 0, 'None') techID+=1 ml[0].append(m) a = attribute(4,3,1,1,2,2,4,0,0,0,0) m=monster(techID,'hill orc','overworld',4,2,a,'hostile','human',2,False,True, 'attack_melee', ('Head','Body','Legs','Feet'), None, 0, 0, 'None') techID+=1 ml[0].append(m) f = file('overworld_monster.data', 'w')
def __init__(self, classe, material, plus, state=100, cursed = 1, known = False, inv_slot = 'equipment'): item.__init__(self,inv_slot) materiales = ('wooden','wooden','wooden','wooden','wooden','wooden', 'tin', 'tin', 'tin', 'tin', 'tin', 'copper', 'copper', 'copper', 'copper', 'steel' ,'steel' ,'steel' ,'titan', 'titan', 'magnicum', '') kind = {'spear' : 1 , 'sword' : 2 , 'axe' : 3 , 'hammer' : 4 ,'shoes' : 1 , 'cuisse' : 2, 'helmet' : 3 , 'armor' : 4, 'wand' : 1, 'rune' : 2, 'rune staff' : 3, 'artefact' : 4, 'ring' : 2, 'amulet' : 4, 'necklace' : 2, 'talisman' : 4, 'pickaxe' : 1} material_boni = {'wooden' : 1, 'tin' : 2, 'copper' : 3, 'steel' : 4, 'titan' : 5, 'magnicum' : 6} self.classe = classe self.material = materiales[material] try: material = material_boni[self.material] except: material = 0 if self.material == 'wooden': self.defensibility_max = 1 elif self.material == 'tin': self.defensibility_max = 2 elif self.material == 'copper': self.defensibility_max = 3 elif self.material == 'steel': self.defensibility_max = 4 elif self.material == 'titan': self.defensibility_max = 5 elif self.material == 'magnicum': self.defensibility_max = 6 else: self.defensibility_max = 1 self.defensibility = self.defensibility_max self.attribute = attribute(0,0,0,0,0,0,0,0,0,0,0) self.cursed = cursed self.known = known self.plus = plus self.state = state self.worn_at = 'NA' if self.classe == 'sword' or self.classe == 'axe' or self.classe == 'hammer' or self.classe == 'spear' or self.classe == 'pickaxe': plus_final = plus + material + kind[self.classe] self.attribute.p_strange += plus_final elif self.classe == 'helmet' or self.classe == 'armor' or self.classe == 'cuisse' or self.classe == 'shoes': plus_final = plus + material + kind[self.classe] self.attribute.p_defense += plus_final elif self.classe == 'wand' or self.classe == 'rune' or self.classe == 'rune staff' or self.classe == 'artefact': plus_final = plus + material + kind[self.classe] self.attribute.m_strange += plus_final elif self.classe == 'amulet' or self.classe == 'ring': plus_final = plus + material + kind[self.classe] self.attribute.m_defense += plus_final elif self.classe == 'talisman' or self.classe == 'necklace': plus_final = plus + material + kind[self.classe] self.attribute.luck += plus_final if self.classe == 'pickaxe': plus_final = plus + material + kind[self.classe] self.attribute.pickaxe_power += plus_final self.attribute.p_strange *= cursed self.attribute.p_defense *= cursed self.attribute.m_strange *= cursed self.attribute.m_defense *= cursed self.attribute.luck *= cursed self.attribute.max_lp *= cursed self.attribute.max_mp *= cursed self.set_name() if self.classe == 'sword' or self.classe == 'axe' or self.classe == 'spear' or self.classe == 'hammer'or self.classe == 'pickaxe': self.worn_at = 'Hold(R)' elif self.classe == 'wand' or self.classe == 'rune' or self.classe == 'rune staff' or self.classe == 'artefact': self.worn_at = 'Hold(L)' elif self.classe == 'helmet': self.worn_at = 'Head' elif self.classe == 'armor': self.worn_at = 'Body' elif self.classe == 'cuisse': self.worn_at = 'Legs' elif self.classe == 'shoes': self.worn_at = 'Feet' elif self.classe == 'ring': self.worn_at = 'Hand' elif self.classe == 'necklace' or self.classe == 'amulet' or self.classe == 'talisman': self.worn_at = 'Neck' if self.classe == 'Nothing': self.attribute = attribute(0,0,0,0,0,0,0,0,0,0,0)
attr_list = [ attribute(0, 'c', [0, 100]), attribute(1, 'd', ['M', 'F']), attribute(2, 'd', ['f', 't']), attribute(3, 'd', ['f', 't']), attribute(4, 'd', ['f', 't']), attribute(5, 'd', ['f', 't']), attribute(6, 'd', ['f', 't']), attribute(7, 'd', ['f', 't']), attribute(8, 'd', ['f', 't']), attribute(9, 'd', ['f', 't']), attribute(10, 'd', ['f', 't']), attribute(11, 'd', ['f', 't']), attribute(12, 'd', ['f', 't']), attribute(13, 'd', ['f', 't']), attribute(14, 'd', ['f', 't']), attribute(15, 'd', ['f', 't']), attribute(16, 'd', ['f', 't']), attribute(17, 'c', [0, 100]), attribute(18, 'd', ['f', 't']), attribute(19, 'c', [0, 100]), attribute(20, 'd', ['f', 't']), attribute(21, 'c', [0, 100]), attribute(22, 'd', ['f', 't']), attribute(23, 'c', [0, 100]), attribute(24, 'd', ['f', 't']), attribute(25, 'c', [0, 100]), attribute(26, 'd', ['f', 't']), attribute(27, 'c', [0, 100]), attribute(28, 'd', ['WEST', 'STMW', 'SVHC', 'SVI', 'SVHD', 'other']), attribute(29, 'd', ['primary hypothyroid', 'compensated hypothyroid', 'secondary hypothyroid', 'negative']) ]
axis=0) with open( globalV.FLAGS.BASEDIR + globalV.FLAGS.APYPATH + 'attribute_names.txt', 'r') as f: allClassAttName = [line.strip() for line in f] # Train Network if globalV.FLAGS.PRE == 1: print('\nPre-train CNN') darknet = darknetModel() darknet.trainDarknet(trX[:trDiv], trY[:trDiv], trX[trDiv:], trY[trDiv:]) elif globalV.FLAGS.PRE == 2: print('\nTrain all network together') attModel = attribute() attModel.trainAtt(trX, trAtt, vX, vAtt) elif globalV.FLAGS.PRE == 3: print('\nTrain classify') # classifier = classify() # classifier.trainClassify(concatAtt_D, np.arange(concatAtt_D.shape[0]), 0.5) g1 = tf.Graph() g2 = tf.Graph() with g1.as_default(): model = attribute() with g2.as_default(): classifier = classify() predictTrainAtt = model.getAttribute(trX) combineAtt = np.concatenate(
print(trX30.shape, trY30.shape, trAtt30.shape) print(vX.shape, vY.shape, vAtt.shape) print(teX.shape, teY.shape, teAtt.shape) # Get all Classes name and attribute name allClassName = np.concatenate((np.concatenate( (trainClass, valClass), axis=0), testClass), axis=0) with open( globalV.FLAGS.BASEDIR + globalV.FLAGS.APYPATH + 'attribute_names.txt', 'r') as f: allClassAttName = [line.strip() for line in f] if globalV.FLAGS.OPT == 2: print('\nTrain Attribute') attModel = attribute(15) attModel.trainAtt(trX70, trY70, vX, vY, teX, teY, concatAtt_D[:15]) elif globalV.FLAGS.OPT == 4: print('\nClassify') g1 = tf.Graph() with g1.as_default(): model = attribute() predY = model.predictClassIndex(trX30, concatAtt_D) print('Train Accuracy = {0:.4f}%'.format( np.mean(np.equal(predY, trY30)) * 100)) predY = model.predictClassIndex(vX, concatAtt_D) print('Val Accuracy = {0:.4f}%'.format( np.mean(np.equal(predY, vY)) * 100)) predY = model.predictClassIndex(teX, concatAtt_D)