xabbo-scripts/Scripts/Snake Target Probe.csx
Administrator 7a548130a3 Move all scripts into Scripts/ subfolder
Keeps the repo root clean - only README.md visible on landing page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 09:49:37 +01:00

47 lines
1.2 KiB
C#

/// @name Snake Target Probe
using System;
using System.Linq;
using System.Collections.Generic;
const int MIN_X = 37, MAX_X = 59, MIN_Y = 29, MAX_Y = 51;
bool InBoard(dynamic i)
=> i != null && i.Location.X >= MIN_X && i.Location.X <= MAX_X && i.Location.Y >= MIN_Y && i.Location.Y <= MAX_Y;
var map = new Dictionary<long, (int kind, int x, int y, int state)>();
foreach (var i in FloorItems)
{
if (!InBoard(i)) continue;
map[i.Id] = ((int)i.Kind, i.Location.X, i.Location.Y, (int)i.State);
}
Log("Snake Target Probe started");
Log("Watching board item state/move changes...");
while (Run)
{
Delay(100);
foreach (var i in FloorItems)
{
if (!InBoard(i)) continue;
int kind = (int)i.Kind;
int x = i.Location.X;
int y = i.Location.Y;
int state = (int)i.State;
if (!map.TryGetValue(i.Id, out var prev))
{
map[i.Id] = (kind, x, y, state);
Log($"add id={i.Id} kind={kind} pos=({x},{y}) state={state}");
continue;
}
if (prev.x != x || prev.y != y || prev.state != state)
{
Log($"chg id={i.Id} kind={kind} ({prev.x},{prev.y})/{prev.state} -> ({x},{y})/{state}");
map[i.Id] = (kind, x, y, state);
}
}
}