Pong

Pong game with brain in centre of image score 0-1
A tribute to the 50 year old game

Pong is a table tennis-themed arcade sports video game, featuring simple two-dimensional graphics, manufactured by Atari and originally released in 1972.

Game Play

A simple tennis game, but what did you expect in 1972?

Two people each with a “bat”, or if you lack the imagination of my generation, a “short line”, which bat moves up or down controlled by the player. The objective is to win by putting your bat in the way of the square(!) ball to make it return in such a way that your opponent cannot return it.

To add an element of gameplay the ball doesn’t return perpendicular to the bat despite it being stationary but deflects at an angle that is different depending on what part of the bat it hits. The mechanism behind the angle of return was simple but effective, splitting the bat into 8 segments. Note: Given it’s not odd, and the middle of the bat returns it straight, I am guessing it works like this:

For example, the centre 2 segments return the ball at a 90° angle to the bat, while the outer segments return the ball at smaller angles. Whilst “angle of incidence = angle of reflection” is used for the edges, for the bat it won’t work – the ball would bounce around predictably. Without any sideways motion to hit it harder forwards, Atari needed something to add an element of fun.

The ball speeds up the longer it remains in play to make the game more skilful. Upon missing the ball the speed reset.

As a sneaky way to shorten games and add more skill, the bats were intentionally stopped from reaching the top of the screen. This allows deflecting the ball to that precise location winning the point.

Pong sounds easy – right?

The simple instruction to a human to “hit the ball” will soon see them align the bat X with ball X. Before long they will experience the effect of not hitting a ball centrally (the ball whizzing off at strange angles). Shortly after they will be using this to get their opponent on the back foot. Right, it was easy?

Not for AI. The problem attempting “human” level gameplay leads to hidden complexity…

  • Hitting a ball using the middle of the bat is highly unlikely to enable anyone to win unless the opposition is appallingly bad. You need to hit the ball off-centre to make it difficult for the other player to return.
  • Knowing where to hit it depends on whether you get a choice. You might be just lucky enough to return the ball with no say in what part of the bat you hit the ball with.
  • Chasing the “X” of the ball is dangerous as the ball speeds up:
    • At higher speed the ball could hit the wall and end up after deflection, travelling somewhere else.
    • Given the bat can’t move quick enough as the ball gets faster, you’re going to miss it.
    • You need to anticipate a bounce and that could mean going the opposite way to be able to get in the right place after the rebound.
  • You need to consider the bat belonging to your opponent –
    • to attempt to position the ball where they won’t get to (e.g. they are on the left, position the ball to the right)
    • to anticipate their ball return angle, i.e. if you can see they plan to hit the ball on the edge of the bat, the ball is going to be at a sharp angle and not a major concern. Skilled players “slice” the ball, which in virtual terms is looking like you’re going to hit it with one part of the bat but moving it sharply before impact. Done quickly it catches out the opponent, but risks missing the ball.
  • Predicting where the ball is heading is not possible from a single frame; this alone makes the whole thing very tricky. You’d need temporal data (this frame, last frame i.e., memory).
  • Cause and effect are hard to link: I did X and Y happened, if feedback is used. For example, associating hitting the ball at an angle that prevented the opponent from returning could be from a well-placed shot or a shortcoming of your opponent (lapse of concentration, bad hand-eye coordination).

Do you still think it’s easy?

Until “general AI” becomes a thing, the AI starts off knowing nothing.

Looking at the game from a newbie…

There’s a black area with some white pixels illuminated. When I use my controller, some of the pixels move and some of them don’t (like the opponent’s bat). When the ball moved was it because I moved my controller? How do I know there is no relationship with moving my controller?

This reminds me of an episode of Derren Brown‘s, where he put people in the room with lots of “things” (buttons, etc). They had a big scoreboard visible. If I remember correctly their goal was to increase it as large as possible (to increase the money they won & win). As they did “things” the number increased by varying amounts. The humans all naively associated what they did with the number going up, even despite repeating the action and wondering in disbelief why it didn’t always provide the same outcome. SPOILER ALERT: It was completely random…

I guess the naivety results from evolution have taught us there is a relationship between cause and effect, and the reverse, that an effect invariably has a cause. That spear whizzed past you and hit a close tree. You recognise it as a spear and quickly remember spears don’t throw themselves, followed by the realisation of serious imminent danger. You look for the threat. It’s an important skill for survival. But what of our “Pong” AI?

Maybe let’s try another scenario? Imagine two space aliens arriving on earth and walking into a house where “Pong” is on-screen waiting to be played. (You have to imagine, given the state of the world as I cannot imagine any intelligent species wanting to visit planet Earth right now.)

Assuming that the aliens weren’t visiting in the ’70s, nor studying humans/sticking probes in places we won’t mention, do you think they would pick up the controls and start playing together, and understand the rules of the game?

Maybe you think that’s more of a philosophical question than AI/ML, I would argue if they got over how backward humans are and the poor graphics, to enjoy or even play “Pong” they would probably need instructions. (For space aliens out there who disagree with that statement, please post in the comments section, but I will request proof you’re an alien.)

To play you need to understand the elements of the game:

  • 2 x bat, 1 x ball, a score, a winning and losing region
  • motion for things you influence (you control a bat, and how you hit the ball)
  • the objective – return the ball in a way the other play cannot stop to score points, and the highest points win. (The game could be to hit the ball such that they can hit it back, but I suspect that would be less exciting)
  • given it is 2 player, you need to appreciate that you are competing not working together

In childhood, we develop self-awareness. Before you can put yourself in someone else’s shoes to predict their behaviour, you need to be aware of self. Prediction of their action requires you to pretend to be them. The same way one plays checkers or chess. “I do this, they will do that” (and in both games, repeat multiple times and apply for each moveable piece). Let’s not get bogged down in the probability of any action.

Making something that plays the game successfully leaves us either solving some problems either using smart optimisations or true AI.

Distilling what an AI needs to do:-

  • problem 1: track the moving ball (predict where the ball will cross the defensive goal line), to place the bat correctly.
    • e.g. It could use several frames (seeing) to compute trajectory.
  • problem 2: determine where to hit the ball on the bat to win.
    • This requires the position/image of the other players’ bat.
    • It also needs to know the relationship between the position of the opposing players’ bat, the regions available to contact the ball, the angle of deflections available (i.e. predict where they will land up) and how long the other player requires to move into a position to return the ball.

If I created a perceptron neural network for both problems it’s not “AI”. It’s not a “thinking” program, it’s…

  • a “human” worked out the best way to solve the problem (not the computer)
  • a “computer iteratively worked out a formula for the inputs”.

That’s good enough to market it as “AI” judging by some snake oil vendors, but not good enough for me.

Ok, so what’s the alternative?

TBH, I don’t know whilst writing it.

What the posts attempt is to at least achieve resolving the 2 problems, thereby proving I can provide snake oil too – and you hopefully enjoy the crazy ideas I use to solve things!

Posts below:

Pong 2.0

Pong 3.0

Leave a Reply

Your email address will not be published. Required fields are marked *