DECOY: Building a One-Button Pursuit Game with Predictive Drones in MATLAB

For the MATLAB One-Button Game Mini Hack, I created DECOY, an arcade survival game built around a simple idea:
What if the same button could help you escape and trick your enemies at the same time?
In DECOY, the player controls a glowing courier moving automatically around an elliptical circuit. Hostile drones attempt to intercept the courier, while a single button allows the player to reverse direction and leave behind a temporary holographic decoy.
The decoy attracts nearby drones, creating opportunities to escape or eliminate several pursuers with one well-timed move.
The game's motto is "DECEIVE TO SURVIVE."
The project was developed using OpenAI Codex with MATLAB MCP tools, allowing an AI coding agent to inspect the official contest project, implement the game, run MATLAB checks, and refine the code through several iterations.
Play DECOY — Deceive to Survive:
DECOY — A one-button arcade game featuring predictive drones, holographic distractions, and tactical survival.
Here are some of the most interesting technical and design lessons from the process.
1. Designing a Meaningful One-Button Mechanic
The first challenge was creating a game where pressing one button involves a genuine decision.
In DECOY, pressing SPACE or clicking performs two actions:
  • Reverses the courier's direction.
  • Creates a temporary hologram if an available charge remains.
The corresponding logic is compact:
if pressed
s.dir=-s.dir;
if s.charges>0
[~,k]=min(s.h(:,3));
s.h(k,:)=[p 2.8 0];
s.charges=s.charges-1;
end
end
The courier always reverses direction, even when no hologram charges are available.
Each hologram lasts 2.8 seconds. The player can hold a maximum of three charges, replenished by collecting packages along the circuit.
This creates an interesting tradeoff.
Using a hologram early may provide a safe escape, but waiting until several drones are nearby could produce a more valuable capture.
The goal was to make timing and positioning more important than rapid button pressing.
2. Moving Along an Elliptical Circuit
Rather than allowing free movement, DECOY keeps the courier on a fixed elliptical path.
The position is calculated from a single angle:
function p=position(a)
p=[400+270*cos(a),305+175*sin(a)];
end
The courier advances automatically by updating the angle:
s.theta=mod(s.theta+s.dir*.78*dt,2*pi);
Here, s.dir determines the direction of travel, while dt makes the movement dependent on elapsed time rather than the number of rendered frames.
This approach has several benefits.
First, the player's movement remains predictable. Second, the game only needs to manage one movement parameter. Finally, enemy drones can anticipate where the courier is likely to be in the near future.
The ellipse is also a useful visual design element. It creates a clearly defined arena without requiring complicated level geometry.
3. Giving Drones Predictive Pursuit Behavior
One of the main gameplay challenges was making the drones feel threatening without making their movement completely unpredictable.
The drones use a lightweight, rule-based steering system.
Instead of always chasing the courier's current position, they estimate a future position along the elliptical path.
The core calculation is:
target=position(s.theta+s.dir*.78*min(1.4,norm(p-q)/speed));
The estimated lead time depends on the distance between the drone and the courier, together with the drone's speed.
This produces a simple form of predictive interception.
A drone approaching from inside the ellipse can aim ahead of the courier instead of constantly following behind it.
The important distinction is that this behavior does not require a trained machine-learning model. It is implemented through geometry, prediction, and steering rules.
That was an important design choice for a game with a strict code-size limit.
4. Making Holograms Change Enemy Behavior
A hologram is more than a visual effect. It changes how the drones select their targets.
The game checks the distance from each drone to the active holograms:
dist=sum((s.h(:,1:2)-q).^2,2);
dist(s.h(:,3)<=0)=inf;
[near,h]=min(dist);
Expired holograms are excluded from consideration by assigning them an infinite distance.
The drone normally pursues the predicted courier position, but a nearby hologram takes priority:
if near<235^2, target=s.h(h,1:2); end
This is what makes the central mechanic work.
A carefully placed hologram can redirect several drones away from the courier. If a drone reaches an active hologram, it is eliminated and awards points.
The player is therefore not simply avoiding enemies. They are manipulating enemy behavior.
I found this much more interesting than implementing another conventional dodge mechanic.
5. Rewarding Clever Decoys
The scoring system encourages players to use holograms tactically.
A captured drone provides a base reward of 100 points. Additional drones caught by the same hologram increase the reward.
The implementation uses:
s.h(h,4)=s.h(h,4)+1;
s.score=s.score+100+25*(s.h(h,4)-1);
s.caught=s.caught+1;
This creates a bonus for multi-drone captures.
Packages provide another incentive to keep moving around the circuit. Collecting one restores a hologram charge, up to the maximum of three, and awards 30 points.
The player also receives points for survival time.
Together, these systems create several possible strategies: survive cautiously, collect packages consistently, or take greater risks to capture groups of drones.
The best score is retained between rounds while the current game session remains open.
6. Progressive Difficulty Without Traditional Levels
DECOY is designed as an endless survival game rather than a sequence of fixed levels.
As time passes, drones become faster and appear more frequently.
Their movement speed is calculated using:
speed=min(142,90+s.t*.48);
This gradually increases their speed while enforcing an upper limit.
The spawning interval also changes over time:
s.spawn=max(.85,2.5-.018*s.t)*(1+.12*sin(s.t*.7));
This gradually increases pressure while introducing some variation into the arrival rhythm.
The game uses a fixed pool of twelve drone objects rather than creating unlimited graphics objects.
The interface displays a sector indicator that advances with survival time, giving players a sense of progression even though the game uses one continuous arena.
This approach keeps the implementation compact while encouraging repeated attempts to beat the previous record.
7. Creating a Neon-Noir Visual Identity
I wanted DECOY to have a visual identity distinct from a typical arcade prototype.
The final design uses a dark violet background, gold circuit lines, orange drones, blue holograms, and a luminous courier.
The interface includes a central geometric relay, an elliptical arena with subtle markings, charge indicators, a score display, and a dedicated start screen.
The visual design was refined after the first playable version.
Initially, the central area felt too empty and the courier was not visually distinctive enough. Later iterations added more recognizable player geometry, environmental details, and clearer introductory instructions.
An important MATLAB technique was to create graphics objects only during initialization and update their properties afterward.
For example, the courier's orientation is calculated from the tangent to the elliptical path:
v=s.dir*[-270*sin(s.theta) 175*cos(s.theta)];
v=v/norm(v);
w=[-v(2) v(1)];
These vectors are then used to construct a directional shape.
This makes the courier visibly change orientation when the player reverses direction.
The holograms also display a circular arc representing their remaining lifetime, helping players understand when their decoy will disappear.
Visual feedback is especially important when the game is controlled with only one button.
8. Keeping MATLAB Animation Responsive
DECOY separates the simulation from the rendering logic using the contest's required init, update, and render functions.
The graphics objects are created in init, while render updates existing object properties.
The simulation also divides longer time steps into smaller increments:
n=ceil(dt/.01);
step=dt/n;
for j=1:n
s=advance(s,step);
if s.mode==2, break; end
end
This limits the internal simulation step to approximately 0.01 seconds.
Smaller steps help maintain more consistent movement and collision behavior when the rendering frame rate varies.
The game also reuses its drone, hologram, and visual-effect objects instead of creating new objects continuously.
These decisions helped keep the implementation manageable and supported smooth real-time gameplay in MATLAB.
9. Developing the Game with Codex and MATLAB MCP
One of the most interesting aspects of this project was the development workflow.
Unlike my previous Mini Hack projects, I used OpenAI Codex as the primary coding agent, connected to MATLAB through Model Context Protocol (MCP).
The workflow started with the official Mini Hack starter project.
Codex first inspected the project structure, read AGENTS.md, identified the contest restrictions, and checked which MATLAB tools were available.
Before implementation, it proposed three different game concepts. I reviewed the alternatives and selected DECOY because its combination of deception, movement, and enemy prediction seemed particularly suitable for one-button gameplay.
Codex then implemented the game directly in game.m.
Through the MATLAB MCP integration, it could execute MATLAB commands, inspect the implementation, run static analysis, and invoke the official contest validator.
The development process included:
  • Initial implementation of the arena and pursuit mechanics.
  • Validation against the contest rules.
  • Programmatic checks of gameplay state transitions.
  • Live gameplay checks in MATLAB.
  • Visual refinements based on screenshots and manual playtesting.
  • A final change to the start-screen slogan.
The AI handled much of the coding and technical verification. My role was to select the concept, assess the gameplay, evaluate the visual results, request improvements, and make the final design decisions.
This was a useful demonstration of how AI-assisted development can support an iterative workflow without removing the importance of human testing and judgment.
10. Lessons from the 10,000-Character Constraint
The contest's 10,000-character limit shaped many implementation decisions.
Rather than using a complicated pathfinding system, DECOY relies on geometric prediction and simple steering.
Instead of building multiple arenas, it creates increasing difficulty within a single circuit.
And rather than continuously creating new effects, it reuses a small collection of MATLAB graphics objects.
The official minihackContest.validate command was used during development to check compatibility with the contest requirements.
The main lesson was that technical constraints can encourage more focused game design.
A compact implementation does not necessarily mean a shallow game. The interaction between a moving courier, predictive drones, and temporary holograms can generate surprisingly varied situations.Final Thoughts
DECOY started as an experiment in designing a meaningful one-button mechanic.
The result is a small arcade game where success depends on understanding how enemies react to the player's actions.
A well-timed press can turn a dangerous pursuit into an opportunity to score points.
The project also demonstrated how OpenAI Codex and MATLAB MCP tools can be combined to develop, validate, and refine a complete game inside MATLAB.
My biggest takeaway is that interesting gameplay often comes from combining a few simple rules rather than adding more controls or features.
In DECOY, one button is enough to reverse direction, create a distraction, manipulate enemy behavior, and sometimes escape a seemingly impossible situation.
DECEIVE TO SURVIVE.
Thanks for reading, and I hope you enjoy playing DECOY!

标签