From 7164d0521800801b3b046008cc2606866daf9ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 4 Nov 2020 10:35:11 +0100 Subject: [PATCH] Coroutines --- README.md | 4 ++-- index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fe462ac..8c9259c 100644 --- a/README.md +++ b/README.md @@ -2307,9 +2307,9 @@ async def human_controller(screen, moves): async def model(moves, state, height, width): while state['*'] not in {p for id_, p in state.items() if id_ != '*'}: id_, d = await moves.get() - p = state[id_] + p = state[id_] deltas = {D.n: P(0, -1), D.e: P(1, 0), D.s: P(0, 1), D.w: P(-1, 0)} - new_p = P(p.x + deltas[d].x, p.y + deltas[d].y) + new_p = P(p.x + deltas[d].x, p.y + deltas[d].y) if 0 <= new_p.x < width-1 and 0 <= new_p.y < height: state[id_] = new_p diff --git a/index.html b/index.html index f525b5e..9edea51 100644 --- a/index.html +++ b/index.html @@ -2017,9 +2017,9 @@ D = enum.Enum('D', 'n async def model(moves, state, height, width): while state['*'] not in {p for id_, p in state.items() if id_ != '*'}: id_, d = await moves.get() - p = state[id_] + p = state[id_] deltas = {D.n: P(0, -1), D.e: P(1, 0), D.s: P(0, 1), D.w: P(-1, 0)} - new_p = P(p.x + deltas[d].x, p.y + deltas[d].y) + new_p = P(p.x + deltas[d].x, p.y + deltas[d].y) if 0 <= new_p.x < width-1 and 0 <= new_p.y < height: state[id_] = new_p