runar-rkmedia / gotally

0 stars 1 forks source link

Tutorial 3 hints are broken #30

Closed runar-rkmedia closed 1 year ago

runar-rkmedia commented 1 year ago

image

The board returns an error:

{"code":"internal","message":"Failed to generate hint"}

the error logged by the server was:

Game-visits threshold triggered (seen 6001) (MaxVisits 6000, depth 2)

runar-rkmedia commented 1 year ago

Upon investigating, it seems the this would use the breadth-first-solver, and therefore goes through very many variations. Increasing the limits returns hints, but it takes too long.

Forcing use of the depth-first-solver does not give any results, even after increasing the limits beyond what is reasonable. Did this work previously? I might need to check some versions back.

I believe a better solver could be created here, especially for challenges. Challenges typically do not generate new cells, like infinite games are (as defined by their rules). This should make it possible to solve a game more algorithmically, instead of brute forcing it. I'll need to think about this one a bit. But typically I think it should be possible to create a generator that returns a list of a sorted ideal solution, ignoring if the path is possible to get to. This is also more aligned with how humans typically think when attempting to solve these games.

Also, some things are generally better to do in a game, so perhaps it should weigh these actions higher. For instance, it is generally better to do 4x4 into 16 to generate 32, than to do 4+4 into 8 to generate 16. Perhaps we should just attempt all possible multiplications before any additions.

runar-rkmedia commented 1 year ago

Suggested instruction:

  1. Take all cell-values, sort the from highest to lowest. 2, Start with the highest value. Check if other values could be used to multiply into this value. a. If no results are found, move on to the next value, and check again for possible multiplications. b. If no results are found for any values, perform step 2 one more time, but with additions.
  2. If no results are found at all, it is not possible to solve the game as it is now. If the game has cellgenerations on after swipes, swiping could help. In that case, perform some swipes, and recheck from step 1. Otherwise, or if it not possible to swipe, return without any results.
  3. Check if the proposed multiplication/addition is possible (e.g. path is ok, or perhaps check if it would be possible by using some smart swipes). If not possible, generate a new proposed multiplication/addition and redo 4.

This should reduce the attempts by a whole lot, and likely to produce better results without so much brute-forcing.

runar-rkmedia commented 1 year ago

The suggestion was added with 3a7ee7d2, which looks like it solves these types of boards really well.

We now have three different game-solving algorithms, each with their own strengths and weaknesses. I don't really see a way around having multiple algorithms for this, as each of them are really fast at some board, and really slow at others. There is some logic that attempts to pick the best algorithm.