09-18-2020, 12:22 AM
I upload a modified version, which gets closer to what I want to do, but does not compile. The problem is, I am improperly using forEach but I don't know why. Now, I am trying to make it so players first select a cell to remove stacks from (as long as the cells contain fewer discs than friendly pieces in line of sight), and then add a disc to that location for each friendly piece in line of sight. Something is not compiling, but from the language reference it seems that I'm using forEach as intended.
(game "Tumbleweed"
(players 2)
(equipment
{
(board (hex 5))
(piece "Disc" Each)
//(stackType Count)
}
)
(rules
(start (place Random {"Disc1" "Disc2"}))
(play
(move
Remove
(to (
forEach (sites Board)
if:(
and
(
(> (count Pieces Mover in:(sites LineOfSight at:(to))) 0)
// place stacks in line of sight of friendly stacks
(> (count Pieces Mover in:(sites LineOfSight at:(to))) (topLevel at:(to)))
// You can only replace an old stack if the newly placed stack is larger
)
)
)
)
(then
(forEach Piece Mover in:(sites LineOfSight at:(to))
(add (piece (id "Disc" Mover)) (to))
)
)
// Height of the new stack is equal to number of friendly pieces in line of sight
stack:true
)
)
(end
(if
(no Moves Next)
(byScore
{
(score P1 (count sites in:(sites Occupied by:P1)))
(score P2 (count sites in:(sites Occupied by:P2)))
}
)
)
)
)
)
(game "Tumbleweed"
(players 2)
(equipment
{
(board (hex 5))
(piece "Disc" Each)
//(stackType Count)
}
)
(rules
(start (place Random {"Disc1" "Disc2"}))
(play
(move
Remove
(to (
forEach (sites Board)
if:(
and
(
(> (count Pieces Mover in:(sites LineOfSight at:(to))) 0)
// place stacks in line of sight of friendly stacks
(> (count Pieces Mover in:(sites LineOfSight at:(to))) (topLevel at:(to)))
// You can only replace an old stack if the newly placed stack is larger
)
)
)
)
(then
(forEach Piece Mover in:(sites LineOfSight at:(to))
(add (piece (id "Disc" Mover)) (to))
)
)
// Height of the new stack is equal to number of friendly pieces in line of sight
stack:true
)
)
(end
(if
(no Moves Next)
(byScore
{
(score P1 (count sites in:(sites Occupied by:P1)))
(score P2 (count sites in:(sites Occupied by:P2)))
}
)
)
)
)
)