Skip to content

Bot State's

Pbatch edited this page Jul 30, 2024 · 4 revisions

The state is generated by the detector.

It is very fast, taking about 0.5 seconds to return the state.

It consists of 5 sub-detectors: card, screen, unit, number and side.

Card detector

To work out what cards we can play, we use the card_detector.

Before the game starts, an image of each card in the deck is hashed.

Then when the detector is run, we hash the screen at each card position and compare it to the precomputed hashes.

Screen detector

To automate moving from between end of game screen, the lobby and the game, we use the screen_detector.

Again, we do this by comparing hashes of various parts of the screen.

If we're in the lobby, the chest icon is at fixed position. lobby

If we're at the end of the game, the OK button is at a fixed position. end_of_game

Otherwise, we assume we're in game.

Unit detector

To work out what units are in the battlefield, we use the unit_detector.

It uses YOLOv10 (an object detector), trained on many labelled screenshots. The ONNX runtime is used to perform fast inference.

image

Here you can see the confusion matrix of the performance. If you are interested in a certain deck where your cards have not been labelled, post your deck in the Issues section and I'll see what I can do.

Number detector

To work out what the numbers are, we use the number_detector.

Again, it uses YOLOv5 and is trained on various fixed crops of the screen (4 for the princess towers, 2 for the king HPs and 4 for the king levels).

We make all the crops the same size, so that ONNX can perform batched inference.

number_health_check

number_val_loss

Side detector

To work out if the unit is an ally or an enemy, we use the side_detector.

It isa small CNN that runs on 16x16 images. We assume that the unit is an enemy if the unit is not in our deck.