update Algorithmen/Brute Force
@@ -1 +1,24 @@
|
|||||||
Broot
|
# Beschreibung
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
jede Stelle die Rotation einer Zelle festlegt.
|
||||||
|
|
||||||
|
# Pseudocode
|
||||||
|
|
||||||
|
```
|
||||||
|
# Setup
|
||||||
|
for piece in board:
|
||||||
|
piece.direction = up
|
||||||
|
|
||||||
|
board[0][0].rotate_cw()
|
||||||
|
prev = board[0][0]
|
||||||
|
for piece in board[1:]:
|
||||||
|
if prev.direction = up:
|
||||||
|
piece.rotate_cw()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user