캔버스를 생각하면 10x10이라고 가정하고 3 개의 직사각형/사각형이 제공됩니다.재귀 함수 수정에 대한 도움말
캔버스 =
10 × 10 사각형 1 = 2 × 2 사각형 2 = 3 × 3 사각형 3 = 나는 캔버스에 모든 사각형의 모든 위치를 루프 재귀 함수를 만들었습니다,하고 작동
× 4 벌금. (나는 누군가가 그것을보고 싶어하는 다음 함수를 포함 시켰지만 그것이 필요하다고 생각하지는 않는다).
직사각형 1과 2는 회전 할 수없는 IE라는 것을 알 수 있습니다.이 중 하나를 90도 회전 시키면 본질적으로 같은 모양입니다. 그러나 직사각형 3은 회전 가능합니다.
모든 순환 게재와 함께 모든 직사각형의 모든 위치를 반복하도록 순환/순환 기능을 변경/구성하는 방법은 무엇입니까?
가능한 목표는 캔버스의 모든 모양을 피팅하는 것입니다.
도움 주셔서 감사합니다.
Sub recurse(ByVal startPoint As Integer)
Dim x As Integer
Dim y As Integer
Dim validSolution As Boolean = isSolutionValid()
Dim loopXTo As Integer
Dim loopYTo As Integer
Dim solutionRating As Integer
'If parent nodes create invalid solution, we can skip (375 iterations from 1,600 iterations saving)
If validSolution = True Then
If (startPoint = 0) Then
loopXTo = Math.Floor((canvasCols - squareObjects(startPoint).sqRows())/2) '576 iterations from 1,680 iterations
loopYTo = Math.Floor((canvasRows - squareObjects(startPoint).sqCols)/2) '31,104 iterations from 90,720 iterations
Else
loopXTo = canvasCols - squareObjects(startPoint).sqRows
loopYTo = canvasRows - squareObjects(startPoint).sqCols
End If
'Loop all positions on canvas
For x = 0 To loopXTo
For y = 0 To loopYTo
'Set coords of square
squareObjects(startPoint).setSquareCords(x, y)
'Phyiscally place it in canvas
placeSquareOnCanvas(x, y, squareObjects(startPoint).sqRows, squareObjects(startPoint).sqCols)
'Recursive, get next square
If (startPoint + 1 < totalSquares) Then
recurse(startPoint + 1)
Else
validSolution = isSolutionValid()
'Is solution valud
If (validSolution = True) Then
solutions = solutions + 1
End If
iterations = iterations + 1
'Response.Write("<br /><b>Iteration " & iterations & "</b>")
If (validSolution) Then
'Rate solution, record if best
solutionRating = rateSolution()
If solutionRating > bestCellSaving Then
bestCellSaving = solutionRating
copySolution()
End If
'Response.Write(" <span style='color:green'> <B>VALID SOLUTION</B></span> (" & rateSolution() & ")")
End If
'printCanvas(canvas)
End If
squareObjects(startPoint).removeSquare(canvas)
Next
Next
End If
End Sub
솔루션을 아직 찾지 못했기 때문에 현상금을 추가하고 있습니다. 그냥 명확하게하기 위해 캔버스에있는 모든 모양의 모든 위치를 반복하려고합니다 (이미 완료되었습니다). 모든 회전마다 모든 모양의 모든 위치를 반복하도록 수정해야합니다. 기본적으로 모든 위치 조합! –