Skip to content

Commit

Permalink
README improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyssoul committed Dec 3, 2020
1 parent 5101581 commit 7438763
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 11 deletions.
111 changes: 103 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@
Dungeons and data structures: AI Game Tournament
# Dungeons & Data Structures: CoderOne AI Game Challenge

## Installation instructions
### Prerequisites
This is a `python` project and valid Python3 installation is required to run it.
If you don't have have `python` installed on your machine, please go to python the official python [web site pt](https://www.python.org/) and follow installation instructions for your operating system.

## Installation
There are a number of ways to install the project. Easies is to use intallation package.
Download latest avaialble release from [github release page](https://github.com/gocoderone/dungeons-and-data-structures/releases).

### MacOS/Linux
Assuming `~/workspace` is the directory you want to use to delevop your AI-agent:
Open terminal and run
```shell
# Create a working directory for your project:
> mkdir -p ~/workspace/my-agent

# Change into that directory
> cd ~/workspace/my-agent

# Create a python virtual environment. Lets call it venv
> python3 -m venv venv
# Activate your new python environment
> source venv/bin/activate
> pip install -r requirements.txt

# Install CoderOne Dungen module you have previously downloaded:
> pip install ~/Downloads/coderone-challenge-dungeons-0.1.0.tar.gz

```
Once you have working installation you can start working on your AI-agent.
> coderone-dungeon --interactive --watch my_agent
### Windows
**TBD


## Running a game
Once all game dependencies properly installed, the game can be launched using command line:
> ./main.py
> python -m coderone.dungeon.main
There a number of command line option support by the game driver. To get a full list of options run:
> ./main.py --help
> python -m coderone.dungeon.main --help
### Commandline options summory
Game runner recognises a number of command line options.
use `python -m coderone.dungeon.main --help` to get a list of supported options.

* `--headless` - run the game without graphics. Tournament matches will be run in this mode.
* `--interactive` - game is created with extra player for the interactive user. This player can be controlled using keyboard.
* `--watch` - automatically reload user agent if source code files changes. This allows for interactive development as code can be edited while the game is running.
* `--record <FILE>` - record game action into a specified file for later review.


### Intractive mode keys:
* `Enter` - to pause / un-pause the game
* `Shit+R` - to restart the game with new random map
* `` / `` / `` / `` - arrows to move the player
* `<SPACE>` - to place the bomb


### Game modes
Expand All @@ -25,10 +67,63 @@ There are 3 main modes to run the game:
This is the mode used to run a tornamanet.

By default, game runs in a tornament mode, without user input, with graphics output. For example, to ran a random match between two AI agent "agent1.py" and "agent2.py", run:
> ./main.py agent1 agent2
> ./main.py agent1.py agent2.py
Agent with multiple files code are also supported. Keep in mind that a proper [python modules](https://docs.python.org/3/tutorial/modules.html) must include `__init__.py` file.

## Config options
On the first run the game will generate default config file `config.json` and store in the OS-specific configuation directory.

Default config looks like this:
```
{
"headless": false,
"interactive": false,
"start_paused": true,
"wait_end": 5,
"max_iterations": 3000,
"tick_step": 0.10
}
```
### Config notes
In your local developemnt environemnt you have access to all config options, such as nubmer of iteration the game runs (`max_iterations`) or game update time step (`tick_step`). However, this options are fixed in the tournamtent and can not be modified so please don't rely on this values.

**Note** do not include ".py", because the agent code is loaded from a python module. In the example above, `agent1` - is python module name, represented by a single file `agent1.py`.

Agent with multiple files code are also supported. Keep in mind that each proper (python modules)[https://docs.python.org/3/tutorial/modules.html] must include `__init__.py` file.
## Known issues
Python library used for graphics has some known issues.
If you experience a game crash with error like:
```
munmap_chunk(): invalid pointer
Aborted (core dumped)
```
Add the following option to your `config.json`
> "no_text": false,
This options disables all texts in the game which resolves library crashes.


## Development

Clone this git repository:
> git clone https://github.com/gocoderone/dungeons-and-data-structures
Open termnial and run following commands

```shell
> cd <git check-out>
> python3 -m venv venv
> source venv/bin/activate
> pip install -r coderone/requirements.txt
> pip install -r coderone/dungeon/requirements.txt

```

## Contributions
As we strive to build AI sport games we welcome all contributions to improve the experience for all participants.

Feel free to [raise](https://github.com/gocoderone/dungeons-and-data-structures/issues/new/choose) an issue in the github repository if you experiece any issue or would like to send a suggestion.

## Authors
HUMANS at [Coder One](https://www.gocoder.one/):
* Ivan aka [@abbyssoul](https://github.com/abbyssoul)

4 changes: 1 addition & 3 deletions coderone/dungeon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
ASSET_DIRECTORY = os.path.join(os.path.dirname(__file__), 'assets')
DEFAULT_CONFIG_FILE = 'config.json'

print(f"!!!! {ASSET_DIRECTORY}")


SCREEN_TITLE = "Coder Oone: Dungeons & Data Structures"
SCREEN_TITLE = "Coder One: Dungeons & Data Structures"
# Do the math to figure out our screen dimensions
SCREEN_WIDTH = PADDING[0]*2 + WIDTH * 12
SCREEN_HEIGHT = PADDING[1]*3 + HEIGHT * 10
Expand Down

0 comments on commit 7438763

Please sign in to comment.