02-03-2021, 02:30 PM
As an interlude(me) until I continue working on board games, I give it a try at something new - games involving math and numbers. Here is a puzzle across which I ran recently in another forum.
Start with a list of rational numbers. In every move, take two of these numbers, combine them with an algebraic operation (+, -, *, /), and replace the original two numbers in the list with the result. The game / puzzle ends when only one number is left. The player wins if this number agrees with a certain target value.
In other words, the objective is to combine a given list of numbers into an expression which yields a particular value, using operations +, -, *, /.
Example: From the list [3, 3, 8, 8], construct 24.
Moves:
Hence, 24 = 8 / (3 - 8/3).
Now I wonder whether this kind of puzzle can be implemented in Ludii. Every game state would have to be a list of rational numbers, and the legal moves are the operations on pairs of numbers. My idea would be implementing each list element in the player's hand, and then to implement a rule which allows jumping one piece onto another to combine them. Or maybe on a board, if jumping within the hand is not possible. But the tricky part seems to be the math. If I read the language reference correctly, piece values are integers. But even floats would be tricky, if one wants to represent exact rational numbers. Could one have pairs of integers, or even an own Rational type, that canonicalizes things like 2/4 = 1/2 or 1/(-3) = -1/3?
Start with a list of rational numbers. In every move, take two of these numbers, combine them with an algebraic operation (+, -, *, /), and replace the original two numbers in the list with the result. The game / puzzle ends when only one number is left. The player wins if this number agrees with a certain target value.
In other words, the objective is to combine a given list of numbers into an expression which yields a particular value, using operations +, -, *, /.
Example: From the list [3, 3, 8, 8], construct 24.
Moves:
- (/ 8 3): [3, 8, 8/3]
- (- 3 8/3): [8, 1/3]
- (/ 8 1/3): [24]
Hence, 24 = 8 / (3 - 8/3).
Now I wonder whether this kind of puzzle can be implemented in Ludii. Every game state would have to be a list of rational numbers, and the legal moves are the operations on pairs of numbers. My idea would be implementing each list element in the player's hand, and then to implement a rule which allows jumping one piece onto another to combine them. Or maybe on a board, if jumping within the hand is not possible. But the tricky part seems to be the math. If I read the language reference correctly, piece values are integers. But even floats would be tricky, if one wants to represent exact rational numbers. Could one have pairs of integers, or even an own Rational type, that canonicalizes things like 2/4 = 1/2 or 1/(-3) = -1/3?