Hacker News new | comments | show | ask | jobs | submit login
JavaScript Cold War simulation (simonswain.com)
264 points by simonswain on June 10, 2015 | hide | past | web | favorite | 72 comments

The author also worked on a deep space simulator [1] which has been on hacker news [2] before. Another very interesting simulation.

[1] (https://github.com/simonswain/deepspace) [2] (https://news.ycombinator.com/item?id=8837204)

For "authorized" advice, see https://www.youtube.com/watch?v=q2v0YuDatpc (Declassified USAF training material, 1958), alternate source: https://archive.org/details/AirForceSpecialFilmProject416pow...

(Amazing actors' performance included.)

SAGE is the inspiration for this...


This thing was off the hook...

I once included this video in something similar (also relating to SAGE) as the help option, see this easter-egg: http://www.masswerk.at/google60/?q=list%20games (option 4)

(Edit: Similar just intention-wise, else much simpler, since just in ASCII, meant to be EBCDIC.)

BTW: "System Technology" (SDC, 1960) is also an impressive source in this context: https://www.youtube.com/watch?v=Yqu3YX2cLA8

Nice Easter Egg!

On "System Technology": See esp. at 17:00, ca., this is very similar to the view conveyed by your rendition (note the swarming aircrafts).

This film is a very good use of one hour of your time if you have any interest in history and a high tolerance for mind-numbing terror.

The Power of Decision is easily one of the most scary and disturbing films I have ever watched.

I always used to think that Doctor Strangelove was a really funny movie, but after this, it was a lot less funny somehow (still a great movie, though).

This video is great... and so dark. This stuff was for real.

Personally, I think the opening sequence can't be topped by anything in the context of Cold War.

People who like this might like the very similar PC game "DEFCON" http://www.introversion.co.uk/defcon/

This is a hot war simulation, is it not?

If you want a cold war simulation, try it with JavaScript turned off.

Technically, yes. It's meant to escalate from cold to hot as munitions stockpiles build.

But that doesn't make for a very interesting presentation, so it goes direct to Hot.

I think WWIII sim is probably a better description. Or could go with the 1985 War Games "Global Thermonuclear War". Just nitpicking. The simulation is awesome.

I was thinking the same thing. I was expecting the initial flurry of planes to skirt the opponent's airspace, provoking but not violating :)

The creator held a talk about simulations at JSConf.Asia 2014. Highly recommended: https://www.youtube.com/watch?v=0HJPilemNns

Really cool - would be good to have a quick instructions drop down - I started with clicking things and hitting keys until I realised it was a simulation on initial conditions only.

The bombers seem too effective in anti-fighter measures, and has been said, the sats are very effective at anti-ICBM, but seem invincible themselves?

Interesting how quickly the tide turns from stalemate to dominance once a few factories or bases fall. And also how long it takes to really finish the opponent off (probably my launch_max is too low).

Also interesting the 'fronts' or lines of bombers that form between oppositions. This happens in naval and ground battle, but I'd think a major air war, with high speed relative to density of fighters would avoid this?

Would be cool to involve some sort of strategic element? I'd hoped the fighters would protect the bombers more, but it seems they are more defensive?

Well done!

Yep. All that will be there one day. This is v0.1

Can you give an explanation about what each type of unit does?

There are two views, top view and elevation view. All the actors have an x, y and z.

Each of the circle structures is a nation state.

It has a capital at the center (square, blinking). Defcon is the number in the capital.

Cities (circles) send people to work at factories.

Factories (triangles) make munitions and send them to bases

Bases (square) stockpile munitions (counts, clockwise from top right: icbms, abms (anti ballistic missiles), fighters and bombers.

Bombers are big and slow (triangles) that select a target (factory, base, city, capital in that order), fly to it and nuke it, reselecting a target if somebody else destroys it first.

As defence perimeters are penetrated, defcon gets more scary.

Fighters launch at Defcon 4 and attempt to destroy bombers.

At Defcon 3, Bases launch ICBMs a low probability amount of the time.

Satellites launch at Defcon 2, and can shoot ICBMs out of the sky, but have fire/recharge lasers.

When one of a nation's assets (factory, base, city) is nuked, they go to Defcon 1.

If your enemy goes to Defcon 1, so do you.

At Defcon 1, all ICBMs will fire.

When your capital is destroyed, it's Game Over.

The control panel lets you tweak the starting parameters. There are a lot more controls for all the actors (e.g, how close do bombers flock.) than are not exposed here.

Factories are triangles. Cities are circles. Bases are squares. In the center is a more different square with the defcon. Cities are required to supply factories. Factories are required to make new units. Bases are required to launch units.

Fighters target bombers and fighters. Satellites target ICBMs. Bombers and ICBMs target factories, cities, bases, and defcon. Bombers target in that order; ICBMs seem to target randomly.

Game over when defcon is destroyed.

Launching an ICBM requires defcon <= 3. The choice to launch is a bit random at defcon 3 and 2 but they all launch at defcon = 1.

Defcon changes to 4, 3, 2, and 1 if a bombers crosses the circular boundaries (radar?) around the center. You can see this happen when the boundary flashes.

Seems like:

  - circle: city
  - triangle: factory
  - square: military base
  - big plane: bomber
  - little plane: fighter
  - things with rocket trails: ICBMs
  - floaty diamond things: satellites (which shoot down ICBMs)
The square in the middle of each team represents the current defcon. Assuming you start at defcon 5, when an enemy unit crosses the big blinking circle, drop to defcon 4. When a unit crosses the next blinking circle, drop to defcon 3. I haven't figured out yet how the escalation proceeds after that.

Bang on.

The dust coming up out of the bases (and to a limited amount, the other assets) are ABMs, trying to take out incoming ICBMs.

Goes to Defcon 2 on enemy bombers reaching city limits (the radius Cities and Bases are at).

Yikes! Is this realistic? There seems to be a doctrine that ICBMs will only be launched upon receiving a complete nuclear strike, and once that happens it's pretty much game over.

This makes fighter jets a critical buffer because the only way a defense can prevent mutually assured destruction is to prevent non-ICBM first strikes.

If you're looking for realism in your apocalyptic nightmare scenarios, there's an ooooold DOS game called Bravo Romeo Delta you should track down. I wrote a little bit about it here: http://jasonlefkowitz.net/2014/11/choreographing-armageddon-...

It's fallen into abandonware hell, so you can't buy a copy at GOG or anything like that, but cough I'm sure you could find a copy if you looked on the right sites.

This is awesome... so much detail.

At Defcon 3, Bases launch ICBMs a low probability amount of the time.

When one of a nation's assets (factory, base, city), they go to Defcon 1.

If your enemy goes to Defcon 1, so do you.

At Defcon 1, all ICBMs will fire.

Bases are limited to how many the can have in the air at a given time.

Not realistic really, but never let the truth get in the way of a good yarn...

Try putting satalites up to '3', it's almost impossible for an ICBM to get through.

Eventually just one did, but then even the volleys get stomped by the satalites.

This game has been running for over 10 minutes at DEFCON 1 for me, the blueside managed to get the first city down but it's now a city each but yellow also lost 2 of their triangles (bases? factories?).

Bump up icbm_launch_max to maybe 15, and set stock_icbms to say 100 or so.

If my first game hasn't finished (It wasn't a complete stalemate yet but they have stocked up a lot of fighters and bombers) when I get home I'll try that! I find zero-player games fascinating, especially ones such as this.

One of the reasons why stealth technology was so important to Cold War tech.

Real Cold War is more of this: Two side point lethal nukes at each other, but at a point one side falls on its face and proceeds selling factories for scraps, while other one forgets near-death experience in a whim deriving no lesson from it.

Not so fun to simulate mind you.

This was a presentation at JSConf US 2 weeks ago. I'm sure everyone will enjoy it much more with the video once it winds up online.

It wss a fun talk. My only regret is that Simon didn't use an [apropos quote](http://www.imdb.com/title/tt0086567/quotes?item=qt0453844) during the talk.

The BBS login at the start of the talk said: "Greetings, Simon".

Reminds me a lot of the game Defcon. I love it!

Reminds me of Missile Command

I love the dual side/top view setup.

The game also becomes interesting and easier to watch the escalation by turning it straight to Defcon 3 and then reducing the number of bombers.

This leads to skirmishes between fighters and a few stray icbm's in the beginning, but once one hits the situation escalates extremely rapidly.

This was super fun to play with and the visuals are very cool! One minor thing though, the Star Wars program simulation seems too good: once you have around 5 sats going around you're safe for a long long time that it starts becoming boring (and I'm pretty sure it wouldn't be the case IRL). Like, I watched a game for 30min and all sats were too effective and nobody could really hit each other no matter how many attacks they did. Maybe make sats attack each other while in orbit? Perhaps only in specific timed cases, sort of during an orbit apogee or perigee or whatever, just to make them a bit less effective or durable?

> Maybe make sats attack each other while in orbit?

Just add ASAT. If they've got ICBM technology and especially if they've got ABMs, they can certainly knock a satellite out of orbit.

Reminds me somewhat of DefCon (http://www.introversion.co.uk/defcon/). No one wins. Try to be the one who loses least...

The author's Github contains the source for this:


I wish the parameters were url parameters. Comparing simulations would have been possible.

(I'm currently running a conventional war scenario -- bombers and fighters only - no icbms or sats).

Yep. Need the ability to save and share scenarios. Coming.

It seems with this scenario, whoever strikes first really does win, though the game takes a bit longer.

The game always nearly ends with a couple of bombers sneaking past the bases at the front and taking out the factories and cities until the player runs out of resources.

Very impressive. As a crusty old desktop programmer I am amazed how smoothly it runs in the browser. A few questions (didn't see them answered below):

1. What Javascript frameworks/libraries did you use (if any)? 2. Do the 2 sides always have to be symmetric?

It would be great if you could add some brief notes explaining what is going on (even if you just copy and paste some of the below).

No frameworks or libs. Vanilla.js, raw Canvas and requestAnimationFrame. In this version, they are symmetric with slight random variations. No reason they have to be though.

What sort of IDE/debugger did you use (if there is such a thing for Javascript)?

How long did it take to write and debug?

Looking forward to v0.2!

Emacs, and Chrome dev tools. The build environment has jslint set up in it too. I can't recommend enough js{lint|hint}ing all your code. None of the stuff in the sim is super tricky.

It was definitely something compiled to JavaScript, I can tell you that.


That's plain JavaScript, only minified.

>Doing heavy lifting with JavaScript in IE8 is just not fun.

Please force your customers to upgrade their browser. You'll do the better good for yourself, your customers, and mankind in general. :)

I spent an hour playing with this - very enjoyable! Would love an iOS app with something similar. Recommendations?

Slight bug, If there's any bombers on the field at all the other sides fighters won't shoot any fighters.

If side A has fighters on side B. A has a bomber just launched. B fighters just try to fly at the bomber, dieing to the B fighters.

Joshua, is that you?

Wouldn't you prefer a nice game of chess?


Reminds me of Minestorm on the Vectrex!

Reminds me of Atari Missile Command.

Good ol' days.

Every time the same team wins over and over again, when I change some values other team keeps winning all the time.


the only winning move is .....

To play, perfectly, waiting for your opponent to make a mistake. (https://xkcd.com/832/)

Alternately, watch SMBC's more explicit version https://www.youtube.com/watch?v=TFCOapq3uYY

It's not whether you win or lose. It's how you play the game.

need more visual

@simonswain - You should avoid the bright flashes when the game is over, some people might have health issues.

Meh, the flashing-lights-in-games thing is waaaaaay overrated as a public health concern. Most photosensitive (=~'flashing light') epileptics require flashes in the range of ~8-18 Hz (mostly in 12-16 Hz), and even then it almost always takes some time to build up, and even then it's a fraction of epileptics that are susceptable. And flashing lights by themselves don't make non-photosensitive epileptics have seizures (or non-eplieptics). Only about 15% of people epilepsy with are photosensitive. A photosensitive epileptic will know to look away if they see their kind of triggering flash.

By the time you narrow it down to the mere handful of epileptics that will have a seizure from one or two flashes (ever hear anyone complain of a single camera flash and epileptics?), you're in a very rare group. At which point, nothing is safe - I heard of one epileptic who had seizures due to orange circles. Other colour circles were fine, other orange shapes were fine, it was just orange circles (which mean no driving...). Another patient had seizures when ice touched their lips. They do exist, of course, but at that point you're optimising for an incredibly rare user. If you're going to optimise for that, there's plenty of usability optimisations that hit way more people that you should be doing first :)

Source: spent four years doing several EEGs on neuro patients per day, each of which had a 5-minute session with a strobe light at various frequencies. Most of those patients were there for epilepsy or suspicion of epilepsy, but not all, of course. Seeing a photosensitive response at 8Hz was uncommon, but not rare. Some people had some response to single flashes (well, 1Hz) but it never built up to a dangerous level - I never saw someone in danger of having a seizure from 1Hz flashes.

/rant (sorry, nothing personal, I just keep seeing this (largely) urban myth)

> I just keep seeing this (largely) urban myth)

It is reinforced by those warnings in all games.

A fair point - they're just doing CYA because of public hysteria on the issue. Game designers are rarely biologists, let alone neurologists, and it's a topic that the public knows little about :)

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact