Skip to main content

Hearthstone Battlegrounds Battle Simulator

A simulator for battles in the HS battlegrounds. This program can quickly run over a battle many times, and give statistics on the results

Example output:

Turn 8
* 4/6 Cave Hydra
* 8/2 Kaboom Bot
* 10/4 Kaboom Bot
* 11/6 Nightmare Amalgam
* 2/2 Lightfang Enforcer
* 4/6 Imp Gang Boss
VS
* 2/2 Kaboom Bot
* 2/2 Kaboom Bot
* 6/3 Cobalt Guardian, divine shield
* 2/6 Security Rover
* 4/2 Micro Machine
* 1/5 Junkbot
* 5/6 Psych-o-Tron, taunt, divine shield
--------------------------------
win: 2%, tie: 3%, lose: 94%
mean score: -6.573, median score: -7
percentiles: -14 -11 -9 -8 -8 -7 -6 -5 -4 -3 12
actual outcome: -9, is at the 20-th percentile

This corresponds to the following board state: Example game
taken from the game at https://www.youtube.com/watch?v=TV0HSwbhasQ,

The score at the end is the number of stars of the remanining minions of the first player, or negative the stars of the second player. So a positive score means the first player wins by that many stars, a negative score means that the first player loses. This score corresponds to damage dealt or taken, excluding damage from the character's level. The program reports mean and median of the scores, and the 0%, 10%, .., 100% percentiles

Usage

hsbg run.txt

The input file consists of a series of commands to define the board state, and looks very similar to the output shown above. See examples/run1.txt.

The program can also be used in interactive mode, by starting it without any arguments. Type help to get a list of commands:

-- Defining the board
board      = begin defining player board
vs         = begin defining opposing board
* <minion> = give the next minion
HP <hero>  = tell that a hero power is used
level <n>  = give the level of a player
health <n> = give the health of a player

-- Modifying the board
give <m> <buff> = buff minion(s) m with one or more buffs

-- Running simulations
actual <i> = tell about actual outcome (used in simulation display)
run (<n>)  = run n simulations, report statistics (default: 1000)
optimize   = optimize the minion order to maximize some objective
objective  = set the optimization objective (default: minimize damage taken)

-- Stepping through a single battle
show       = show the board state
reset      = reset battle
step       = do 1 attack step, or start if battle not started yet
trace      = do steps until the battle ends
back       = step backward. can be used to re-roll RNG

-- Other
info <msg> = show a message
help       = show this help message
quit       = quit the simulator

-- Minion format
Minions are specified as
  [attack/health] [golden] <name>, <buff>, <buff>, ..
for example
 * 10/12 Nightmare Amalgam
 * Golden Murloc Tidecaller, poisonous, divine shield, taunt, windfury, +12 attack

-- Minion buffs
 * +<n> attack = buff attack by this much
 * +<n> health = buff health by this much
 * +<a>/+<h>   = buff attack and health
 * taunt, divine shield, poisonous, windfury = the obvious
 * microbots   = deathrattle: summon 3 1/1 Microbots
 * golden microbots = deathrattle: summon 3 2/2 Microbots
 * plants      = deathrattle: summon 2 1/1 Plants
 * <minion>    = magnetize given minion

-- Refering to a minion
You can refer to a minion with an index (1 to 7), a name, a tribe, or all
For example
  give all +1/+1
  give 2 poisonous  # buffs the second minion
  give Mech divine shield, windfury
  give Cave Hydra +10 health
By default this refers to your side, to modify the enemy:
  give enemy all taunt

A better user interface is a work in progress.

Compiling

To compile the code you need a recent version of gcc, python and make. Run make in the root directory to build the executable.

To make the web version you need emscripten, run make web to build it.

FAQ

Q: How do I put in a board state
A: Use a text file, see the examples directory. The plan is to eventually make a parser for the Hearthstone log files.

Q: What about Bob's tavern?
A: Currently only actual battles are simulated, the program doesn't know about buying, selling, leveling etc.

Q: What can I do with this?
A:

  • You can see how lucky you are
  • You can learn to better position your minions (use the optimize command)
  • (future) you can see how well your board is expected to do at a certain turn of the game

Q: Known bugs
A:

  • There might be subtle differences in the order of triggers etc.

Metadata

Release files for hsbg-sim 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hsbg-sim 1.0.0
File Size Uploaded Provenance Actions
hsbg_sim-1.0.0.tar.gz 26.7 kB Without provenance Details for hsbg_sim-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hsbg-sim 1.0.0
File Interpreter ABI Platform Actions
hsbg_sim-1.0.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for hsbg_sim-1.0.0-cp39-cp39-win_amd64.whl

Total release size: 82.0 kB

Release files / hsbg_sim-1.0.0.tar.gz

Download URL hsbg_sim-1.0.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0c6bf025bfe343eaaa3934cdd45d443ed19cf9de5b39a7ebe552be9689857f7a
BLAKE2b-256 checksum
How to use checksums
2fb9a69ec1fcfa1a1d0b3ff534c4daa895d61df04d33c38bdcfd8d5163431040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Release files / hsbg_sim-1.0.0-cp39-cp39-win_amd64.whl

Download URL hsbg_sim-1.0.0-cp39-cp39-win_amd64.whl
Size 55.3 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
0dfa4cd4ce7aad444d18318f8be1a4034163784698635c07851bcecc69227ed7
BLAKE2b-256 checksum
How to use checksums
f1324714a2804742bfcb07da9a533c679ea509c635f8e5a94e87337db62d2fdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Security for hsbg-sim 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page