08-07-2020, 11:56 AM
Hi,
1. (sites LineOfSight Empty ...) should return all empty sites in line-of-sight. Isn't that what you're after?
2. When changing the (or (if (A)) (B)) structure to an if structure, note that you need to rebracket the second clause to make it mart of the "if" clause, i.e. (if (A) (B)) not (if (A)) (B). I'd suggest checking your bracketing carefully.
3. It's hard to advise on the scoring problem without knowing the rules of your game. If you want the score to be based on number of neighouring pieces then your formulation won't work as (count Neighbours ...) returns the number of sites that are neighbours, i.e. are adjacent. If you want to count the number of *occupied* neighbours, you can do something like the following (this is from the Game of Life, which will appear in an upcoming release):
(define "Nbors"
(count Sites
in:(intersection
(sites Around #1)
(sites Occupied by:#2)
)
)
)
then call it with ("Nbors" (to) Mover) or ("Nbors" (last To) Mover) or whatever is appropriate for your case.
Regards,
Cameron
1. (sites LineOfSight Empty ...) should return all empty sites in line-of-sight. Isn't that what you're after?
2. When changing the (or (if (A)) (B)) structure to an if structure, note that you need to rebracket the second clause to make it mart of the "if" clause, i.e. (if (A) (B)) not (if (A)) (B). I'd suggest checking your bracketing carefully.
3. It's hard to advise on the scoring problem without knowing the rules of your game. If you want the score to be based on number of neighouring pieces then your formulation won't work as (count Neighbours ...) returns the number of sites that are neighbours, i.e. are adjacent. If you want to count the number of *occupied* neighbours, you can do something like the following (this is from the Game of Life, which will appear in an upcoming release):
(define "Nbors"
(count Sites
in:(intersection
(sites Around #1)
(sites Occupied by:#2)
)
)
)
then call it with ("Nbors" (to) Mover) or ("Nbors" (last To) Mover) or whatever is appropriate for your case.
Regards,
Cameron