Historical battle simulation package for Python

Overview

Jomini v0.1.4

Jomini GitHub license Maintenance

ForTheBadge built-with-love

Jomini creates military simulations by using mathematical combat models. Designed to be helpful for game developers, students, history enthusiasts and -to some extent- scientists. You can mail me at [email protected] if you want to contribute.

To download: https://pypi.org/project/Jomini

Documentation will be available in the next update.

Lanchester Models 101

This package uses the combat models developed by Frederick William Lanchester, a.k.a one of the founding fathers of Operations Research.

  • Lanchester Models are deterministic, which means the model will always yield the same result for the same input parameters.
  • Lanchester Models view battles as an attrition model, therefore manuevers and sudden changes during the battle can not be represented.
  • You might need to do some manual fine-tuning if you are not able to get quality parameters (rho, beta, engagement_width) from a data set.
  • Despite the downsides, even the primitive models developed by Lanchester himself works wonders with the right parameters.

Code Sample: Lanchester's Linear Law

  • The Linear Law is based on force concentration
  • Good for modelling melee battles and unaimed fire (artillery, arquebus, handcannon etc.)
from jomini.Lanchester import Battle, LinearLaw

# Re-creating the Battle of Cerignola (AD 1503)
# In the actual battle, Spanish(red) lost 500 men while the French(blue) lost 4000 men
# Parameters rho, beta, engagement_width and time are manually fine_tuned
b = Battle(red=6_300, blue=9_000, rho=0.0800, beta=0.0100)
L = LinearLaw(b, engagement_width=100)
print(L.get_casualty_rates()) # Returns casualty rates 
print(L.get_casualties(time=7))
print(L.get_remaining(time=7))
print(L.simulate_battle(time=7))

Linear Law

Code Sample: Visiting models used in Jomini

  • Square Law: Given equal power coefficients, the fighting power is proportional to the square of army size.
    • Good for modelling aimed fire (e.g Napoleonic line-battles)
  • Logarithmic Law: Basically square law at a larger scale, used by Weiss to model the American Civil War
    • Good for modelling tank combat as well
from jomini.Lanchester import Battle, LinearLaw, SquareLaw, LogarithmicLaw, GeneralLaw

# Simulating a fictitious battle with each of the laws
b = Battle(red=20_000, blue=30_000, rho=0.0150, beta=0.0120)
Linear = LinearLaw(b, engagement_width=500)
Square = SquareLaw(b)
Log = LogarithmicLaw(b)
Generalized = GeneralLaw(b, engagement_width=500, p=0.450, q=0.600)

# If time is not specified, the battle goes on until one side is annihilated.
print(Linear.simulate_battle() + "\n")
print(Square.simulate_battle() + "\n")
print(Log.simulate_battle() + "\n")
print(Generalized.simulate_battle())

Model-1 Model-2

You might also like...
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Tekken-python-ml - A project of playing tekken game using python
Tekken-python-ml - A project of playing tekken game using python

Tekken Python Description Hi this is new project of playing tekken game using py

Minecraft clone using Python Ursina game engine!
Minecraft clone using Python Ursina game engine!

Minecraft clone using Python Ursina game engine!

Lutris desktop client in Python / PyGObject

Lutris Lutris is an open source gaming platform that makes gaming on Linux easier by managing, installing and providing optimal settings for games. Lu

Python fitting assistant, cross-platform fitting tool for EVE Online
Python fitting assistant, cross-platform fitting tool for EVE Online

pyfa What is it? Pyfa, short for python fitting assistant, allows you to create, experiment with, and save ship fittings without being in game. Open s

AI that plays Flappy Bird Game using the python module NEAT.
AI that plays Flappy Bird Game using the python module NEAT.

Flappy Bird AI [NEAT] AI that plays Flappy Bird Game using the python module NEAT. Instructions Install Python Modules: pip3 install -r requirements.t

Parkour game made in Python with Ursina Game Engine along with ano0002, Greeny127 and Someone-github Creates a landscape with more accurate river generation in Minecraft version 1.12 using python.
Creates a landscape with more accurate river generation in Minecraft version 1.12 using python.

MinecraftLandRiverGen View the following youtube video to set up a world that can interact with the python programs

a game of life implementation in python

gameoflife-py python implementation of game of life Installing As long as you have bash and curl installed and are on Linux the install script should

Comments
  • Added more errors to fix issues

    Added more errors to fix issues

    Added TypeErrors where a side has 0 soldiers in battle Added ValueError for the following case in pseudocode: (rate_red > size_red and rate_blue > size_blue) Closes #3 Closes #4

    opened by umitkaanusta 0
Releases(v0.1.4)
Owner
Ümit Kaan Usta
Marmara University - CSE
Ümit Kaan Usta
OpenGL experiments with Pygame & ModernGL

pygame-opengl OpenGL experiments with Pygame & ModernGL TODO Skybox & Reflections Post-process effects (motion blur, color correction, etc..) Normal m

Kadir Aksoy 4 Oct 28, 2022
A zombie game using Kinetic. You can control players using fingers

This is Eden Park's portpolio: Works, projects and practices This repository can be used to show the potential employers to check my works, code and p

Eden Park 4 May 16, 2022
A Game of Life implementation in Python

Game of Life in Python (Golipy) Golipy is a simulator of John H. Conway's Game of Life, developed in Python based on the Pygame library. This is a toy

Alber 2 Dec 10, 2021
Bingo game with python

bingo-game-with-python type of plays possible player vs computer player vs player computer vs computer game is built with 4 objects classes 1.game 2.b

1 Nov 27, 2021
Simple Game created using Python & PyGame, as my Beginner Python Project!

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc have sound and lot's of keyboard functions. Prerequisites More Experience

Gaurav Pandey 2 Jan 08, 2022
A simple pygame implementation of the LOGO programming language.

LOGO-py A simple pygame implementation of the LOGO programming language. Latest Version Notes Fixed a bug where penup/pendown would not work properly.

Ethan Evans 1 Dec 05, 2021
A Pygame game made in 48 hours

Flappuccino Flappuccino is a game created in 48 hours for the PyGame Community New Years Jam using Python with Pygame. Screenshots Background Informat

PolyMars 242 Jan 02, 2023
PingPong - Simple Ping Pong Game Made In Python

PingPong Basic Ping Pong Game Made In Python

ʀᴇxɪɴᴀᴢᴏʀ 1 Jan 01, 2022
A solution program of 24. game.

A solution program of 24. game.

1 Dec 12, 2022
Among AIs is a (prototype of) PC Game we developed as part of the Smart Applications course @ University of Pisa.

Among AIs is a PC Game we developed as part of the Smart Applications course @ Department of Computer Science of University of Pisa, under t

Gabriele Pisciotta 5 Dec 05, 2021
Graphical impimetaion of Conway's Game of Life in Python using pyglet

Conway's Game of Life in Python Konstantin Opora Conway's Game of Life: graphical implementation in python using pyglet. developed in Python 3.10.0 Re

Konstantin Opora 1 Nov 30, 2021
Deep Running

Deep Running 1. Install $ pip install --user deep_running 2. Lap N Lap. Name Remarks Citation Meta 1 Mario Deeeeeep Running I was born to run. dannyso

karaage 69 Jan 31, 2022
An algorithm to reach a correlated equilibrium in multiplayer games.

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games. View Demo · Report Bug · Request Fea

Omar Boufous 2 Feb 01, 2022
An interactive pygame implementation of quadtree spatial quantization

QuadTree-py An interactive pygame implementation of quadtree spatial quantization Contents Installation Usage API Reference TODO Installation Clone th

Ethan 1 Dec 05, 2021
Average Clicker Game (AVG) is a Python made game using tkinter

Average-Clicker-Game Average Clicker Game (AVG) is a Python clicker game not made with pygame but with tkinter, it has worker, worker upgrades, times

Zacky2613 1 Dec 21, 2021
This is a good project to train your logic game with python language

JO-KEN-PÔ!!! | Description | basic. I make this game only to train. This is a good project to train your logic game with python language. This game is

Elianderson Silva 1 Jan 24, 2022
Ultimaze est un jeu en 2.5D, réalisé dans le cadre d'un projet de NSI.

Ultimaze Ultimaze est un jeu en 2.5D, réalisé dans le cadre d'un projet de NSI. La consigne était d'utiliser la librairie pygame pour créer un jeu en

parlabarbedeMerlin 3 Sep 17, 2022
A networking library for multiplayer games.

Aerics A networking library for multiplayer games. Getting Started Install Python Open cmd/terminal and type: pip install Aerics Examples Creating a

Yusuf Rençber 3 Jan 04, 2023
A set of functions compatible with the TIC-80 platform

Pygame-80 A set of functions from TIC-80 tiny computer platform ported to Pygame 2.0.1. Many of them are designed to work with the NumPy library to im

7 Aug 08, 2022
Brawl Stars open source server for v20

Laser Scratch Brawl Stars open source server for v20! Implemented Features Battle End Leaderboard Player Profile Lobby Info Menu Notifications Club Wa

TheIke 17 Nov 19, 2022