KAZIK/tools/tests/prepare_clover_fixtures.py
Artvasil09 881a0061dc Add native NPC visitors with contracts, Clover slots, Pyramid, and party table scenes
Implement 32x32 BFS visitor navigation and daily contracts system with companion .npc journals; add native assembly scenes for Clover slots, Pyramid cards, Blackjack Party and Russian Party; package animation and sprite packs; add comprehensive offline test suites and rebuild shipping binaries.
2026-10-13 09:47:33 +03:00

55 lines
2.1 KiB
Python

"""Independent offline oracle for the original Clover combo contract."""
from pathlib import Path
from random import Random
ROOT = Path(__file__).resolve().parents[2]
VALUES = [3, 2, 2, 3, 5, 5, 7]
PATTERNS = [([0, 4, 7, 10, 14], 8),
([0, 1, 2, 3, 4], 7), ([10, 11, 12, 13, 14], 7),
([10, 6, 2, 8, 14], 4), ([0, 6, 12, 8, 4], 4)]
PATTERNS += [(list(range(row * 5, row * 5 + 5)), 3) for row in range(3)]
PATTERNS += [(list(range(row * 5 + col, row * 5 + col + 4)), 2)
for row in range(3) for col in range(2)]
PATTERNS += [([col, col + 5, col + 10], 1) for col in range(5)]
PATTERNS += [([0, 6, 12], 1), ([1, 7, 13], 1), ([2, 8, 14], 1),
([10, 6, 2], 1), ([11, 7, 3], 1), ([12, 8, 4], 1)]
PATTERNS += [(list(range(row * 5 + col, row * 5 + col + 3)), 1)
for row in range(3) for col in range(3)]
def evaluate(board):
blocked = win = total = count = 0
jackpot = int(len(set(board)) == 1)
if jackpot:
total, count, win = VALUES[board[0]] * 10, 1, 32767
for cells, factor in PATTERNS:
bits = sum(1 << cell for cell in cells)
if len({board[cell] for cell in cells}) != 1 or blocked & bits == bits:
continue
blocked |= bits
win |= bits
total += VALUES[board[cells[0]]] * factor
count += 1
return total, count, win, jackpot
def main():
rng = Random(5315)
boards = [[symbol] * 15 for symbol in range(7)]
for cells, _ in PATTERNS:
board = [(i * 3 + i // 5) % 7 for i in range(15)]
for cell in cells:
board[cell] = 6
boards.append(board)
boards += [[rng.randrange(7) for _ in range(15)] for _ in range(512)]
lines = ["; Mechanically generated offline reference vectors.", ".data",
f"clpFixtureCount3D equ {len(boards)}", "clpFixtures3D label DWORD"]
for board in boards:
lines.append(" dd " + ",".join(map(str, [*board, *evaluate(board)])))
lines.append(".code")
(ROOT / "tools/tests/clover_fixtures.inc").write_text("\n".join(lines) + "\n", encoding="ascii")
print(f"Prepared {len(boards)} independent Clover boards")
if __name__ == "__main__":
main()