Removed reading of incoming events bc why not
This commit is contained in:
parent
ebe6fab9c6
commit
72b8c6274b
13
async-bot.py
13
async-bot.py
|
@ -37,7 +37,6 @@ class AsyncBotManager:
|
||||||
if a:
|
if a:
|
||||||
self.difference[x + ox + (y + oy) * 1000] = l > 0
|
self.difference[x + ox + (y + oy) * 1000] = l > 0
|
||||||
|
|
||||||
|
|
||||||
async def listener(self):
|
async def listener(self):
|
||||||
async with ClientSession() as http:
|
async with ClientSession() as http:
|
||||||
async with http.get(f"{self.base}/api/initial-state") as req:
|
async with http.get(f"{self.base}/api/initial-state") as req:
|
||||||
|
@ -75,16 +74,10 @@ class AsyncBotManager:
|
||||||
async with AsyncSimpleClient(http_session=http) as sio:
|
async with AsyncSimpleClient(http_session=http) as sio:
|
||||||
await sio.connect(f"{self.base}/socket.io")
|
await sio.connect(f"{self.base}/socket.io")
|
||||||
while not self._shutdown:
|
while not self._shutdown:
|
||||||
try:
|
index, expected = choice(list(self.difference.items()))
|
||||||
event, data = await sio.receive(0.1)
|
|
||||||
if event not in ("full_state", "batched_bit_toggles"):
|
|
||||||
print(bot_index, "!!!", event, data)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
index, target = choice(list(self.difference.items()))
|
|
||||||
y, x = divmod(index, 1000)
|
y, x = divmod(index, 1000)
|
||||||
curr = self.canvas.getpixel((x, y)) > 0 # type: ignore
|
current = self.canvas.getpixel((x, y)) > 0 # type: ignore
|
||||||
if curr != target:
|
if current != expected:
|
||||||
print(bot_index, "swap", x, y)
|
print(bot_index, "swap", x, y)
|
||||||
await sio.emit("toggle_bit", {
|
await sio.emit("toggle_bit", {
|
||||||
"index": index
|
"index": index
|
||||||
|
|
Loading…
Reference in New Issue