rendered paste body;#include <Array.au3>
Dim $grid[11][11][2]
For $y = -5 to 5 step 1
For $x = -5 to 5 step 1
$grid[$x + 5][$y + 5][0] = Sqrt((Abs($x)^2) + (Abs($y)^2))
Next
Next
Dim $CurrentDistance[1]
$CurrentDistance[0] = $grid[0][0][0]
$Index = 0
Do
For $y = 0 to UBound($grid, 1) - 1
If ($x = 10) And ($y = 10) Then ExitLoop 3
For $x = 0 To UBound($grid, 2) - 1
ToolTip($x & ", " & $y & ", " & $Index)
;Sleep(50)
If $grid[$x][$y][0] < $CurrentDistance[$Index] Then
For $z = $Index To 0 Step - 1
If $CurrentDistance[$z] <= $grid[$x][$y][0] Then
$Index = $z
$CurrentDistance[$Index] = $grid[$x][$y][0]
$grid[$x][$y][1] = $Index
ContinueLoop 3
EndIf
Next
$Index = 0
$CurrentDistance[$Index] = $grid[$x][$y][0]
$grid[$x][$y][1] = $Index
ExitLoop 2
ElseIf $grid[$x][$y][0] = $CurrentDistance[$Index] Then
$grid[$x][$y][1] = $Index
ElseIf $grid[$x][$y][0] > $CurrentDistance[$Index] Then
For $z = $Index To UBound($CurrentDistance) - 1
If $CurrentDistance[$z] = $grid[$x][$y][0] Then
$Index = $z
$grid[$x][$y][1] = $Index
ContinueLoop 3
EndIf
Next
$Index = $Index + 1
ReDim $CurrentDistance[$Index + 1]
$CurrentDistance[$Index] = $grid[$x][$y][0]
$grid[$x][$y][1] = $Index
Else
MsgBox(0, "Euclidean Distance model", "Wtf??")
Exit
EndIf
Next
Next
Until ($x = 10) And ($y = 10)
Dim $String = "Euclidean Distance by rank:" & @CRLF & @CRLF & "| "
;For $z = 0 To 1
For $y = 0 To UBound($grid, 1) - 1
For $x = 0 To UBound($grid, 2) - 1
$String = $String & Round($grid[$x][$y][0]) & " | "
Next
$String = $String & @CRLF & "----------------------------------------------" & @CRLF & "| "
Next
;Next
MsgBox(0, "Euclidean Distance Model", $String)
Exit