Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e257b7b

Browse files
committed
Coroutines
1 parent ac99928 commit e257b7b

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
@@ -2292,7 +2292,8 @@ async def main_coroutine(screen):
22922292

22932293
async def random_controller(id_, moves):
22942294
while True:
2295-
moves.put_nowait((id_, random.choice(list(D))))
2295+
move = id_, random.choice(list(D))
2296+
moves.put_nowait(move)
22962297
await asyncio.sleep(random.random() / 2)
22972298

22982299
async def human_controller(screen, moves):

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,8 @@
20152015

20162016
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">random_controller</span><span class="hljs-params">(id_, moves)</span>:</span>
20172017
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
2018-
moves.put_nowait((id_, random.choice(list(D))))
2018+
move = id_, random.choice(list(D))
2019+
moves.put_nowait(move)
20192020
<span class="hljs-keyword">await</span> asyncio.sleep(random.random() / <span class="hljs-number">2</span>)
20202021

20212022
<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>

0 commit comments

Comments
 (0)