skills/tabular/game-state-grid-encoding/SKILL.md
Encode a 2D game board into a normalized multi-channel feature tensor with log-scaled resources, signed unit counts, and directional features for RL agents
npx skillsauth add wenmin-wu/ds-skills tabular-game-state-grid-encodingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Game AI competitions often provide board state as nested objects (cells, fleets, shipyards). Converting this into a fixed-size tensor with per-cell feature channels enables CNN or MLP-based RL agents. Each channel encodes a different aspect: log-scaled resources, signed unit counts (+1 for friendly, -1 for enemy), direction values, and structure presence.
import numpy as np
N_FEATURES = 4 # kore, ships, direction, shipyard
def encode_board(board, player_id):
size = board.configuration.size
state = np.zeros((size, size, N_FEATURES), dtype=np.float32)
for point, cell in board.cells.items():
state[point.y, point.x, 0] = cell.kore
if cell.fleet:
sign = 1 if cell.fleet.player_id == player_id else -1
state[point.y, point.x, 1] = sign * cell.fleet.ship_count
state[point.y, point.x, 2] = cell.fleet.direction.value
if cell.shipyard:
state[point.y, point.x, 3] = 1 if cell.shipyard.player_id == player_id else -1
state[:, :, 0] = np.clip(np.log2(state[:, :, 0] + 1) / 10.0, 0, 1)
state[:, :, 1] = np.clip(state[:, :, 1] / 100.0, -1, 1)
return state
(board_size, board_size, n_features)data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF