Ludii Forum
Number / math games - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Games to Include (https://ludii.games/forums/forumdisplay.php?fid=12)
+--- Thread: Number / math games (/showthread.php?tid=414)



Number / math games - xenos1984 - 02-03-2021

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:
  • (/ 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?


RE: Number / math games - slimy_asparagus - 02-03-2021

Rational numbers can be viewed as pairs of natural numbers and you can implement their arithmetic that way. So the lack of rational numbers in Ludii should not be an issue.

This could be a puzzle or a game. For a puzzle the objective is to get exactly the answer. For a game the winner could be the one who gets closer presumably in a fixed time limit.


RE: Number / math games - xenos1984 - 02-03-2021

(02-03-2021, 02:36 PM)slimy_asparagus Wrote: Rational numbers can be viewed as pairs of natural numbers and you can implement their arithmetic that way. So the lack of rational numbers in Ludii should not be an issue.

True - so the actual question would be, whether one could have pairs of natural numbers or integers as piece values (maybe this is possible already, but I have not found it in the language reference). The question for a Rational class is rather one of convenience, if one would intend to write other games involving rational numbers, to avoid implementing their arithmetic in every new game.

Quote:This could be a puzzle or a game. For a puzzle the objective is to get exactly the answer. For a game the winner could be the one who gets closer presumably in a fixed time limit.

Another idea for a game would be to have two players do alternating moves on a common list of numbers. Winning conditions for the two players would be given by certain conditions on the final result. But it could be difficult to balance the winning conditions.


RE: Number / math games - cambolbro - 02-03-2021

Hi,

You could use stacks to represent the integer pairs that make up rational numbers, where the top piece is the numerator and the bottom piece is the denominator. 

Assuming that the game starts with a list of integers, you could start with a single piece on the board for each integer, then when two numbers are combined you could add a piece to the stack if the result is rational. So if the move is / and the pieces are 3 and 8, then the result will be a stack with 8 on level 0 (denominator) and 3 on level 1 (numerator), and the old 8 piece will be deleted.

You may need to explicitly describe each move +, -, *, / in game logic to perform the correct calculation on pairs of numerator/denominator stacks.

You may run into issues with larger numbers. Maybe the count mechanism (e.g. Mancala) could be used to store a number at each site rather than a numbered piece?

We can add a new style for drawing stacks as rational number pairs if that would help.

Regards,
Cameron


RE: Number / math games - cambolbro - 02-03-2021

By the way, nice idea! I'd love to add many more such math games to the Ludii collection.


RE: Number / math games - xenos1984 - 02-03-2021

Thanks, Cameron, stacks sound like a good idea - I'll give it a try!

For the idea, I should give credits to Peter Henning, who brought up the original [3, 3, 8, 8] = 24 puzzle in a different forum (in German), breaking off a flow of ideas.