06-30-2021, 05:42 PM
I often find my self in the predicament that I want to refer to two different values that has the same variable-name. Here is an example:
I am trying to figure out how to detect a flanked arc (as defined in this thread), and am currently trying to see if I can use (count Steps) to detect a path of enemy pieces between two friendly pieces. In the course of thinking through how to do this, I was stopped by a clash between variable names.
The line I have marked "THIS LINE" is obviously useless. But what I want to do is to differentiate between what (to) refers to in the scope of (step (to if:(…))) and what it refers to in (move Select (to if:(…))) outside of (step (to if:(…))).
Since this shows up so often, I thought it would be worth asking: Could there be implemented a general solution to this?
I am trying to figure out how to detect a flanked arc (as defined in this thread), and am currently trying to see if I can use (count Steps) to detect a path of enemy pieces between two friendly pieces. In the course of thinking through how to do this, I was stopped by a clash between variable names.
Code:
(move Select
(from (sites Occupied by:Mover))
(to
(sites Occupied by:Mover)
if:(>
(count Sites in:(sites Board))
(count Steps
(step
(to
if:(or
(= (next) (who at:(to)))
(= (to) (to)) //<----- THIS LINE
)
)
)
(from)
(to)
)
)
)
)
Since this shows up so often, I thought it would be worth asking: Could there be implemented a general solution to this?