Tools and utilities for the game Airline Manager 4.
Project description
am4
Airline Manager 4 is an online multiplayer game whose goal is to build an airline from scratch. Rapid progression in the game requires thorough market research and route planning to high demand destinations, while considering recurring fuel/CO2 costs, and conforming to aircraft range/runway requirement constraints.
The weekly leaderboards and alliances are highly competitive arenas which require extensive knowledge in the game: this repository contains a set of high-performance foundational tools, built for the more technical-oriented players. The project is structured as follows:
- core calculations written in C++ for exhaustive searches (
src/am4/utils
) - a Python web API exposing the core (
src/am4/api
) - an sqlite database storing user settings (
src/am4/db
) - a Python discord bot for our community (
src/am4/bot
) -
am4help.com
: a SolidJS frontend calling the API (under construction,src/am4/web
)
[!WARNING] The code here represents my journey of learning various programming languages: parts of it are poorly written. Feel free to contribute by opening issues or pull requests!
Usage
The easiest way to get started is Docker.
Clone the repository and run inside:
docker build -t am4 .
docker run -d -p 8002:8002 -p 8090:8090 --name am4-dev am4
# sudo docker exec -it am4-dev bash
Access the API docs at localhost:8002/docs
and database admin UI at localhost:8090/_
.
If you would also like to run the discord bot, you must load your custom configuration file (more info):
docker run -d -p 8002:8002 -p 8090:8090 --name am4-dev am4 tail -f /dev/null
mv config.example.json config.json
# edit config.json
docker cp config.json am4-dev:/app/config.json
docker exec am4-dev python3 -m src.am4 cfg set config.json
docker exec -d am4-dev python3 -m src.am4 start api,bot
Development
If you are using VSCode, install the recommended extensions and use Tasks instead of manually executing the commands.
Core Utils
The core utils is the most important part of the project, as it is used by the API, bot and web.
Modifying it
The main entry point is the debug executable.
A C++17 compliant compiler and Linux system is required to build it.
[!TIP] VSCode users: set build target and launch.
sudo apt-get install build-essential
# optionally install vtune for profiling
cd src/am4/utils
mkdir build
cd build
cmake .. && cmake --build . --target _core_executable && ./_core_executable
Note that the BUILD_PYBIND
definition/directives controls whether the pybind11 bindings are included. It is set to 0 when building the executable.
Create the Python bindings
[!TIP] VSCode users: run the
py: reinstall
task.
# in root dir:
sudo apt-get install python3-dev python3-pip
pip3 install virtualenv
virtualenv .venv
source .venv/bin/activate
pip3 install --verbose ".[dev,api,bot]" --config-settings=cmake.define.COPY_DATA=1
pytest
cd src/am4/utils
python3 generate-stubs.py
# pip3 uninstall src/am4/utils -y
The am4
package and data files will then be installed in your site-packages, ready for use:
from am4.utils.db import init
from am4.utils.aircraft import Aircraft
init() # IMPORTANT: loads the aircraft, airport and routes etc.
a = Aircraft.search("b744")
print(a.ac)
To learn more on how to use it, check out the tests or the generated stubs.
Configuration File
The database and API can run out of the box without any configuration file, by using the defaults. However, running the discord bot/building the frontend will require you to provide custom config.
To do this, rename ./config.example.json
to ./config.json
and modify it. Then, run:
python3 -m src.am4 cfg set config.json
This will verify and persist the settings to ./src/am4/.config.json
, which is used in future calls.
Database
User authentication is handled by pocketbase, a lightweight SQLite-based backend supporting OAuth2.0.
It is automatically started before the API/discord bot when using the CLI.
Web API
The core utils are exposed to the web using FastAPI. Validation on query params/body is handled by Pydantic models defined under ./src/am4/db/models
.
To start it, use:
python3 -m src.am4 start api
Discord bot
It is similar to the API in design, but is more sophisticated in that it reads users' roles to determine their game mode.
To start it, use:
python3 -m src.am4 start bot
Web Frontend
Under construction!
Documentation for Legacy Code
src-old
: the very first iteration of the discord bot.src-v2-v3
: my first attempts at rewriting in C/Cythonresearch
: parts of my attempts to figure out the demand formula
Features
Old bot:
- calculates essential statistics
- most distance-efficient stopovers
- route demands, best seat configurations, best ticket prices, estimated income
- player rank, mode, achievements, fleet
- alliance rank, share value, contribution
- aircraft characteristics and profit
- airport characteristics
- CSV export for route queries
- fuel/CO2 notifications
- aircraft characteristics comparisons
- internal Star Alliance tools (now disbanded)
- adding competitor alliances to watchlist
- alliance comparisons over time: value,contribution/day, rate of changes
- realtime alliance-member comparisons: SV/contribution distribution
- member tracking: cheat detection tools, departure pattern identification
Public
-
$route|stop <airport> <airport> <aircraft> [flights_per_day] [reputation]
: finds the best route between two airports -
$routes <airport> <aircraft> <max_distance> <flights_per_day> [reputation]
: finds the best destinations from a certain airport, sorted by decreasing estimated income -
$user [player]
: shows player (and associated alliance if found) statistics -
$fleet [player]
: shows player fleet and estimated income -
$info <aircraft>
: shows basic aircraft information and rough profit estimations -
$compare <aircraft>
: compares two aircrafts -
$search <aircraft>
: finds the associated aircraft shortname for aircraft commands -
$airport <airport>
: shows airport information -
$price f[fuel_price] c[co2_price]
: notifies everyone for the fuel price
Internal Alliance Tools
-
$memberCompare <player> <player>
: compares descending structure of contribution/day and SV -
$alliance <alliance>
: shows AV progression and d(AV)/dt. -
$allianceCompare <alliance> <alliance>
: compares AV progression and gap difference over time, shows 48h/12h-average contribution/day graphs -
$member <player> [player[]]
shows contribution/day, total contribution and SV history for 1+ members -
$actions <player> [maxResults]
: shows log of estimated departures, contributions and income -
$watchlist [add|+, remove|rm|-] [alliance]
: shows, adds or remove alliance(s) to the watchlist
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file am4-0.1.8a1.tar.gz
.
File metadata
- Download URL: am4-0.1.8a1.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84a9324e03c44c2e50c30b26a11f78adbeae557bda434668fb6e40be886bb604 |
|
MD5 | b9bff7480e157316440b66270d49fec4 |
|
BLAKE2b-256 | cc6bb2e5eb537d5825067b87ee224ece5a17d54ef44fc8958a64e447357857b4 |
File details
Details for the file am4-0.1.8a1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
- Upload date:
- Size: 16.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ce0b25d3f34e33183ebf300c09dcc5564040b2fa63445aa768535f3da12f135 |
|
MD5 | 024f156f07830dc579e77389f7db0965 |
|
BLAKE2b-256 | 0071c47bebecdffed0166034658a14cc95c617133d452a38a124472d57198ae2 |
File details
Details for the file am4-0.1.8a1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 875b28aad646546e3a0d8d4c9d1a51ca3b2528e9a07414f61933bca8557fcdf4 |
|
MD5 | b4b695de3860e39d1d986d819e375b07 |
|
BLAKE2b-256 | 85cc2e563146d268ac5bdaeff602d049483c02ed35b7678cce2929b8c8cbb4c3 |
File details
Details for the file am4-0.1.8a1-cp311-cp311-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp311-cp311-macosx_10_15_x86_64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.11, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a36d3a9edd8a74782dbcde44b7424cd492fe233516d408dbfece267b015c619 |
|
MD5 | 565745f6395a21df32f2569921d34ba0 |
|
BLAKE2b-256 | 896e8eb24f519582ff026742d74e68707bd6166fc619c66e234a9d770246ca18 |
File details
Details for the file am4-0.1.8a1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
- Upload date:
- Size: 16.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ff1dba0a61ed3f0f9291a9831db6e8c385733f9ce992e6472d98d959edfeb00 |
|
MD5 | c683cbca73ced850f64bafb14404e6d3 |
|
BLAKE2b-256 | 8317b23387ba7ad76e8013dcef9bdd37e87ecb9e737598640b526c4f3d451674 |
File details
Details for the file am4-0.1.8a1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2694e40f8502b2130056381d7e8810493df9ae1ed01df0e325f4ef48d207f4f7 |
|
MD5 | fe4ea9f6257ac619a0af01c81c82fc5d |
|
BLAKE2b-256 | 78b419ba5b03ca47c52ec72c216e50de476e61f554355faa87b6c7bb83876cad |
File details
Details for the file am4-0.1.8a1-cp310-cp310-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp310-cp310-macosx_10_15_x86_64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.10, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed6d411ead9724d3bd08bb5ee4bb28e2738e9fda6ea6fb4271487296c7a0aa6f |
|
MD5 | 15475425a830c0f417f44f07c3decc51 |
|
BLAKE2b-256 | 194986bf08c256a9fc33f32f3e823e21cc076471bb2978f600541f0d73470d9c |
File details
Details for the file am4-0.1.8a1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
- Upload date:
- Size: 16.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f90f6308599e6169a471c5bb985e093a3bb85f939a4ef8979a080857adc2610b |
|
MD5 | 4158e7090514dd8be7f8e02495458382 |
|
BLAKE2b-256 | 108e6d32d36554f0625776f4a67334bc70def215c61504a76b1200c5ea33d025 |
File details
Details for the file am4-0.1.8a1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41fac41959a56731e326b0a08b2cd8aa9dc4790b952432fa5ed4a3ca12453c8c |
|
MD5 | b481c4431cd93ac5ff51758d58c31dcf |
|
BLAKE2b-256 | a9c2aa854c8d45407296de13ec222a90d7380b12c08c9c2656cfd9df4bcef437 |
File details
Details for the file am4-0.1.8a1-cp39-cp39-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: am4-0.1.8a1-cp39-cp39-macosx_10_15_x86_64.whl
- Upload date:
- Size: 27.6 MB
- Tags: CPython 3.9, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae28cd03c7f0ecc933495495de9d1fbf01ccd6fcdd3e928f68b47a3421f0d64c |
|
MD5 | 63860670d03671c97caf1c2ecbb5c25a |
|
BLAKE2b-256 | c2b71a84843a464765e47a6a43c2e276f595c5ecc9e667a80daf568432adb08b |