Code Monkey home page Code Monkey logo

gregparkes / battlesimulator Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 8.0 85.75 MB

An extensive game simulator and animated visualizer for 2D battles drawn with inspiration from Totally Accurate Battle Simulator (TABS). Define units and learn patterns of behaviour to train Machine Learning algorithms.

License: GNU General Public License v3.0

Jupyter Notebook 93.33% Python 6.64% Shell 0.03%
simulations battle animated-battles totally-accurate-battle-simulator

battlesimulator's People

Contributors

cookiecat-101 avatar gregparkes avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

battlesimulator's Issues

Wrong Enemy Selection

Hello, I think I found an issue: every sim I run has the same problem including the example notebooks and dataset. In the very first frame of the simulation there is one and sometimes two units on one of the teams that are not displayed as arrows but as hexagons. From what I can tell these units have no dxx/dxy movement and remain stationary.

All units in the battle, including their own team target these stationary units first; they also target themselves in the initial step of the simulation which is very odd.

It seems like it always occurs with units on the first team/army that is created.

I can't find what the problem might be, here is a screenshot of the first frame of the examples/notebook1 simulation using the clone wars unit dataset.

image

Here is the output from the first frame: all of team 1 is targeting unit 2 with the exception of unit 4 which for some reason is targeting another teammate.

ย  x y target hp armor ddx ddy team utype
0 0.054352 -0.246322 2 20 40 0.525136 0.851019 1 1
1 0.38671 -0.093172 2 20 40 0.230794 0.973003 1 1
2 0.53523 0.532973 2 20 40 0 0 1 1
3 -0.815678 0.177755 2 20 40 0.967125 0.254303 1 1
4 1.034064 -0.82021 3 20 40 -0.880084 0.474819 1 1
5 0.650016 0.749444 2 20 40 -0.468473 -0.883478 1 1
6 0.113461 0.009714 2 20 40 0.627559 0.778569 1 1
7 -0.366717 0.80359 2 20 40 0.957817 -0.287379 1 1
8 -0.342028 -0.365436 2 20 40 0.698634 0.715479 1 1
9 1.078876 0.418672 0 20 40 -0.838797 -0.544444 1 1
10 2.318572 1.852982 9 35 45 -0.653914 -0.756569 0 2
11 1.150131 2.927896 5 35 45 -0.223753 -0.974646 0 2
12 1.138769 2.461794 5 35 45 -0.274467 -0.961597 0 2
13 2.905375 1.393993 9 35 45 -0.882115 -0.471035 0 2
14 2.353364 2.187001 9 35 45 -0.584695 -0.811253 0 2

Number of Kills for each unit and team feature request

I am interested in seeing the number of kills each unit and team achieve in the battle. It seems like keeping the running total in M might work. The unit level totals would be available in the last frame of the simulation which you can get by running with return_frames = True.

In the return_frames = False scenario I suppose a more robust results dataset would need to be implemented which in addition to returning the remaining units for each team it would also include the number of kills each team achieved. If this were to be done a pandas dataframe with the teams on the rows and statistics in the columns seems ideal. Other stats could also be added like total damage done, team level accuracy, units lost, types of units killed, etc.

Obviously this is not a trivial enhancement but wanted to note it here.

Error in simulate_k with more than two teams

I am trying to run a k simulations with more than two teams and am receiving this error:

ValueError: Shape of passed values is (30, 2), indices imply (30, 3)

I tracked it down to this line in _battle.simulate_k

runs = np.zeros((k, 2), dtype=np.int64)

it is assuming the results have only two teams. I think a quick fix is to change to the below which is the number of teams:

runs = np.zeros((k, np.unique(self._teams).shape[0]), dtype=np.int64)

the team_counts results returned by simulate_battle contain a records for each unique team in M.

This appears to work for up to 30+ teams/allegiances

_simplot Error

HI Greg!
Thanks for this awesome battlesim!
I'm trying to implement it on my pc to use it in my D&D Campaigns, cause I find it awesome.

I'm following the tutorial and the error that is given when I run "battle.sim_jupyter()" is "name '_simplot' is not defined".

Is it a problem in a package?

Thank you!

Error in simulate_k when number of teams are different

In examples/notebook2 I am receiving an error after changing Magmaguard team to a third team name in the starwars-cloneswars.csv dataset.

The issue appears to be due to the battle now containing 3 teams after loading the unit dataset file, but the simulate_battle is only returning a result for the unique teams in M.

Generically: this error happens when the number of unique teams loaded into the battle object is different than the number of teams that are added via create_armies

Solution: I suppose you can just make sure to add armies for all of the teams that are loaded into the battle object.

I found this when playing around with examples/notebook2 which loads a number of units from the csv dataset file but only runs a sim using two unit types which are in three army groups, and represent only two of the three unique teams in the dataset file (after I changed the Magmaguard to a third team name).

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.