MSP-01.2-Snake: A Compact Convolutional Model for Snake
2 min readupdated
This compact model features just 317K parameters and is trained to play classic Snake on a 10 by 10 grid. It takes a four-channel state matrix as input (snake head, body gradient, apple, and movement hints) and outputs the optimal direction for the next move. Compared to the first version, the training dataset has been expanded to two million simulations, and penalties for wall and tail collisions have been added. This project is ideal for reinforcement learning researchers and enthusiasts experimenting with compact architectures.
Key features
- High accuracy: the model achieves 99.5% full board clears on new test seeds.
- Compact size: weighs around 1.3 megabytes in fp32 Safetensors format.
- Fast performance: running forty full games on a CPU takes only about four seconds.
- Reliability: zero collision-related deaths were recorded during tests across two hundred unseen seeds.
What you can do
- Run autonomous Snake games using the built-in inference script to evaluate strategy.
- Test the model's behavior on custom seeds and verify move stability.
- Use the architecture as an educational example for studying convolutional models in game environments.
Example
from huggingface_hub import snapshot_download
from snake_v1.env import SnakeEnv
from snake_v1.model import SnakeVisionNet
local_dir = snapshot_download("Manprot/MSP-01.2-Snake")
model = SnakeVisionNet.from_pretrained(local_dir)
env = SnakeEnv(board_size=10, seed=80000)
obs, info = env.reset(seed=80000)
done = False
while not done:
action = model.act_numpy(obs, action_mask=env.valid_action_mask(), deterministic=True)
obs, reward, done, events, info = env.step(action)
print(f"Score: {info['score']}/97 | Full clear: {info['board_cleared']}")Read more
DetailsBenchmarks: the average result is 96.74 apples out of a possible 97.
Hardware: any CPU or GPU works, as weight size is minimal.
Limitations: fixed 10 by 10 grid geometry; fine-tuning is required if the size changes.
Training: 14 epochs using the AdamW optimizer and a cosine learning rate scheduler.










Comments