Code Monkey home page Code Monkey logo

jomini's Introduction

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

jomini's People

Contributors

umitkaanusta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jomini's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.