Why not shuffle the visible of layers in a document.
My approach to do the experiment of less is more
use framework "GameKit"
my shuffledBoolean:5
on shuffledBoolean:_amountInt
tell application "Pixelmator Pro"
repeat with i from 1 to (_amountInt as integer)
set theBoolean to (my shuffledObjects:{"true", "false"})
tell front document to tell layer i to set visible to item 1 of theBoolean
end repeat
end tell
end shuffledBoolean:
on shuffledObjects:_theArray
set theArray to current application's NSArray's arrayWithArray:_theArray
set randomSource to current application's GKRandomSource's alloc()'s init()
set shuffled to randomSource's arrayByShufflingObjectsInArray:theArray
return shuffled as list
end shuffledObjects: