# Tellmark bot track: minimal example client. # pip install websockets (version 12 or newer) # python tellmark_bot.py tm_yourkey -> 1 practice game # python tellmark_bot.py tm_yourkey final -> your final (50 hidden deals, 1 per 24 h) import json, random, sys from websockets.sync.client import connect KEY = sys.argv[1] MODE = sys.argv[2] if len(sys.argv) > 2 else "practice" URL = f"wss://tellmark.plsintro.com/bot?key={KEY}&mode={MODE}&games=1" TWIN = {"circle": "square", "square": "circle", "triangle": "bar", "bar": "triangle"} def decide(s): """Return one action for this step, or None to pass.""" hand = s["hand"] # The suit you hold most is often the 12-card suit, so its twin is a fair first guess for the target. target = TWIN[max(hand, key=hand.get)] if s["phase"] == "guess": return {"t": "guess", "suit": target, "confidence": 0.4} if s["phase"] == "question": return {"t": "answer", "seat": random.choice([0, 1, 2, 3]), "why": "example bot"} if s["phase"] != "trading": return None ask = s["books"][target]["ask"] if ask and ask["player"] != 0 and ask["price"] <= 6: return {"t": "take", "suit": target, "dir": "buy", "limit": ask["price"]} for suit, n in hand.items(): bid = s["books"][suit]["bid"] if suit != target and n > 0 and bid and bid["player"] != 0 and bid["price"] >= 3: return {"t": "take", "suit": suit, "dir": "sell", "limit": bid["price"]} return None with connect(URL) as ws: for raw in ws: m = json.loads(raw) if m["t"] == "state": if m.get("error"): print("rejected:", m["error"]) ws.send(json.dumps({"t": "act", "step": m["step"], "a": decide(m)})) elif m["t"] == "result": print("game", m["game"], "score", m["total"]) elif m["t"] in ("final", "msg", "hello"): print(m)