Update Algorithmen/Brute Force

2026-06-08 09:19:48 +00:00
parent aebeb5d994
commit 1da4e51467

@@ -1,24 +1,26 @@
# Beschreibung # Beschreibung
Dieses Algorithmus löst das Spiel, indem es jede einzelne möglichkeit Dieses Algorithmus löst das Spiel, indem es jede einzelne möglichkeit
ausprobiert, bis es die lösung findet. Das macht es, indem es das erste Feld ausprobiert, bis es die lösung findet. Das macht es, indem es das erste Feld
dreht und wenn es dann in seine ursprüngliche richtung zeigt, wird das nächste dreht und wenn es dann in seine ursprüngliche richtung zeigt, wird das nächste
auch gedreht. Dies kann man auch sehen als ein Aufzählen einer base-4 Nummer, wo auch gedreht. Dies kann man auch sehen als ein Aufzählen einer base-4 Nummer, wo
jede Stelle die Rotation einer Zelle festlegt. jede Stelle die Rotation einer Zelle festlegt.
# Pseudocode # Pseudocode
``` ```
# Setup # Setup
for piece in board: for piece in board:
piece.direction = up piece.direction = up
board[0][0].rotate_cw() # Lösen
prev = board[0][0] while not solved:
for piece in board[1:]: board[0][0].rotate_cw()
if prev.direction = up: prev = board[0][0]
piece.rotate_cw() for piece in board[1:]:
else: if prev.direction == up:
break piece.rotate_cw()
``` else:
break
```