GithubHelp home page GithubHelp logo

zodiacwind / differential-games Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aalu1418/differential-games

0.0 0.0 0.0 8.17 MB

Python implementation of differential games - starting from simple 2 body pursuit/evader problems to more advanced scenarios.

Python 100.00%

differential-games's Introduction

Differential Games

Simulating differential games (specifically pursuit/evasion scenarios) using python.

Homicidal Chauffeur Problem - 2 Body Pursuit/Evasion

Differential equations

source: Fundamentals of Aerospace Navigation and Guidance by Kabamba & Girard

Differential equation solver
Python/Scipy solv_ivp or could implement as a discrete time system...

Player strategy ideas (for choosing heading angles)

  • Minimize/maximize distance
  • Move in tangential direction of attacker
  • Knowing previous history of other player or not
  • Neural network / machine learning for creating strategy using sklearn libraries (maybe...)

Pursuer strategies

  • phiSingleState - calculates the required phi to reach the evader using a single snapshot (issues with arctan2 range wrap)
  • phiThetaHistory - calculates the required phi to reach the evader using previous theta history (solves the arctan2 wrap issue)
  • phiPerturb - simple method based on phiThetaHistory but handles a detected loop by perturbing the pursuer phi

Evader strategies

  • psiRandom - random direction changes every 20 steps
  • psiTurn90 - every 5 steps, calculates new psi that is 90 degrees from a line drawn from pursuer to evader. Left vs right turn is handled depending on pursuer heading.

Current winning strategy: phiPerturb beats all pursuer methods
Caveat: this may be because of a flaw in the psiTurn90 algorithm

Algorithms

  1. Initialize with some set of parameters.
  2. Simulate first step using ODE solver.
  3. Choose heading angles using strategy.
  4. Repeat 2 and 3 until time runs our or collision occurs.

Notes

  • wavy behavior exhibited when using phiCalcSingleState is solved using np.unwrap with previous history in phiCalcThetaHistory
    • not sure if this is a bug or not: whenever the pursuer misses, it makes a loop.
  • Running instructions (overall run with python3 main.py):
    • runAllSim runs all methods against each other and outputs results
    • runSim runs a specific method
    • animate.animate allows for animated python figure
  • To-Do: rewrite using object oriented programming

differential-games's People

Contributors

aalu1418 avatar

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.