11-23-2020, 09:34 AM
Hi,
The moves described in a piece generator have to be described for each piece individually. That's why in 99% of the case they refer to the ludeme (from) which is used to indicate the position of each piece in iterating them with the ludeme (forEach Piece).
In your fail file, the (from ...) description is not for a single piece, but to move to a set of sites to another.
Consequently for each piece individually all these moves will be computed, which is wrong.
If you want a such description in the moves generator of a piece you need to have a condition for each piece in the (from ...) ludeme.
Moreover the (forEach Piece) refers to a container (by default the board). Consequently if you want to check some pieces which are in another container like the hand of the players you have to specific the container.
Here the full description doing that:
Regards,
Eric
The moves described in a piece generator have to be described for each piece individually. That's why in 99% of the case they refer to the ludeme (from) which is used to indicate the position of each piece in iterating them with the ludeme (forEach Piece).
In your fail file, the (from ...) description is not for a single piece, but to move to a set of sites to another.
Consequently for each piece individually all these moves will be computed, which is wrong.
If you want a such description in the moves generator of a piece you need to have a condition for each piece in the (from ...) ludeme.
Moreover the (forEach Piece) refers to a container (by default the board). Consequently if you want to check some pieces which are in another container like the hand of the players you have to specific the container.
Here the full description doing that:
Code:
(define "MoveOntoBoard"
(move
(from if:(is In (from) (sites Hand Mover)))
(to (sites Outer))
)
)
//-------------------------------------------------------------------------
(game "Test"
(players 2)
(equipment {
(board (rectangle 4 3))
(piece "Ball" Each ("MoveOntoBoard"))
(hand Each)
})
(rules
(start {
(place Stack "Ball1" (handSite P1))
(place Stack "Ball2" (handSite P2))
})
(play
(forEach Piece container:(mover))
)
(end (if (no Moves Next) (result Mover Win)))
)
)
Regards,
Eric