SA <<
Previous Next >> Maze
SST
模擬與狀態追蹤(Simulation & State Tracking)
追蹤機器人狀態或環境變化。
# 範例 1:記錄走過的格子數
steps = 0
while not wall_in_front():
move()
steps += 1
# 範例 2:模擬方向轉動
def turn_right():
for _ in range(3):
turn_left()
# 範例 3:模擬狀態機(簡化)
state = "searching"
while state != "done":
if object_here():
take()
state = "done"
else:
move()
SA <<
Previous Next >> Maze