Found huge bug, updated some basic stuff
BIN
.DS_Store
vendored
BIN
agents/ppo/.DS_Store
vendored
Normal file
BIN
assets/.DS_Store
vendored
Normal file
BIN
assets/graphics/.DS_Store
vendored
Normal file
BIN
assets/graphics/particles/.DS_Store
vendored
Normal file
BIN
assets/map/.DS_Store
vendored
Normal file
|
@ -18,8 +18,8 @@
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,393,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,393,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,500,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,400,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,400,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,393,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,393,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
-1,-1,-1,-1,-1,-1,390,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||||
|
|
|
63
camera.py
|
@ -11,9 +11,7 @@ class Camera(pygame.sprite.Group):
|
||||||
|
|
||||||
# General Setup
|
# General Setup
|
||||||
self.display_surface = pygame.display.get_surface()
|
self.display_surface = pygame.display.get_surface()
|
||||||
self.half_width = self.display_surface.get_size()[0] // 2
|
self.display_size = self.display_surface.get_size()
|
||||||
self.half_height = self.display_surface.get_size()[1] // 2
|
|
||||||
self.offset = pygame.math.Vector2(100, 200)
|
|
||||||
|
|
||||||
self.floor_surf = pygame.image.load(
|
self.floor_surf = pygame.image.load(
|
||||||
import_assets(
|
import_assets(
|
||||||
|
@ -25,32 +23,45 @@ class Camera(pygame.sprite.Group):
|
||||||
|
|
||||||
self.floor_rect = self.floor_surf.get_rect(topleft=(0, 0))
|
self.floor_rect = self.floor_surf.get_rect(topleft=(0, 0))
|
||||||
|
|
||||||
def custom_draw(self, entity):
|
self.calculate_scale()
|
||||||
|
|
||||||
self.sprite_type = entity.sprite_type
|
def calculate_scale(self):
|
||||||
# Getting the offset
|
map_width, map_height = self.floor_rect.size
|
||||||
if hasattr(entity, 'animation'):
|
screen_width, screen_height = self.display_size
|
||||||
self.offset.x = entity.animation.rect.centerx - self.half_width
|
|
||||||
|
|
||||||
self.offset.y = entity.animation.rect.centery - self.half_height
|
# Calculating the scale to fit the map on the screen
|
||||||
|
self.scale = min(screen_width / map_width, screen_height / map_height)
|
||||||
|
self.scaled_floor_surf = pygame.transform.scale(self.floor_surf,
|
||||||
|
(int(map_width * self.scale),
|
||||||
|
int(map_height * self.scale)))
|
||||||
|
self.scaled_floor_rect = self.scaled_floor_surf.get_rect()
|
||||||
|
|
||||||
else:
|
def custom_draw(self):
|
||||||
self.offset.x = entity.rect.centerx - self.half_width
|
# Drawing the scaled floor
|
||||||
|
self.display_surface.blit(
|
||||||
self.offset.y = entity.rect.centery - self.half_height
|
self.scaled_floor_surf, self.scaled_floor_rect.topleft)
|
||||||
|
|
||||||
# Drawing the floor
|
|
||||||
floor_offset_pos = self.floor_rect.topleft - self.offset
|
|
||||||
self.display_surface.blit(self.floor_surf, floor_offset_pos)
|
|
||||||
|
|
||||||
for sprite in sorted(self.sprites(),
|
|
||||||
key=lambda sprite: sprite.animation.rect.centery
|
|
||||||
if hasattr(sprite, 'animation')
|
|
||||||
else sprite.rect.centery):
|
|
||||||
|
|
||||||
|
for sprite in sorted(self.sprites(), key=lambda sprite: sprite.rect.centery if not hasattr(sprite, 'animation') else sprite.animation.rect.centery):
|
||||||
|
# Check for sprites with 'animation' attribute
|
||||||
if hasattr(sprite, 'animation'):
|
if hasattr(sprite, 'animation'):
|
||||||
offset_pos = sprite.animation.rect.topleft - self.offset
|
scaled_sprite_image = pygame.transform.scale(sprite.animation.image,
|
||||||
self.display_surface.blit(sprite.animation.image, offset_pos)
|
(int(sprite.animation.rect.width * self.scale),
|
||||||
|
int(sprite.animation.rect.height * self.scale)))
|
||||||
|
scaled_position = (int(sprite.animation.rect.x * self.scale),
|
||||||
|
int(sprite.animation.rect.y * self.scale))
|
||||||
|
for sprite in sorted(self.sprites(), key=lambda sprite: sprite.rect.centery if not hasattr(sprite, 'animation') else sprite.animation.rect.centery):
|
||||||
|
# Check for sprites with 'animation' attribute
|
||||||
|
if hasattr(sprite, 'animation'):
|
||||||
|
scaled_sprite_image = pygame.transform.scale(sprite.animation.image,
|
||||||
|
(int(sprite.animation.rect.width * self.scale),
|
||||||
|
int(sprite.animation.rect.height * self.scale)))
|
||||||
|
scaled_position = (int(sprite.animation.rect.x * self.scale),
|
||||||
|
int(sprite.animation.rect.y * self.scale))
|
||||||
else:
|
else:
|
||||||
offset_pos = sprite.rect.topleft - self.offset
|
scaled_sprite_image = pygame.transform.scale(sprite.image,
|
||||||
self.display_surface.blit(sprite.image, offset_pos)
|
(int(sprite.rect.width * self.scale),
|
||||||
|
int(sprite.rect.height * self.scale)))
|
||||||
|
scaled_position = (int(sprite.rect.x * self.scale),
|
||||||
|
int(sprite.rect.y * self.scale))
|
||||||
|
|
||||||
|
self.display_surface.blit(scaled_sprite_image, scaled_position)
|
||||||
|
|
BIN
configs/.DS_Store
vendored
Normal file
BIN
effects/.DS_Store
vendored
Normal file
BIN
entities/.DS_Store
vendored
Normal file
|
@ -148,14 +148,6 @@ class Player(pygame.sprite.Sprite):
|
||||||
|
|
||||||
def get_current_state(self):
|
def get_current_state(self):
|
||||||
|
|
||||||
def fermi(x, a):
|
|
||||||
# Used for rescaling features
|
|
||||||
return 1 / (np.exp((x - a)) + 1)
|
|
||||||
|
|
||||||
def maxwell(x, a):
|
|
||||||
# Used for rescaling features
|
|
||||||
return 1 / np.exp((x - a) / a)
|
|
||||||
|
|
||||||
if self.distance_direction_from_enemy != []:
|
if self.distance_direction_from_enemy != []:
|
||||||
sorted_distances = sorted(
|
sorted_distances = sorted(
|
||||||
self.distance_direction_from_enemy, key=lambda x: x[0])
|
self.distance_direction_from_enemy, key=lambda x: x[0])
|
||||||
|
@ -166,32 +158,11 @@ class Player(pygame.sprite.Sprite):
|
||||||
|
|
||||||
self.action_features = [self._input.action]
|
self.action_features = [self._input.action]
|
||||||
|
|
||||||
self.reward = [
|
self.reward = self.stats.exp\
|
||||||
np.log(1 + self.stats.exp) if self.stats.exp >= 0 else -10,
|
+ self.stats.health/self.stats.stats['health'] - 1\
|
||||||
|
- nearest_dist/np.sqrt(np.sum(self.map_edge))\
|
||||||
fermi(nearest_dist, 300),
|
- nearest_enemy.stats.health/nearest_enemy.stats.monster_info['health']\
|
||||||
|
- 2*len(self.distance_direction_from_enemy)/self.max_num_enemies
|
||||||
fermi(
|
|
||||||
nearest_enemy.stats.health,
|
|
||||||
nearest_enemy.stats.monster_info['health']
|
|
||||||
),
|
|
||||||
|
|
||||||
maxwell(
|
|
||||||
len(self.distance_direction_from_enemy),
|
|
||||||
self.max_num_enemies
|
|
||||||
) - 1,
|
|
||||||
|
|
||||||
- fermi(
|
|
||||||
self.stats.health,
|
|
||||||
self.stats.stats['health']
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
# self.reward = self.stats.exp\
|
|
||||||
# + self.stats.health/self.stats.stats['health'] - 1\
|
|
||||||
# - nearest_dist/np.sqrt(np.sum(self.map_edge))\
|
|
||||||
# - nearest_enemy.stats.health/nearest_enemy.stats.monster_info['health']\
|
|
||||||
# - 2*len(self.distance_direction_from_enemy)/self.max_num_enemies
|
|
||||||
|
|
||||||
self.state_features = [
|
self.state_features = [
|
||||||
self.animation.rect.center[0]/self.map_edge[0],
|
self.animation.rect.center[0]/self.map_edge[0],
|
||||||
|
@ -204,10 +175,8 @@ class Player(pygame.sprite.Sprite):
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
enemy_states = []
|
|
||||||
|
|
||||||
for distance, direction, enemy in self.distance_direction_from_enemy:
|
for distance, direction, enemy in self.distance_direction_from_enemy:
|
||||||
enemy_states.extend([
|
self.state_features.extend([
|
||||||
|
|
||||||
distance/np.sqrt(np.sum(self.map_edge)),
|
distance/np.sqrt(np.sum(self.map_edge)),
|
||||||
|
|
||||||
|
@ -215,14 +184,12 @@ class Player(pygame.sprite.Sprite):
|
||||||
|
|
||||||
direction[1],
|
direction[1],
|
||||||
|
|
||||||
nearest_enemy.stats.health /
|
enemy.stats.health /
|
||||||
nearest_enemy.stats.monster_info['health'],
|
enemy.stats.monster_info['health'],
|
||||||
|
|
||||||
enemy.stats.exp,
|
enemy.stats.exp,
|
||||||
])
|
])
|
||||||
|
|
||||||
self.state_features.extend(enemy_states)
|
|
||||||
|
|
||||||
if hasattr(self, 'num_features'):
|
if hasattr(self, 'num_features'):
|
||||||
while len(self.state_features) < self.num_features:
|
while len(self.state_features) < self.num_features:
|
||||||
self.state_features.append(0)
|
self.state_features.append(0)
|
||||||
|
@ -255,7 +222,7 @@ class Player(pygame.sprite.Sprite):
|
||||||
self)
|
self)
|
||||||
|
|
||||||
self.agent.remember(self.state_features, action,
|
self.agent.remember(self.state_features, action,
|
||||||
probs, value, self.stats.exp, self.is_dead())
|
probs, value, self.reward, self.is_dead())
|
||||||
|
|
||||||
self.get_current_state()
|
self.get_current_state()
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,5 @@ class Terrain(pygame.sprite.Sprite):
|
||||||
topleft=(position[0], position[1] - TILESIZE))
|
topleft=(position[0], position[1] - TILESIZE))
|
||||||
else:
|
else:
|
||||||
self.rect = self.image.get_rect(topleft=position)
|
self.rect = self.image.get_rect(topleft=position)
|
||||||
|
|
||||||
self.hitbox = self.rect.inflate(HITBOX_OFFSET[sprite_type])
|
self.hitbox = self.rect.inflate(HITBOX_OFFSET[sprite_type])
|
||||||
|
|
BIN
figures/.DS_Store
vendored
Normal file
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
20
game.py
|
@ -1,16 +1,13 @@
|
||||||
import os
|
|
||||||
|
|
||||||
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import pygame
|
|
||||||
|
|
||||||
from level import Level
|
|
||||||
|
|
||||||
from configs.system.window_config import WIDTH,\
|
from configs.system.window_config import WIDTH,\
|
||||||
HEIGHT,\
|
HEIGHT,\
|
||||||
WATER_COLOR,\
|
WATER_COLOR,\
|
||||||
FPS
|
FPS
|
||||||
|
from level import Level
|
||||||
|
import pygame
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
|
@ -44,8 +41,6 @@ class Game:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
self.clock = pygame.time.Clock()
|
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
self.quit()
|
self.quit()
|
||||||
|
@ -55,10 +50,9 @@ class Game:
|
||||||
|
|
||||||
self.screen.fill(WATER_COLOR)
|
self.screen.fill(WATER_COLOR)
|
||||||
|
|
||||||
self.level.run('observer', self.clock.get_fps())
|
self.level.run()
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
self.clock.tick(FPS)
|
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
|
|
@ -108,24 +108,5 @@ class UI:
|
||||||
|
|
||||||
self.display_surface.blit(magic_surf, magic_rect)
|
self.display_surface.blit(magic_surf, magic_rect)
|
||||||
|
|
||||||
def display(self, player):
|
def display(self):
|
||||||
if player.sprite_type == 'player':
|
self.show_exp(-1)
|
||||||
self.show_bar(
|
|
||||||
player.stats.health,
|
|
||||||
player.stats.stats['health'],
|
|
||||||
self.health_bar_rect,
|
|
||||||
HEALTH_COLOR)
|
|
||||||
|
|
||||||
self.show_bar(
|
|
||||||
player.stats.energy,
|
|
||||||
player.stats.stats['energy'],
|
|
||||||
self.energy_bar_rect,
|
|
||||||
ENERGY_COLOR)
|
|
||||||
|
|
||||||
self.show_exp(player.stats.exp)
|
|
||||||
self.weapon_overlay(player._input.combat.weapon_index,
|
|
||||||
player._input.can_rotate_weapon)
|
|
||||||
self.magic_overlay(player._input.combat.magic_index,
|
|
||||||
player._input.can_swap_magic)
|
|
||||||
if player.sprite_type == 'camera':
|
|
||||||
self.show_exp(player.exp)
|
|
||||||
|
|
95
level.py
|
@ -85,50 +85,41 @@ class Level:
|
||||||
|
|
||||||
elif col != '700':
|
elif col != '700':
|
||||||
Terrain((x, y),
|
Terrain((x, y),
|
||||||
[self.obstacle_sprites,
|
[self.obstacle_sprites],
|
||||||
self.visible_sprites],
|
|
||||||
'invisible')
|
'invisible')
|
||||||
elif col == '700' and self.n_players > 1:
|
elif col == '700' and self.n_players > 1:
|
||||||
print(f"Prison set at:{(x, y)}")
|
print(f"Prison set at:{(x, y)}")
|
||||||
# Generate grass
|
# Generate grass
|
||||||
# if style == 'grass':
|
if style == 'grass':
|
||||||
# random_grass_image = choice(self.graphics['grass'])
|
random_grass_image = choice(self.graphics['grass'])
|
||||||
#
|
|
||||||
# Terrain((x, y), [
|
Terrain((x, y), [
|
||||||
# self.visible_sprites,
|
self.visible_sprites,
|
||||||
# self.obstacle_sprites,
|
self.obstacle_sprites,
|
||||||
# self.attackable_sprites
|
self.attackable_sprites
|
||||||
# ],
|
],
|
||||||
# 'grass',
|
'grass',
|
||||||
# random_grass_image)
|
random_grass_image)
|
||||||
|
|
||||||
# Generate objects like trees and statues
|
# Generate objects like trees and statues
|
||||||
# if style == 'objects':
|
if style == 'objects':
|
||||||
# surface = self.graphics['objects'][int(col)]
|
surface = self.graphics['objects'][int(col)]
|
||||||
# Terrain((x, y), [
|
Terrain((x, y), [
|
||||||
# self.visible_sprites,
|
self.visible_sprites,
|
||||||
# self.obstacle_sprites
|
self.obstacle_sprites
|
||||||
# ],
|
],
|
||||||
# 'object',
|
'object',
|
||||||
# surface)
|
surface)
|
||||||
|
|
||||||
# Generate observer, players and monsters
|
# Generate observer, players and monsters
|
||||||
if style == 'entities':
|
if style == 'entities':
|
||||||
|
|
||||||
# Generate observer
|
|
||||||
if col == '500':
|
|
||||||
self.observer = Observer(
|
|
||||||
(x, y),
|
|
||||||
[self.visible_sprites]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Generate player(s)
|
# Generate player(s)
|
||||||
# TODO: Make a way to generate players in random locations
|
if col == '400':
|
||||||
elif col == '400':
|
|
||||||
self.possible_player_locations.append((x, y))
|
self.possible_player_locations.append((x, y))
|
||||||
# Monster generation
|
|
||||||
|
|
||||||
else:
|
# Monster generation
|
||||||
|
elif col in ['390', '391', '392', '393']:
|
||||||
if col == '390':
|
if col == '390':
|
||||||
monster_name = 'bamboo'
|
monster_name = 'bamboo'
|
||||||
elif col == '391':
|
elif col == '391':
|
||||||
|
@ -171,28 +162,22 @@ class Level:
|
||||||
if int(col) != -1:
|
if int(col) != -1:
|
||||||
x = col_index * TILESIZE
|
x = col_index * TILESIZE
|
||||||
y = row_index * TILESIZE
|
y = row_index * TILESIZE
|
||||||
# # Regenerate grass
|
# Regenerate grass
|
||||||
# if style == 'grass':
|
if style == 'grass':
|
||||||
# random_grass_image = choice(
|
random_grass_image = choice(
|
||||||
# self.graphics['grass'])
|
self.graphics['grass'])
|
||||||
#
|
|
||||||
# Terrain((x, y), [
|
Terrain((x, y), [
|
||||||
# self.visible_sprites,
|
self.visible_sprites,
|
||||||
# self.obstacle_sprites,
|
self.obstacle_sprites,
|
||||||
# self.attackable_sprites
|
self.attackable_sprites
|
||||||
# ],
|
],
|
||||||
# 'grass',
|
'grass',
|
||||||
# random_grass_image)
|
random_grass_image)
|
||||||
|
|
||||||
if style == 'entities':
|
if style == 'entities':
|
||||||
|
|
||||||
if col == '500':
|
if col in ['390', '391', '392', '393']:
|
||||||
continue
|
|
||||||
|
|
||||||
if col == '400':
|
|
||||||
continue
|
|
||||||
|
|
||||||
else:
|
|
||||||
if col == '390':
|
if col == '390':
|
||||||
monster_name = 'bamboo'
|
monster_name = 'bamboo'
|
||||||
elif col == '391':
|
elif col == '391':
|
||||||
|
@ -287,12 +272,10 @@ class Level:
|
||||||
def toggle_pause(self):
|
def toggle_pause(self):
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
|
|
||||||
def run(self, who='observer', fps='v0.9'):
|
def run(self):
|
||||||
# Draw the game
|
# Draw the game
|
||||||
self.visible_sprites.custom_draw(self.observer)
|
self.visible_sprites.custom_draw()
|
||||||
self.ui.display(self.observer)
|
self.ui.display()
|
||||||
|
|
||||||
debug(f"{fps}")
|
|
||||||
|
|
||||||
if not self.paused:
|
if not self.paused:
|
||||||
# Update the game
|
# Update the game
|
||||||
|
@ -310,7 +293,7 @@ class Level:
|
||||||
|
|
||||||
for player in self.player_sprites:
|
for player in self.player_sprites:
|
||||||
if player.is_dead():
|
if player.is_dead():
|
||||||
print(f"\nPlayer {player.player_id} is dead")
|
print(f"\nPlayer {player.player_id} is dead\n")
|
||||||
player.stats.exp = -10
|
player.stats.exp = -10
|
||||||
player.update()
|
player.update()
|
||||||
self.dead_players[player.player_id] = player.is_dead()
|
self.dead_players[player.player_id] = player.is_dead()
|
||||||
|
|
|
@ -182,8 +182,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
for player in game.level.player_sprites:
|
for player in game.level.player_sprites:
|
||||||
|
|
||||||
episode_reward[player.player_id][step] = np.mean(
|
episode_reward[player.player_id][step] = player.reward
|
||||||
player.reward)
|
|
||||||
|
|
||||||
if (step % horizon == 0 and step != 0) or player.is_dead():
|
if (step % horizon == 0 and step != 0) or player.is_dead():
|
||||||
|
|
||||||
|
|