mirror of
https://github.com/csd4ni3l/fleet-commander.git
synced 2026-01-01 04:23:47 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a18299e0d | ||
|
|
0a52c68656 | ||
|
|
d177577058 | ||
|
|
6deb6c0b8d | ||
|
|
6e18ac3ae4 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -180,4 +180,5 @@ test*.py
|
|||||||
logs/
|
logs/
|
||||||
logs
|
logs
|
||||||
settings.json
|
settings.json
|
||||||
training_logs
|
training_logs
|
||||||
|
*.bck*
|
||||||
@@ -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.
|
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.
|
||||||
|
|
||||||
|
[](https://youtu.be/AtjB0Vr-E7U)
|
||||||
|
|
||||||
# Install steps:
|
# Install steps:
|
||||||
|
|
||||||
|
|||||||
BIN
invader_agent.zip
Normal file
BIN
invader_agent.zip
Normal file
Binary file not shown.
@@ -93,12 +93,6 @@ settings = {
|
|||||||
"VSync": {"type": "bool", "config_key": "vsync", "default": True},
|
"VSync": {"type": "bool", "config_key": "vsync", "default": True},
|
||||||
"FPS Limit": {"type": "slider", "min": 0, "max": 480, "config_key": "fps_limit", "default": 60},
|
"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": {
|
"Miscellaneous": {
|
||||||
"Discord RPC": {"type": "bool", "config_key": "discord_rpc", "default": True},
|
"Discord RPC": {"type": "bool", "config_key": "discord_rpc", "default": True},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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_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')))
|
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")
|
enemy_texture = arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'enemy.png'))
|
||||||
player_texture = arcade.load_texture("assets/graphics/player.png")
|
player_texture = arcade.load_texture(os.path.join(_assets_dir, 'graphics', 'player.png'))
|
||||||
@@ -178,7 +178,7 @@ class SpaceInvadersEnv(gym.Env):
|
|||||||
nearest = self._nearest_enemy()
|
nearest = self._nearest_enemy()
|
||||||
alignment = abs(nearest.center_x - self.player.center_x) / self.width
|
alignment = abs(nearest.center_x - self.player.center_x) / self.width
|
||||||
if alignment < 0.025:
|
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.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)
|
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)
|
self.bullets.append(b)
|
||||||
|
|
||||||
if self.player_alive:
|
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:
|
if self.player.center_x < edge_threshold or self.player.center_x > self.width - edge_threshold:
|
||||||
reward -= 0.03
|
reward -= 0.03
|
||||||
|
|
||||||
reward -= 0.0025
|
reward -= 0.01
|
||||||
|
|
||||||
obs = self._obs()
|
obs = self._obs()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import logging, arcade, arcade.gui, sys, traceback
|
import logging, arcade, traceback, pyglet.display
|
||||||
|
|
||||||
from utils.constants import menu_background_color
|
|
||||||
|
|
||||||
import pyglet.info, pyglet.event
|
|
||||||
|
|
||||||
def dump_platform():
|
def dump_platform():
|
||||||
import platform
|
import platform
|
||||||
@@ -38,29 +34,6 @@ def print_debug_info():
|
|||||||
logging.debug('########################## DEBUG INFO ##########################')
|
logging.debug('########################## DEBUG INFO ##########################')
|
||||||
logging.debug('')
|
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):
|
def on_exception(*exc_info):
|
||||||
logging.error(f"Unhandled exception:\n{''.join(traceback.format_exception(exc_info[1], limit=None))}")
|
logging.error(f"Unhandled exception:\n{''.join(traceback.format_exception(exc_info[1], limit=None))}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user