Erste Version

This commit is contained in:
wittmannzl103469 committed 2026-11-04 21:01:26 +01:00
commit 782b1850a3
1641 files changed
+512713

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
from functools import reduce
def is_clear(state, block):
return all([v != block for v in state.values()])
def move(block, target):
def action(state):
if not is_clear(state, block):
raise ValueError(f"Auf Block {block} liegt etwas!")
if target != "_" and not is_clear(state, target):
raise ValueError(f"Block {target} ist nicht frei!")
new_state = state.copy()
new_state[block] = target
return new_state
return action
def chain(f, g):
return lambda state: g(f(state))
identity = lambda state: state
start = {"A": "B", "B": "_", "C": "_", "D": "C"}
goal = {"A": "_", "B": "C", "C": "_", "D": "B"}
actions = [
move("A", "_"),
move("D", "_"),
move("B", "C"),
move("D", "B"),
]