Solve final paired stages by splitting one and merging only the intended group
This commit is contained in:
@@ -34,13 +34,13 @@ function RevealBall([int]$Stage,[string]$Id,[string]$Name) {
|
||||
}
|
||||
throw "No safe first-hit view for actual ball $Id within a full native orbit."
|
||||
}
|
||||
function MergeReal([int]$Stage,[string]$Name) {
|
||||
function MergeReal([int]$Stage,[string]$Name,[int]$SourceCount=0,[int]$TargetCount=0) {
|
||||
for($attempt=0;$attempt-lt16;$attempt++) {
|
||||
$before=Save "$Name-before-$attempt"; $board=Board $before $Stage
|
||||
if($null-eq$board){return $before}
|
||||
$oldCount=$board.groups.Count
|
||||
$rotation=[Numerics.Quaternion]::new($board.camera.rotation.x,$board.camera.rotation.y,$board.camera.rotation.z,$board.camera.rotation.w)
|
||||
$pairs=@(foreach($source in $board.groups){foreach($target in $board.groups){if($source.id-eq$target.id){continue};foreach($sid in $source.ballIds){foreach($tid in $target.ballIds){
|
||||
$pairs=@(foreach($source in $board.groups){foreach($target in $board.groups){if($source.id-eq$target.id-or($SourceCount-gt0-and$source.ballIds.Count-ne$SourceCount)-or($TargetCount-gt0-and$target.ballIds.Count-ne$TargetCount)){continue};foreach($sid in $source.ballIds){foreach($tid in $target.ballIds){
|
||||
$s=@($board.balls|Where-Object id -eq $sid)[0].position; $t=@($board.balls|Where-Object id -eq $tid)[0].position
|
||||
$delta=[Numerics.Vector3]::Transform([Numerics.Vector3]::new($s.x-$t.x,$s.y-$t.y,$s.z-$t.z),[Numerics.Quaternion]::Inverse($rotation))
|
||||
[pscustomobject]@{sid=$sid;tid=$tid;depth=[Math]::Abs($delta.Z);size=$source.ballIds.Count}
|
||||
@@ -54,16 +54,17 @@ function MergeReal([int]$Stage,[string]$Name) {
|
||||
Step "$Name-drag-$attempt" @('shell','input','swipe',"$($start[0])","$($start[1])","$($end[0]+$offset)","$($end[1])",'500')
|
||||
$after=Save "$Name-after-$attempt"; $newBoard=Board $after $Stage
|
||||
if($null-eq$newBoard-or$newBoard.groups.Count-lt$oldCount){return $after}
|
||||
$board=$newBoard
|
||||
}
|
||||
Orbit "$Name-orbit-$attempt" $board
|
||||
}
|
||||
throw "Native merge bound reached for Stage $Stage; all actual attempts retained."
|
||||
}
|
||||
function SplitReal([int]$Stage,[int]$Selected,[string]$Name) {
|
||||
function SplitReal([int]$Stage,[int]$Selected,[string]$Name,[string]$OnlyId='') {
|
||||
for($attempt=0;$attempt-lt8;$attempt++) {
|
||||
$before=Save "$Name-before-$attempt"; $board=Board $before $Stage
|
||||
$group=@($board.groups|Sort-Object {$_.ballIds.Count} -Descending)[0]
|
||||
$ids=@(if($Stage-eq13-and$Selected-eq2){$group.ballIds[0];$group.ballIds[-1]}else{$group.ballIds|Select-Object -First $Selected})
|
||||
$ids=@(if($OnlyId){$OnlyId}elseif($Stage-eq13-and$Selected-eq2){$group.ballIds[0];$group.ballIds[-1]}else{$group.ballIds|Select-Object -First $Selected})
|
||||
$mode=$false
|
||||
foreach($chooseId in @($ids[-1])+@($group.ballIds)){
|
||||
$board=RevealBall $Stage $chooseId "$Name-choose-reveal-$attempt-$chooseId"
|
||||
@@ -183,6 +184,16 @@ try {
|
||||
Check 'partial2-exact-restored' (Same $partialBoard (Board (Save 'partial2-restored') 2)) 'OriginalIDs positions membership collected counted camera exact'
|
||||
}
|
||||
CountRemaining $stage|Out-Null
|
||||
} elseif($stage-eq29-or$stage-eq30) {
|
||||
# 5+3 -> 4+1+3 -> 4+4; 6+4 -> 5+1+4 -> 5+5, using only normal group controls.
|
||||
$other=if($stage-eq29){3}else{4}
|
||||
for($pairAttempt=0;$pairAttempt-lt4;$pairAttempt++){
|
||||
$pairBoard=Board (Save "stage-$stage-pair-$pairAttempt") $stage
|
||||
if(!$pairBoard){break}
|
||||
$large=@($pairBoard.groups|Sort-Object {$_.ballIds.Count} -Descending)[0]
|
||||
SplitReal $stage 1 "stage-$stage-take-one-$pairAttempt" $large.ballIds[-1]|Out-Null
|
||||
MergeReal $stage "stage-$stage-one-plus-$other-$pairAttempt" 1 $other|Out-Null
|
||||
}
|
||||
} else {
|
||||
if($original.groups.Count-gt1){MergeReal $stage "stage-$stage-merge"|Out-Null}
|
||||
if($splitSizes.ContainsKey($stage)){SplitReal $stage $splitSizes[$stage] "stage-$stage-split"|Out-Null}
|
||||
|
||||
Reference in New Issue
Block a user