08-04-2023, 06:25 AM

Hello,

with my pupils we tested the included game, played on a graph with pieces set (at start) to the other player's home. The goal is to be the first one to have one's pieces at home (or to block the other player). In the initial version (created by a 6 years old girl) there were too many draws, so we used armbands to restrict the number of moves: every time one moves, one has to give away one armband, until one can not move anymore. In the included file I managed to emulate this armband trick, with stacks of decreasing lengths.

The game is interesting but the end condition is not good. What I need is to program what we do with the children: once the game is ended, we compute

Then, the winner is the player who has the smallest sum. If the sums are equal one plays again, until the sums are not equal.

The ludeme

gives me one unit less than the distance, but I don't know how to apply it to a list of sites, it seems to work only when a and b are sites. So I need

I see in the language reference that forEach is used either to set an action (like Move), or to filter sites (in the Regions functions) but there is no example of use of forEach to get a list of integers. At least I did not find one.

So how can I compute a sum of distances to get the score?

with my pupils we tested the included game, played on a graph with pieces set (at start) to the other player's home. The goal is to be the first one to have one's pieces at home (or to block the other player). In the initial version (created by a 6 years old girl) there were too many draws, so we used armbands to restrict the number of moves: every time one moves, one has to give away one armband, until one can not move anymore. In the included file I managed to emulate this armband trick, with stacks of decreasing lengths.

The game is interesting but the end condition is not good. What I need is to program what we do with the children: once the game is ended, we compute

- for each piece, the distance to the goal line (0 if the piece is already on the goal line, 1 if it is adjacent to a site on the line, occupied or not, 2 if if it adjacent to a site itself adjacent to the goal line)

- the sum of the 3 distances (one for each piece), which is an integer between 1 and 6 for each player

Then, the winner is the player who has the smallest sum. If the sums are equal one plays again, until the sums are not equal.

The ludeme

Code:

`(count (sites Between from:a to:b))`

gives me one unit less than the distance, but I don't know how to apply it to a list of sites, it seems to work only when a and b are sites. So I need

- a ludeme giving the distance between a site and a group of sites (I mean, the distance between the site and the nearest site in the group)

- a ludeme giving the total distance between a group of sites and another group of sites (I mean the sum of the values given by the ludeme above)

I see in the language reference that forEach is used either to set an action (like Move), or to filter sites (in the Regions functions) but there is no example of use of forEach to get a list of integers. At least I did not find one.

So how can I compute a sum of distances to get the score?

**Attached Files**

brassards3.lud (Size: 2.57 KB / Downloads: 1)