skotz / volcanoes

Prototype for a new board game
4 stars 1 forks source link

Idea to try improving MonteCarloTreeSearchEngine.cs performance #55

Open simondorfman opened 3 years ago

simondorfman commented 3 years ago

In the simulation, instead of picking random moves, try this:

From the list of available moves, assign each move a weighted value and then randomly pick from that weighted list. So some moves (which are generally better, more often than not, hopefully) will be picked more often in the simulation.

There would be 4 levels of weight:

  1. 1.5 times more likely
  2. 1.25 times more likely
  3. the remaining tiles at 1 rating (or something like that, not sure how to say it)
  4. 0 times more likely, never pick these tiles, unless they would cause an immediate win

(I'm just guessing on these weightings, maybe other numbers will work better.)

Here's how the weighted values would be calculated for the 4 levels:

level 1: spaces that are 3 away from your own volcanoes AND only consider your own volcanoes that are level 1, 2, or 3 (not 4 dormant) AND only consider open paths when counting the 3 spaces away (not occupied by opponent volcanoes, or own volcanoes)

Rational for level 1: Because once your volcano erupts, it will be 2 away. And once the volcano you play erupts, there will be a connection. You're setting yourself up for a connection after both volcanoes erupt.

level 2: spaces that are 2 away from your enemy volcanoes AND only consider the enemy volcanoes that are level 1, 2, or 3 (not 4 dormant) AND only consider open paths when counting the 2 way (not occupied by opponent volcanoes, or own volcanoes)

Rational for level 2: You're setting your volcano up to kill the child-volcanoes before the child-volcanoes erupt.

level 3: the remaining valid-play spaces (after level 1, 2 & 4 are calculated)

level 4: spaces that are 1 away from your enemy volcanoes AND only consider the enemy volcanoes that are level 3

Rational for level 4: If you play a volcano here, it will be destroyed at the next growth turn. So it's a bad move, unless it wins you the game right away.

skotz commented 3 years ago

The only issue here is that it'll take more time to generate these moves than it would to just pick a random one. That'll result in fewer overall simulations, which will decrease overall strength. We'll have to find a way to precompute a lot of this.