Compare commits

5 Commits
latest ... main

Author SHA1 Message Date
csd4ni3l
1a18299e0d update utils.py to latest template version 2025-12-13 15:52:10 +01:00
csd4ni3l
0a52c68656 fix texture loading, remove sound settings 2025-11-17 16:12:10 +01:00
csd4ni3l
d177577058 Add demo video 2025-11-17 16:04:29 +01:00
csd4ni3l
6deb6c0b8d update README model number 2025-11-17 15:46:28 +01:00
csd4ni3l
6e18ac3ae4 add better model, improve rewards 2025-11-17 15:44:42 +01:00
7 changed files with 11 additions and 41 deletions

3
.gitignore vendored
View File

@@ -180,4 +180,5 @@ test*.py
logs/
logs
settings.json
training_logs
training_logs
*.bck*

View File

@@ -4,7 +4,9 @@ It uses AI (Reinforcement Learning) for the Player(s), and You, the Enemy has to
I know the game is too easy and is too simple, but please understand that doing RL isn't the easiest thing ever. I also did this very late.
You can train it yourself, or use the default model(10 million timesteps) which comes with the game.
You can train it yourself, or use the default model(125 million timesteps, took 7 hours) which comes with the game.
[![Demo Video](https://img.youtube.com/vi/AtjB0Vr-E7U/hqdefault.jpg)](https://youtu.be/AtjB0Vr-E7U)
# Install steps:

BIN
invader_agent.zip Normal file

Binary file not shown.

View File

@@ -93,12 +93,6 @@ settings = {
"VSync": {"type": "bool", "config_key": "vsync", "default": True},
"FPS Limit": {"type": "slider", "min": 0, "max": 480, "config_key": "fps_limit", "default": 60},
},
"Sound": {
"Music": {"type": "bool", "config_key": "music", "default": True},
"SFX": {"type": "bool", "config_key": "sfx", "default": True},
"Music Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "music_volume", "default": 50},
"SFX Volume": {"type": "slider", "min": 0, "max": 100, "config_key": "sfx_volume", "default": 50},
},
"Miscellaneous": {
"Discord RPC": {"type": "bool", "config_key": "discord_rpc", "default": True},
},

View File

@@ -7,5 +7,5 @@ _assets_dir = os.path.join(os.path.dirname(_module_dir), 'assets')
button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'button.png')))
button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'button_hovered.png')))
enemy_texture = arcade.load_texture("assets/graphics/enemy.png")
player_texture = arcade.load_texture("assets/graphics/player.png")
enemy_texture = arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'enemy.png'))
player_texture = arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'player.png'))

View File

@@ -178,7 +178,7 @@ class SpaceInvadersEnv(gym.Env):
nearest = self._nearest_enemy()
alignment = abs(nearest.center_x - self.player.center_x) / self.width
if alignment < 0.025:
reward += 0.1
reward += 0.005
self.player.center_x = np.clip(self.player.center_x, 0, self.width)
self.player_speed = (self.player.center_x - prev_x) / max(1e-6, PLAYER_SPEED)
@@ -260,11 +260,11 @@ class SpaceInvadersEnv(gym.Env):
self.bullets.append(b)
if self.player_alive:
edge_threshold = self.width * 0.15
edge_threshold = self.width * 0.1
if self.player.center_x < edge_threshold or self.player.center_x > self.width - edge_threshold:
reward -= 0.03
reward -= 0.0025
reward -= 0.01
obs = self._obs()

View File

@@ -1,8 +1,4 @@
import logging, arcade, arcade.gui, sys, traceback
from utils.constants import menu_background_color
import pyglet.info, pyglet.event
import logging, arcade, traceback, pyglet.display
def dump_platform():
import platform
@@ -38,29 +34,6 @@ def print_debug_info():
logging.debug('########################## DEBUG INFO ##########################')
logging.debug('')
class ErrorView(arcade.gui.UIView):
def __init__(self, message, title):
super().__init__()
self.message = message
self.title = title
def exit(self):
logging.fatal('Exited with error code 1.')
sys.exit(1)
def on_show_view(self):
super().on_show_view()
self.window.set_caption('Fleet Commander - Error')
self.window.set_mouse_visible(True)
self.window.set_exclusive_mouse(False)
arcade.set_background_color(menu_background_color)
msgbox = arcade.gui.UIMessageBox(width=self.window.width / 2, height=self.window.height / 2, message_text=self.message, title=self.title)
msgbox.on_action = lambda _: self.exit()
self.add_widget(msgbox)
def on_exception(*exc_info):
logging.error(f"Unhandled exception:\n{''.join(traceback.format_exception(exc_info[1], limit=None))}")