Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode
virtualenv
venv
.env

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -35,6 +36,7 @@ MANIFEST
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
!dockerfiles/*.spec

# Installer logs
pip-log.txt
Expand Down Expand Up @@ -139,4 +141,4 @@ dmypy.json
.pytype/

# Cython debug symbols
cython_debug/
cython_debug/
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = sphinx
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Published documentation to gh-pages
gh-pages: singlehtml
@cp -r -a -T build/singlehtml docs/

# Makes a docker image
game-image:
docker build -f dockerfiles/game.dockerfile -t aiplatformer:latest .

# Makes an exec in dist/
game:
pyinstaller -F -no-pie -n aiplatformer dockerfiles/aiplatformer.spec

test:
python3 -m unittest discover test

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@ Project made in pygame.
The goal is the create an ai controlled player which learns
to play the game through reinforcement learning.

# Credits
## Requirements

Python ver >= 3.8

## Documentation

Visit the [github pages.](https://jonathanjakobsson.github.io/aiplatformer/)
Generate with: ` make gh-pages `

## Game design

Based on an example shown on[programarcadegames.com](http://programarcadegames.com/python_examples/show_file.php?file=platform_scroller.py)

## Installation

TODO

## Model training and design

TBD
TODO

## Assets

Expand Down
39 changes: 39 additions & 0 deletions dockerfiles/aiplatformer.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

import os
here = os.path.abspath('.')

a = Analysis([os.path.join(here, 'src', 'Game.py')],
pathex=[os.path.join(here, 'src')],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

a.datas.extend(Tree(os.path.join(here, 'assets'), prefix='assets', typecode='DATA'))


exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='aiplatformer',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )
42 changes: 42 additions & 0 deletions dockerfiles/game.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM --platform=x86_64 python:3.8.5 AS BUILDER

ENV DEBIAN_FRONTEND="noninteractive"

WORKDIR /build

RUN apt update; apt install -y patchelf

# Pip requirements
COPY requirements.txt .
COPY requirements-dev.txt .
RUN python3 -m pip install setuptools staticx ;\
python3 -m pip install -r requirements.txt;\
python3 -m pip install -r requirements-dev.txt

# Resources
COPY assets ./assets/
COPY src ./src/
COPY dockerfiles/aiplatformer.spec dockerfiles/aiplatformer.spec

RUN pyinstaller -F -no-pie -n aiplatformer dockerfiles/aiplatformer.spec ;\
staticx ./dist/aiplatformer /build/aiplatformer.static

FROM --platform=x86_64 alpine:latest As FINAL

LABEL github.JonathanJakobsson.name="aiplatformer"
LABEL github.JonathanJakobsson.description="Game"
LABEL github.JonathanJakobsson.url="github.com/JonathanJakobsson/aiplatformer"
LABEL github.JonathanJakobsson.vendor="SiB Solutions AB"
LABEL github.JonathanJakobsson.version="beta"
LABEL github.JonathanJakobsson.maintainer="github.com/JonathanJakobsson/aiplatformer"
LABEL github.JonathanJakobsson.docker.env="DISPLAY"
LABEL github.JonathanJakobsson.docker.cmd.='\
xhost +si:localuser:root; \
docker run -it --net=host -e DISPLAY \
-e XAUTHORITY=/root/.Xauthority -v /tmp/.X11-unix aiplatformer'

WORKDIR /app

COPY --from=BUILDER /build/aiplatformer.static .

ENTRYPOINT ["./aiplatformer.static"]
4 changes: 4 additions & 0 deletions docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: d78c37d48f21131295b1e4922694637f
tags: 33eac41acc08762151beb8f3b7b86c8f
Empty file added docs/.nojekyll
Empty file.
Loading