Image copyright Getty Images Image caption Video games have had a profound effect on the economy

Early in 1962, a young MIT student was on his way home in the nearby town of Lowell, Massachusetts.

As Peter Samson stepped off the train and gazed up at the stars above, a meteor streaked across the heavens. Mr Samson reflexively grabbed for a game controller that wasn't there, and scanned the skies, wondering where his spaceship had gone.

Mr Samson's brain had grown out of the habit of looking at the real stars. He was spending way too much time playing Spacewar!

His near hallucination was the precursor of countless digital fever dreams to come - that experience of drifting off to sleep dreaming of Pac Man, or rotating Tetris blocks, or bagging a rare Pokemon Jigglypuff.

In 1962, that ability of a computer to yank our Pavlovian reflexes and haunt our sleep would have been unimaginable to anyone but Peter Samson and a few of his hacker friends.

They were avid players of Spacewar!, the first video game that mattered - the one that opened the door to a social craze, a massive industry, and shaped our economy in more profound ways than we realise.

50 Things That Made the Modern Economy highlights the inventions, ideas and innovations that helped create the economic world.

It is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.

Before Spacewar!, computers were intimidating, vast and expensive: large grey cabinets in purpose-built rooms, closed off to all but the highly trained.

Computing was what banks and corporations and the military did.

But at the beginning of the 1960s, at MIT, new computers were being installed in a more relaxed environment.

They didn't have their own rooms but were part of the laboratory furniture.

Students were allowed to mess around with them.

The term "hacker" was born, meaning not the modern malevolent cracker of security systems, but someone who would experiment, cut corners and produce strange effects.

Video revolution

At the same time, MIT ordered a new kind of computer: the PDP-1.

Image copyright Science Photo Library Image caption The PDP-1 was crucial in the development of the first video games

It was compact - the size of a large fridge - and relatively easy to use. It was powerful. And it communicated not through a printer, but through a high precision cathode ray tube - a video display.

When a young researcher called Steve "Slug" Russell heard about the PDP-1, he and his friends began plotting the best way to show off its capabilities.

They had been reading a lot of science fiction and dreaming of a proper Hollywood space opera.

But Star Wars was two decades away, so they plumped for the best possible alternative: Spacewar! - a two-player video game that pitted spaceship captains against each other in a photon-torpedo-powered duel to the death.

There were two spaceships - just a few pixels outlining the ships - and the players could spin, thrust, or fire torpedoes.

Economic legacy

Other enthusiasts soon joined in, making the game smoother and faster, adding a star with a realistic gravitational pull, and cobbling together special controllers from plywood, electrical toggles, and bakelite. They were hackers, after all.

In one way, the economic legacy of Spacewar! is obvious.

As computers became cheap enough to install in arcades, and then in the home, the games industry blossomed.

One of the early hits, Asteroids, owed a clear debt to Spacewar! - with the realistic-seeming physics of a spaceship that rotated and thrusted in a zero-gravity environment.

Computer games now rival the film industry for revenue. They're becoming culturally important, too. Lego's Minecraft tie-in jostles for popularity with the company's Star Wars and Marvel sets.

Image copyright Getty Images

But beyond the money that we spend on them, games affect the economy in a couple of ways.

First, virtual worlds can create real jobs.

Virtual sweatshops

One of the first people to make this case was an economist named Edward Castronova.

In 2001, Mr Castronova calculated the gross national product per capita of an online world called Norrath - the setting for an online role-playing game, EverQuest.

Norrath wasn't particularly populous - about 60,000 people would be logged in at a time, performing mundane tasks to accumulate treasure they could use to buy enjoyable capabilities for their characters.

Image copyright EverQuest Image caption Economists realised players were earning real money by doing mundane work for others inside EverQuest

Except, some players were impatient.

They bought virtual treasure from other players, on sites such as eBay, for real money, which meant other players could earn real money for doing mundane work in Norrath.

The wage, reckoned Mr Castronova, was about $3.50 (£2.70) an hour - not much for a Californian but an excellent rate if you happened to live in Nairobi.

More from Tim Harford

How a razor revolutionised the way we pay for stuff

TV Dinner: The hidden cost of the processed food revolution

How the lift transformed our cities

How air conditioning changed the world

Before long, "virtual sweatshops" sprang up from China to India, where teenagers ground away on the tedious parts of certain games, acquiring digital short-cuts to sell to more prosperous players who wanted to get straight to the good stuff.

And it still happens: some people are making tens of thousands of dollars a month on auction sites in Japan, just selling virtual game characters.

For most people, though, virtual worlds aren't a place to earn money, but to enjoy spending time.

Even as Mr Castronova was writing about tiny Norrath, 1.5 million South Koreans were playing in the virtual world of the game Lineage.

Image copyright PA Image caption Candy Crush Saga players move and match similar types of sweets to make them disappear

Then came FarmVille on Facebook, blurring a game with a social network, mobile games such as Angry Birds or Candy Crush Saga, and augmented reality games such as Pokemon Go.

By 2011, the game scholar Jane McGonigal estimated that more than half a billion people worldwide were spending serious amounts of time - almost two hours a day, on average - playing computer games. A billion or two is within easy reach.

And that brings us to the final economic impact. How many of those people are choosing virtual fun over boring work for real money?

Unemployment puzzle

A decade ago, I saw Edward Castronova speak in front of a learned audience of scientists and policy wonks in Washington DC. "You guys are already winning in the game of real life," he told us. "But not everyone can."

Image copyright Getty Images Image caption The augmented reality game Pokemon Go added millions to the value of part owner Nintendo

And if your choice is a Starbucks server or a star-ship captain - what, really, is so crazy about deciding to take command in an imaginary world?

Mr Castronova may have been on to something.

In 2016, four economists presented research into a puzzling fact about the US labour market: the economy was growing strongly, unemployment rates were low, and yet a surprisingly large number of able-bodied young men were either working part-time or not working at all.

More puzzling still, while most studies of unemployment find that it makes people thoroughly miserable, against expectations the happiness of these young men was rising.

The researchers concluded that these men were living at home, sponging off their parents, and playing videogames.

These young men were deciding they didn't want to be a Starbucks server. Being a spaceship captain was far more appealing.

Tim Harford writes the Financial Times's Undercover Economist column. 50 Things That Made the Modern Economy is broadcast on the BBC World Service. You can find more information about the programme's sources and listen online or subscribe to the programme podcast.