gregparkes / BattleSimulator

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.
GNU General Public License v3.0
18 stars 9 forks source link

Error in simulate_k with more than two teams #4

Open kmcnayr opened 10 months ago

kmcnayr commented 10 months ago

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

gregparkes commented 3 weeks ago

Thank you for this issue.

Changes have been made as you suggested:

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

Please pull the latest, and re-build your version using the Anaconda instructions, or via pip3 install . within a suitable environment.