AgentGames

Search titles, descriptions, models and tags. Press Enter to see results.

⚽ Guide

How to make a sports game with AI

A keyboard gives a player eight directions and a sport asks for far more. Close that gap in their favour, openly and on purpose, or the game feels stiff and unfair to everyone who tries it.

Updated 5 October 2026 8 min read By the Agent Games team
Jump to a section
  1. Four steps to a shot worth taking
  2. The ball has to flatter the player
  3. The three assists worth having
  4. An opponent a beginner beats
  5. Keep only the rules that make it recognisable
  6. Common questions
  7. Where to go next

Pick one sport, cut it down to a goal and a score, and build that from above. The code is not the difficulty. The difficulty is that a shot aimed with four keys will miss a goal the player was obviously trying to hit, and a game that lets that stand feels broken.

The thing nobody says out loud

Shots in a sports game get corrected towards the goal. The correction is small, it is invisible, and it always favours the human. Every sports game does this. A build without it feels stiff, and players blame the controls rather than the maths.

Four steps to a shot worth taking#

Paste the prompt below and shoot from everywhere

Close in, from the wing, from your own half. You are looking for the range where shooting stops feeling worth trying.

Turn the assist off and shoot again

This is the build you would have shipped without reading any of this. The difference is larger than you expect.

Raise the assist until you stop noticing it

Too little and the goal feels like a keyhole. Too much and the ball visibly bends, which gives the whole thing away.

Then make the opponent worse at its job

A first build hands it your speed and perfect reactions. Slow it down until you win the first match you play.

PromptCopy this, paste it, send it
Build a sports game as ONE self-contained .html file, seen from above.
No frameworks, no image files, no 3D. The sport is football, cut back to
only the parts that make it recognisable.

PITCH: a green rectangle, a goal mouth at each end, a halfway line.
Nothing else. No throw-ins, no offside, no fouls, no substitutions.

PLAYERS: one circle I control with the arrow keys or WASD, and one
circle the computer controls. Running into the ball pushes it along.
Holding space winds up a shot and releasing it kicks, harder the longer
it was held, up to a ceiling.

SHOT ASSIST, and please build exactly this. On release, work out the
angle from the ball to the centre of the opposing goal. If my shot's own
angle sits within ASSIST_CONE of that angle, replace it with the angle
to the goal completely, rather than part of the way. The cone gets wider
the closer I am to the goal. A shot that would pass just outside a post,
but that was inside the cone, counts as a goal anyway. None of this
applies to a shot pointed away from the goal, which must travel exactly
where I aimed it.

OPPONENT: it runs at the ball, shoots when it reaches it, and is a
little slower than me. It should decide where to go a short delay after
the ball changes direction, not in the same frame. Give its shots a
small random error and give them no assist at all. Somebody playing for
the first time should win.

RULES: goals, a score, a kick-off from the centre spot after each goal,
and a match that ends when one side reaches a target score. That is the
whole rulebook.

HUD: both scores, and a shot power bar while space is held.

PHONE: a drag moves my player and a tap shoots.

Multiply every movement by the seconds that passed since the previous
frame, and never let that value rise above 0.05. Put canvas {
touch-action: none; } in the stylesheet. Gather every number worth
changing into one CONFIG object at the top, ASSIST_CONE and the
close-range widening and the opponent's speed and delay among them, each
with a comment saying what it does.

ASSIST_CONE is the dial for the whole page. Set it to zero once to see the unassisted game, then raise it until you cannot feel it working. Keep the line about shots pointed away from the goal. Without it, every pass backwards gets dragged forwards and moving the ball around becomes impossible.

The ball has to flatter the player#

Simulate the shot honestly and this is what happens. The player holds up and right, which is one fixed angle out of eight. The ball leaves on that angle, passes a finger's width outside the post, and a goal they were plainly trying to score does not count.

They are not being unreasonable. They did aim at the goal. The keyboard cannot express what they meant, so the simulation is answering a question they never asked. The fix is to answer the question they did ask.

An honest shot, and a shot that flatters The same key held on the same keyboard, judged two different ways. Simulated honestly angle = heading // exactly as givenA keyboard offers eight headingsThe goal mouth wants far finer than thatA miss reads as the game's fault Nudged towards the goal if (off < CONE) angle = toGoalAim inside a narrow cone snaps onThe mouth counts wider from close inThe player credits their own timing This is cheating for the player. Every sports game ever made does it.
The comparison is one subtraction between two angles. Everything hard about this is deciding how wide the cone should be, and the only way to decide that is to play with it.

Mechanically it is nothing. Work out the angle from the ball to the centre of the goal. Subtract the angle the player supplied. If what is left is small enough, throw away the player's angle and use the goal's. If it is not, leave the shot alone entirely.

Call it what it is. This is cheating on the player's behalf, and it is in every sports game you have ever enjoyed. Nobody who plays yours will know, and nobody who plays the honest version will stay. Fairness to the simulation is not the same thing as fairness to the person holding the keys.

Bend the shot the whole way, not part of the way. A shot moved halfway towards the goal travels on a line the player did not choose and still misses, which is the worst of both. Inside the cone, commit. Outside it, do nothing at all.

The three assists worth having#

The angle snap is the big one, but on its own it leaves two gaps. Shots from very close still feel fussy, because a small angle error covers a lot of ground at point blank range. And a shot that beats the snap by a hair still goes wide.

Three assists, and how far each should go Enough that it is felt. Never enough that it is seen. Angle snap Inside a narrow cone, bend the shot onto the goal. Target widening From close range, treat the goal mouth as wider. Generous near miss A shot just outside counts if it was aimed in. Never in reverse No help at all for a shot pointed away from goal. One dial for all three An assist value in the config, from none to plenty. Set the dial to zero and play one match. That is the game you nearly shipped.
Build all three off one value in the config. Separate dials for each sound more controllable and in practice mean you tune one, forget the others, and cannot explain why the game feels different on Tuesday.
AssistWhen it appliesWhat it costs if overdone
Angle snapAny shot inside the coneA curve the player can see, which spoils the trick
Target wideningShots taken from close rangeGoals that appear to pass through the post
Generous near missA shot just outside, aimed insideConfusion, if the ball clearly went wide
No assist at allShots pointed away from the goalNothing. Without this rule, passing stops working

The last row is the one that keeps the other three honest. An assist that fires in every direction is not an assist, it is a magnet, and players spot a magnet immediately.

The widening deserves a word, because it is the least obvious of the three. A player standing beside the goal is the most certain they will ever be that they are about to score. Letting the mouth count as a little larger from there matches what they already believe.

The generous near miss needs the most restraint. It only works when the intent was clear, which is exactly what the cone already measures. Apply it to a shot that was never aimed at the goal and the player watches the ball sail wide, then hears a goal. That reads as a bug, and it takes their trust in everything else with it.

An opponent a beginner beats#

A first build gives the computer the player's exact speed and no reaction time. It reaches every loose ball first, it never overruns, and it cannot be beaten. Nobody plays an unbeatable opponent a second time.

Aim lower than feels right. Somebody picking this up cold should win their first match without working out any tactics. You can add difficulty afterwards, and you will. What you cannot recover is the person who lost their first game badly and closed the tab.

  • Give it a reaction delay. Let it work out where to run a short time after the ball changes direction, rather than in the same frame. Most of what makes an opponent feel like a person rather than a tracking system lives in that delay.
  • Make it slightly slower. A fraction slower than the player, not half the speed. A chase it almost wins is better to watch than one it loses from the start.
  • Let it shoot badly. A small random error on every shot, and no assist whatsoever. The assist belongs to the human, and giving the opponent one quietly undoes all the generosity you just built.
  • Expose its speed and its delay. Those two values are a difficulty setting you already have. Naming them in the config is most of the work of adding easy, normal and hard later.

Keep only the rules that make it recognisable#

Every sport carries a rulebook and almost none of it belongs in a small game. Offside, throw-ins, fouls, the clock and substitutions are all real parts of football, and each one you add stops play for a reason the player did not intend.

Ask one question of every rule. Without this, would somebody still know which sport they were playing? A goal and a score survive that question. Offside does not, because nobody looking at the screen would notice its absence.

  • Keep the scoring shape. Where the points come from is what identifies the sport. A mouth at each end is football. An arc worth more is basketball. One serve and a net is tennis.
  • Keep the restart. Something has to happen after a point, or the game has no rhythm. A kick-off from the centre is enough and takes a moment to write.
  • Drop anything that needs explaining first. If a player has to read a rule before the first kick, it is not in the game yet. Teach by letting them try things.
  • Drop anything that punishes an accident. A rule that stops play when the player did nothing obviously wrong is read as the game malfunctioning, regardless of how real it is.

What is left is a loop: get the ball, shoot, score, restart. That loop plus a shot that flatters is a sports game people finish. Add the rulebook later, one rule at a time, and drop any rule that makes a match less enjoyable than it was before.

⚽Sports games written by AI

Common questions#

Can AI make a sports game?

Yes, as long as you pick one sport and cut it to a goal and a score. A pitch seen from above, two circles and a ball is one prompt. The judgement you add is how much the game should help the player aim, which is the whole craft of the genre.

Is aim assist cheating?

It is, and it is cheating in the player's favour, and every commercial sports title does it. The alternative is a game where a shot the player clearly meant to score goes wide because four keys cannot express an angle. Honest there means unpleasant.

How strong should the shot assist be?

Strong enough that you stop noticing it and no stronger. The test is watching the ball: if you can see it bend away from where you aimed, the cone is too wide. Start high, come down until the curve disappears, then stop.

Why does my computer opponent always win?

It almost certainly has your speed and reacts in the same frame the ball moves. Make it a fraction slower and have it decide where to run a short time after the ball changes direction. Those two changes turn an impossible rival into a fair one.

Which rules of the sport should I leave out?

Anything that halts play without the player having done something they understand was wrong. Offside, fouls and set pieces all fall out on that test. Keep where the points come from, keep the restart after a point, and add nothing else at first.

Should a sports game be 3D?

Not for a first build. A view from above shows the whole pitch, needs no camera work and makes the ball easy to read. A camera behind the player adds judgement about what is on screen, which is a problem worth having only after the shooting feels right.

Where to go next#

When you have won a match and immediately started another, publish it. The page records which model wrote it and the prompt behind it, and a scoreline is the kind of thing people want to beat. The sports games here are a short list, which makes it an easy category to be the best thing in.

A sport is better with somebody sitting next to you, and the two player guide covers sharing one keyboard without the two sets of keys fighting. The general method is in how to make a game with AI. If your sport involves a vehicle, the racing guide has the handling numbers, and the prompt guide collects fixes for the faults a first build tends to arrive with.