Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

logo am4

CI

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:

overview

[!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/Cython
  • research: 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

    route

  • $routes <airport> <aircraft> <max_distance> <flights_per_day> [reputation]: finds the best destinations from a certain airport, sorted by decreasing estimated income

    routes

  • $user [player]: shows player (and associated alliance if found) statistics

    user

  • $fleet [player]: shows player fleet and estimated income

    fleet

  • $info <aircraft>: shows basic aircraft information and rough profit estimations

    info

  • $compare <aircraft>: compares two aircrafts

    compare

  • $search <aircraft>: finds the associated aircraft shortname for aircraft commands

    search

  • $airport <airport>: shows airport information

    airport

  • $price f[fuel_price] c[co2_price]: notifies everyone for the fuel price

    price

Internal Alliance Tools

  • $memberCompare <player> <player>: compares descending structure of contribution/day and SV

    member-compare

  • $alliance <alliance>: shows AV progression and d(AV)/dt.

    alliance

  • $allianceCompare <alliance> <alliance>: compares AV progression and gap difference over time, shows 48h/12h-average contribution/day graphs

    alliance-compare

  • $member <player> [player[]] shows contribution/day, total contribution and SV history for 1+ members

    member

  • $actions <player> [maxResults]: shows log of estimated departures, contributions and income

    member-compare

  • $watchlist [add|+, remove|rm|-] [alliance]: shows, adds or remove alliance(s) to the watchlist

Release files for am4 0.1.8a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for am4 0.1.8a1
File Size Uploaded
am4-0.1.8a1.tar.gz 4.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for am4 0.1.8a1
File
am4-0.1.8a1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
am4-0.1.8a1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
am4-0.1.8a1-cp311-cp311-macosx_10_15_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.15+ x86-64 Details
am4-0.1.8a1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
am4-0.1.8a1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
am4-0.1.8a1-cp310-cp310-macosx_10_15_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.15+ x86-64 Details
am4-0.1.8a1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
am4-0.1.8a1-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
am4-0.1.8a1-cp39-cp39-macosx_10_15_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.15+ x86-64 Details

Total release size: 220.1 MB

Release files / am4-0.1.8a1.tar.gz

Download URL am4-0.1.8a1.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
84a9324e03c44c2e50c30b26a11f78adbeae557bda434668fb6e40be886bb604
BLAKE2b-256 checksum
How to use checksums
cc6bb2e5eb537d5825067b87ee224ece5a17d54ef44fc8958a64e447357857b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl

Download URL am4-0.1.8a1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
Size 16.8 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6ce0b25d3f34e33183ebf300c09dcc5564040b2fa63445aa768535f3da12f135
BLAKE2b-256 checksum
How to use checksums
0071c47bebecdffed0166034658a14cc95c617133d452a38a124472d57198ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp311-cp311-macosx_11_0_arm64.whl

Download URL am4-0.1.8a1-cp311-cp311-macosx_11_0_arm64.whl
Size 27.6 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
875b28aad646546e3a0d8d4c9d1a51ca3b2528e9a07414f61933bca8557fcdf4
BLAKE2b-256 checksum
How to use checksums
85cc2e563146d268ac5bdaeff602d049483c02ed35b7678cce2929b8c8cbb4c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp311-cp311-macosx_10_15_x86_64.whl

Download URL am4-0.1.8a1-cp311-cp311-macosx_10_15_x86_64.whl
Size 27.6 MB
Tags CPython 3.11 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
4a36d3a9edd8a74782dbcde44b7424cd492fe233516d408dbfece267b015c619
BLAKE2b-256 checksum
How to use checksums
896e8eb24f519582ff026742d74e68707bd6166fc619c66e234a9d770246ca18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl

Download URL am4-0.1.8a1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
Size 16.8 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3ff1dba0a61ed3f0f9291a9831db6e8c385733f9ce992e6472d98d959edfeb00
BLAKE2b-256 checksum
How to use checksums
8317b23387ba7ad76e8013dcef9bdd37e87ecb9e737598640b526c4f3d451674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp310-cp310-macosx_11_0_arm64.whl

Download URL am4-0.1.8a1-cp310-cp310-macosx_11_0_arm64.whl
Size 27.6 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2694e40f8502b2130056381d7e8810493df9ae1ed01df0e325f4ef48d207f4f7
BLAKE2b-256 checksum
How to use checksums
78b419ba5b03ca47c52ec72c216e50de476e61f554355faa87b6c7bb83876cad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp310-cp310-macosx_10_15_x86_64.whl

Download URL am4-0.1.8a1-cp310-cp310-macosx_10_15_x86_64.whl
Size 27.6 MB
Tags CPython 3.10 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
ed6d411ead9724d3bd08bb5ee4bb28e2738e9fda6ea6fb4271487296c7a0aa6f
BLAKE2b-256 checksum
How to use checksums
194986bf08c256a9fc33f32f3e823e21cc076471bb2978f600541f0d73470d9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl

Download URL am4-0.1.8a1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl
Size 16.8 MB
Tags CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f90f6308599e6169a471c5bb985e093a3bb85f939a4ef8979a080857adc2610b
BLAKE2b-256 checksum
How to use checksums
108e6d32d36554f0625776f4a67334bc70def215c61504a76b1200c5ea33d025
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp39-cp39-macosx_11_0_arm64.whl

Download URL am4-0.1.8a1-cp39-cp39-macosx_11_0_arm64.whl
Size 27.6 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
41fac41959a56731e326b0a08b2cd8aa9dc4790b952432fa5ed4a3ca12453c8c
BLAKE2b-256 checksum
How to use checksums
a9c2aa854c8d45407296de13ec222a90d7380b12c08c9c2656cfd9df4bcef437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / am4-0.1.8a1-cp39-cp39-macosx_10_15_x86_64.whl

Download URL am4-0.1.8a1-cp39-cp39-macosx_10_15_x86_64.whl
Size 27.6 MB
Tags CPython 3.9 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
ae28cd03c7f0ecc933495495de9d1fbf01ccd6fcdd3e928f68b47a3421f0d64c
BLAKE2b-256 checksum
How to use checksums
c2b71a84843a464765e47a6a43c2e276f595c5ecc9e667a80daf568432adb08b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.8a1 This release

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page