class_name RandomBot extends RefCounted ## Baseline bot (bots/random.ts): ends the step or passes 30% of the time, otherwise picks any legal ## action. Choices are picked at random too. ## ## A bot has `bot_name` and `choose(view, actions, me) -> action`, picking one of `actions` for ## player `me` while seeing only `view` (see RulesEngine.view_for). Bots are made per game, from a ## seed, so they can keep per-game memory. var bot_name := "random" var _rng: Dictionary func _init(seed: int) -> void: _rng = Rng.make(seed) func choose(_view: Dictionary, actions: Array, _me: int) -> Dictionary: var stop = null var others := [] for a in actions: if a.type == "end" or a.type == "pass": if stop == null: stop = a else: others.append(a) if others.is_empty(): return stop if stop != null else actions[0] if stop != null and Rng.next_float(_rng) < 0.3: return stop var choices := others.filter(func(a): return a.type == "choose") return Rng.pick(_rng, choices if not choices.is_empty() and Rng.next_float(_rng) < 0.8 else others)