示例#1
0
文件: serf.py 项目: ChadSki/woodchuck
 def no_profession(self):
     if self.target_coords is not None:
         changes = utilities.get_vector(self, self.target_coords[0], self.target_coords[1], self.rect.x + 15, self.rect.y + 22)
         self.change_x = changes[0]
         self.change_y = changes[1]
         if not self.collide_check():
             self.move(self.current_map)
示例#2
0
    def eat(self, current_room):
        if self.target_coin is None or \
           self.target_coin not in current_room.entity_list[coin.Coin]:
            self.target_coin = self.pick_target(self.neighbors, self.current_room)

        changes = utilities.get_vector(self, self.target_coin.rect.x + 2, self.target_coin.rect.y + 2, self.rect.x + 7, self.rect.y + 7)
        self.change_x = changes[0]
        self.change_y = changes[1]
        # pygame.sprite.spritecollide(self, self.current_room.entity_list[coin.Coin], True)
        self.coin_pickup(self.current_room)
示例#3
0
    def go_home(self):
        home_x = self.pit.rect.x + 15
        home_y = self.pit.rect.y + 15

        home_dist = utilities.distance((home_x), (home_y), self.rect.x, self.rect.y)
        if home_dist > 38:
            changes = utilities.get_vector(self, home_x, home_y, self.rect.x + 10, self.rect.y + 10)
            self.change_x = changes[0]
            self.change_y = changes[1]
        else:
            self.give_coins()

        self.coin_pickup(self.current_room)
示例#4
0
 def chase(self, current_room):
     changes = utilities.get_vector(self, self.target_goblin.rect.x + 7, self.target_goblin.rect.y + 7, self.rect.x + 10, self.rect.y + 10)
     self.change_x = changes[0]
     self.change_y = changes[1]
     goblin_hit_list = []
     for each in self.neighbors:
         neighbor_hit_list = (pygame.sprite.spritecollide(self, each.entity_list[goblin.Goblin], True))
         goblin_hit_list = goblin_hit_list + neighbor_hit_list
     for each in goblin_hit_list:
         self.goblins_eaten += 1
         self.lifetime_goblins_eaten += 1
         self.ticks_without_food = 0
         current_room.deaths_by_ogre += 1
         current_room.coins_on_death.append(each.lifetime_coins)
         current_room.death_ages.append(each.age)
         each.expire()
         self.killing = 'Yes'
         self.killframe = 0
示例#5
0
 def fire(self, current_level, pos, player_x, player_y, player):
     origin_modifier = {6: (30, -10), 5: (55, 5), 4: (55, 15), 3: (60, 20), 2: (50, 30), 1: (45, 40), 0: (10, 60)}
     new_projectile = projectiles.Bullet()
     vector_mod = origin_modifier[player.arm_state]
     new_projectile.rect.x = player_x + vector_mod[0]
     new_projectile.rect.y = player_y + vector_mod[1]
     x = pos[0] + 15
     y = pos[1] + 15
     if pos[0] < player_x + 65:
         x = player_x + 65
     assets.pistol_shot_sound.play()
     vector = utilities.get_vector(new_projectile, x, y, new_projectile.rect.x, new_projectile.rect.y)
     new_projectile.change_x = vector[0]
     new_projectile.change_y = vector[1]
     current_level.projectiles_list.add(new_projectile)
     player.firing = self.automatic
     self.current_mag -= 1
     if self.current_mag == 0:
         self.loaded = False
示例#6
0
        def go_home(self, home_x, home_y):

            home_dist = utilities.distance((home_x + 20), (home_y + 15), self.rect.x + 10, self.rect.y + 10)
            if home_dist > 75:
                changes = utilities.get_vector(self, self.home_hut.rect.x + 20, self.home_hut.rect.y + 15, self.rect.x + 10, self.rect.y + 10)
                self.change_x = changes[0]
                self.change_y = changes[1]
            else:
                action = random.randint(0, 800)
                if action <= 10:
                    self.change_x = (self.speed / 2)
                elif 10 < action <= 20:
                    self.change_x = -(self.speed / 2)
                elif 20 < action <= 30:
                    self.change_y = (self.speed / 2)
                elif 30 < action <= 40:
                    self.change_y = -(self.speed / 2)
                elif action > 750:
                    self.change_x = 0
                    self.change_y = 0
df_main = pd.read_csv(file_path)
w2v_model = KeyedVectors.load_word2vec_format(w2v_path, binary=True)
# w2v_model = KeyedVectors.load(w2v_path)
sid = SentimentIntensityAnalyzer()

y = df_main['User'].values.tolist()
X0 = [x.lower() if str(x) != "nan" else "" for x in df_main['Clean Tweets'].tolist()]


Zipped_xy = [[*x] for x in zip(*[(xx, yy) for xx, yy in zip(X0, y) if int(yy) in valid_users])]

y = np.array(Zipped_xy[1])
cv = CountVectorizer(max_features=3696, ngram_range=(1, 2))
cv.fit(Zipped_xy[0] + X_test)
# w2v
X1 = np.array([get_vector(x, w2v_model) for x in Zipped_xy[0]])
# Adding Sentiment
X2 = np.array([list(sid.polarity_scores(x).values()) if str(x) != "nan" else [0, 0, 0, 0] for x in Zipped_xy[0]])
# CV
X3 = cv.transform(Zipped_xy[0]).toarray()

X = np.array([np.append(x1, x2, axis=0) for x1, x2 in zip(X1, X2)])
X = np.array([np.append(x1, x2, axis=0) for x1, x2 in zip(X, X3)])
print(X.shape, y.shape)

"""
TRAIN
"""

X, y = shuffle(X, y, random_state=0)
CLF = ClassifierClass(vm=w2v_model, vm2=cv)
示例#8
0
 def get_vector(self):
     (self.change_x, self.change_y) = utilities.get_vector(self, self.sprite.rect.x + 19, self.sprite.rect.y, self.target_x, self.target_y)