07-04-2021, 12:36 PM
Re the above post. I found the problem(s): it is a problem with (intersection ... )
I updated the file using the following define for placing the edge diagonals:
(define "HalfWayEdge"
(min
(difference
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(difference
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:1)))
))))
Insetead of this old one which doesn't work (intersection for arrays might be giving a union result instead?) meaning that (min finds the lowest of all, instead of the lowest of one value)
(define "HalfWayEdge"
(min
(intersection
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:1)))
)))
(define "SharedCells"
(intersection
(sites Around Cell (last To) Orthogonal)
(sites Around Cell (value) Orthogonal)
))
I used (min ...) to convert the result to an integer for the compiler because without it the script would not compile even though there is only one result (try removing it from the one that works to prove this)
I used (array ...) because I got
Unexpected syntax '(sites Incident Edge ...' in 'at:(intersection (sites Incid...'.
or
Unexpected syntax '(sites Incident Edge ...' in 'at:(difference (sites Inciden...'.
without it, but I don't know why that makes a difference. if (array ...) can understand the syntax, why can't (difference for regions or (intersection for regions understand it?
I use (value) in "SharedCells" to pass the integer into the middle of the processing of region functions.
------------------------------------
There is a separate bug:
This part of the script has a separate bug annotated in the comments in the script:
I have included netted not OK4.trl to illustrate the un desired effects - The Northerly diagonal connection is doubled instead of single, and the Southerly diagonal connection is doubled with its 2 levels in different states as well. Most of the time the script works correctly, but it fails when an orthogonal connector ("I" piece) is removed on the same placement.
(define "AddDiagonalMarkers"
// possible bug here:
// in "netted not OK4.trl" seems values from results were not unique
// or the remainder was performed twice for some other reason...
// happens specifically when an orthogonal has been removed at the placement site (last To) as well
// unaffected by absence of presence of count:2 in the removal.
// additionally some times the state is updated for the entire edge
// and sometimes the state is updated for level 0 of the edge.
// I need the state to update specifically the one edge added the given edge sites.
(forEach Value
(results
from:(last To)
to:(sites Around Cell (from) Diagonal
if:(and
(= (id "Ball" Mover) (what at:(to)))
(not
(is Within
(id "Ball" Mover)
in:(intersection
(sites Around Cell (from) Orthogonal)
(sites Around Cell (to) Orthogonal)
)))))
(to)
)
(and
(add
(piece (id "I" Mover))
(to Edge ("HalfWayEdge"))
)
(set State Edge
at:("HalfWayEdge")
level:(topLevel at:("HalfWayEdge"))
("D" (last To) (value))
))))
I updated the file using the following define for placing the edge diagonals:
(define "HalfWayEdge"
(min
(difference
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(difference
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:1)))
))))
Insetead of this old one which doesn't work (intersection for arrays might be giving a union result instead?) meaning that (min finds the lowest of all, instead of the lowest of one value)
(define "HalfWayEdge"
(min
(intersection
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:0)))
(array (sites Incident Edge of:Cell at:(regionSite ("SharedCells") index:1)))
)))
(define "SharedCells"
(intersection
(sites Around Cell (last To) Orthogonal)
(sites Around Cell (value) Orthogonal)
))
I used (min ...) to convert the result to an integer for the compiler because without it the script would not compile even though there is only one result (try removing it from the one that works to prove this)
I used (array ...) because I got
Unexpected syntax '(sites Incident Edge ...' in 'at:(intersection (sites Incid...'.
or
Unexpected syntax '(sites Incident Edge ...' in 'at:(difference (sites Inciden...'.
without it, but I don't know why that makes a difference. if (array ...) can understand the syntax, why can't (difference for regions or (intersection for regions understand it?
I use (value) in "SharedCells" to pass the integer into the middle of the processing of region functions.
------------------------------------
There is a separate bug:
This part of the script has a separate bug annotated in the comments in the script:
I have included netted not OK4.trl to illustrate the un desired effects - The Northerly diagonal connection is doubled instead of single, and the Southerly diagonal connection is doubled with its 2 levels in different states as well. Most of the time the script works correctly, but it fails when an orthogonal connector ("I" piece) is removed on the same placement.
(define "AddDiagonalMarkers"
// possible bug here:
// in "netted not OK4.trl" seems values from results were not unique
// or the remainder was performed twice for some other reason...
// happens specifically when an orthogonal has been removed at the placement site (last To) as well
// unaffected by absence of presence of count:2 in the removal.
// additionally some times the state is updated for the entire edge
// and sometimes the state is updated for level 0 of the edge.
// I need the state to update specifically the one edge added the given edge sites.
(forEach Value
(results
from:(last To)
to:(sites Around Cell (from) Diagonal
if:(and
(= (id "Ball" Mover) (what at:(to)))
(not
(is Within
(id "Ball" Mover)
in:(intersection
(sites Around Cell (from) Orthogonal)
(sites Around Cell (to) Orthogonal)
)))))
(to)
)
(and
(add
(piece (id "I" Mover))
(to Edge ("HalfWayEdge"))
)
(set State Edge
at:("HalfWayEdge")
level:(topLevel at:("HalfWayEdge"))
("D" (last To) (value))
))))