Skip to content

Commit 2c8b218

Browse files
committed
Coroutines
1 parent f80c951 commit 2c8b218

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,8 @@ async def random_controller(id_, moves):
22942294
await asyncio.sleep(random.random() / 2)
22952295

22962296
async def human_controller(screen, moves):
2297-
while (ch := screen.getch()) != 27:
2297+
while True:
2298+
ch = screen.getch()
22982299
key_mappings = {259: D.n, 261: D.e, 258: D.s, 260: D.w}
22992300
if ch in key_mappings:
23002301
moves.put_nowait(('*', key_mappings[ch]))

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,8 @@
19901990
<span class="hljs-keyword">await</span> asyncio.sleep(random.random() / <span class="hljs-number">2</span>)
19911991

19921992
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">human_controller</span><span class="hljs-params">(screen, moves)</span>:</span>
1993-
<span class="hljs-keyword">while</span> (ch := screen.getch()) != <span class="hljs-number">27</span>:
1993+
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
1994+
ch = screen.getch()
19941995
key_mappings = {<span class="hljs-number">259</span>: D.n, <span class="hljs-number">261</span>: D.e, <span class="hljs-number">258</span>: D.s, <span class="hljs-number">260</span>: D.w}
19951996
<span class="hljs-keyword">if</span> ch <span class="hljs-keyword">in</span> key_mappings:
19961997
moves.put_nowait((<span class="hljs-string">'*'</span>, key_mappings[ch]))

0 commit comments

Comments
 (0)