02-20-2021, 02:28 AM
(This post was last modified: 02-20-2021, 04:11 AM by dale walton.)
Ok, I think I see the problem on my side: Ineed to store these values before moving, as the influence is currently recalculated after the move, and a move step one in thus included in the calculation. Sorry for the maybe false alarm. I haven't been able to correct this and need advice/help.
However this doesn't allow movement at all: What is wrong with it?
(define "MoveFriendly"
(forEach Piece
(do (set Var "PowerLeft" (- 7 ("InfluenceAt" (from))))
next:(if
(lt 0 (var "Powerleft"))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(var "Powerleft"))
if:(is Empty (to))
)
(then
(and
(set Var "PowerLeft" (- (var "Powerleft") (count Steps (last From) (last To))))
(set State at:(last To) (- (var "Powerleft") (count Steps (last From) (last To))))
)))))
Mover
))
-------------------------------------
buggy version that allowed movement was:
(define "MoveFriendly"
(forEach Piece
(if (lt 0 (- 7 ("InfluenceAt" (from))))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(- 7 ("InfluenceAt" (from))))
if:(is Empty (to))
)
(then
(and
(set Var "PowerLeft" (- (- 7 ("InfluenceAt" (last From))) (count Steps (last From) (last To))))
(set State at:(last To) (- (- 7 ("InfluenceAt" (last From))) (count Steps (last From) (last To))))
))))
Mover
))
-----------------------------
And this version does not allow continuation: (Powerleft/State end up at 0)- it also complains because the (set Var) is a non-decision move.
(define "MoveFriendly"
(forEach Piece
(if
(lt 0 (- 7 ("InfluenceAt" (from))))
(and
(set Var "PowerLeft" (- 7 ("InfluenceAt" (from))))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(- 7 ("InfluenceAt" (from))))
if:(is Empty (to))
))
(then
(and
(set Var "PowerLeft" (- (var "Powerleft") (count Steps (last From) (last To))))
(set State at:(last To) (- (var "Powerleft") (count Steps (last From) (last To))))
))))
Mover
))
However this doesn't allow movement at all: What is wrong with it?
(define "MoveFriendly"
(forEach Piece
(do (set Var "PowerLeft" (- 7 ("InfluenceAt" (from))))
next:(if
(lt 0 (var "Powerleft"))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(var "Powerleft"))
if:(is Empty (to))
)
(then
(and
(set Var "PowerLeft" (- (var "Powerleft") (count Steps (last From) (last To))))
(set State at:(last To) (- (var "Powerleft") (count Steps (last From) (last To))))
)))))
Mover
))
-------------------------------------
buggy version that allowed movement was:
(define "MoveFriendly"
(forEach Piece
(if (lt 0 (- 7 ("InfluenceAt" (from))))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(- 7 ("InfluenceAt" (from))))
if:(is Empty (to))
)
(then
(and
(set Var "PowerLeft" (- (- 7 ("InfluenceAt" (last From))) (count Steps (last From) (last To))))
(set State at:(last To) (- (- 7 ("InfluenceAt" (last From))) (count Steps (last From) (last To))))
))))
Mover
))
-----------------------------
And this version does not allow continuation: (Powerleft/State end up at 0)- it also complains because the (set Var) is a non-decision move.
(define "MoveFriendly"
(forEach Piece
(if
(lt 0 (- 7 ("InfluenceAt" (from))))
(and
(set Var "PowerLeft" (- 7 ("InfluenceAt" (from))))
(move
(from (from))
(to
(sites Direction from:(from) Orthogonal distance:(- 7 ("InfluenceAt" (from))))
if:(is Empty (to))
))
(then
(and
(set Var "PowerLeft" (- (var "Powerleft") (count Steps (last From) (last To))))
(set State at:(last To) (- (var "Powerleft") (count Steps (last From) (last To))))
))))
Mover
))