C
C#3w ago
Theos

Creating an algorithm to solve Number Match

Hey, I've recently discovered a new logical game called "Number Match". Link to the game Here is the set or rules describing it:
The game is played on a grid filled with numbers. Grid is x cells wide and infinitely high (it expands vertically if needed)

You remove pairs of the same number, or pairs that add up to 10.

Numbers must be next to each other horizontally, vertically, or diagonally. There can't be any number between them. Distance between the cells has no limit. You can also pair the last number of one row with the first number of the next row. If the next row is empty it just checks the next row until it finds a number.

When pairs are cleared, they disappear. If row is empty then its removed and all the rows under it are moved up.

You can add numbers 5 times. When you add numbers, it collects all the remaining numbers, skipping the empty cells, and appends them starting from the cell after the last number in the grid.

Each pair cleared gives 1 point. Each row cleared gives 5 rows.

The goal is to either clear the board or get the highest score possible.

If no moves remain, game ends.
The game is played on a grid filled with numbers. Grid is x cells wide and infinitely high (it expands vertically if needed)

You remove pairs of the same number, or pairs that add up to 10.

Numbers must be next to each other horizontally, vertically, or diagonally. There can't be any number between them. Distance between the cells has no limit. You can also pair the last number of one row with the first number of the next row. If the next row is empty it just checks the next row until it finds a number.

When pairs are cleared, they disappear. If row is empty then its removed and all the rows under it are moved up.

You can add numbers 5 times. When you add numbers, it collects all the remaining numbers, skipping the empty cells, and appends them starting from the cell after the last number in the grid.

Each pair cleared gives 1 point. Each row cleared gives 5 rows.

The goal is to either clear the board or get the highest score possible.

If no moves remain, game ends.
Any ideas how to approach this problem?
6 Replies
Lord Light
Lord Light3w ago
Check leetcode if it was there)
Theos
TheosOP3w ago
I've checked, nothing
Lord Light
Lord Light3w ago
Oh. Hard case
viceroypenguin
that'll be in a world of algorithms we call heuristics you can do it one of two ways: * check the board for any potential moves, evaluate the move plus one or two moves ahead and pick the best one (min-max strategy) * check the board for any potential moves, and grade them not just on the immediate points but based on additional contxtual information you have about what those kinds of situations look like (general heuristics)
Theos
TheosOP3w ago
I would have to do exhaustive min-max for it to work. Some moves might not seem good at first but they can pay off later
viceroypenguin
i'd hate to see you design a chess engine then... :vplaugh: truth is, this is probably a situation where you can't do perfect knowledge. so gather information and pick a best guess decision notably: chess engines use a combination of the above two strategies

Did you find this page helpful?