Home

Awesome

node-broken-arrow-bot

NOTE: SEE PERMISSIONS SECTION BELOW FOR IMPORTANT INFORMATION ABOUT THE CODE!

The Broken Arrow Bot (@brokenarrowbot) uses basic technical details of the US Nuclear Triad to randomly generate a 'Broken Arrow' event for a nuclear weapon. A location in the continental United States is picked at random and a nuclear explosion is simulated by calculating the blast radii of various nuclear effects (fireball, overpressure, thermal radiation, etc). All of this information is then used to generate an image and text describing the Broken Arrow event, which is then posted to Twitter.

<img src="images/broken-arrow-tweet.png" width="400px;"/>

WHY DID I MAKE THIS?

In the past year, I had my first ever nightmare about a nuclear apocalypse in my city. Surely a person in modern society doesn't worry about these things, I thought? And yet, the ever-present news of recent geopolitical events had found its way into my subconscious, causing me to experience real fear about the nuclear threat. If I was having these fears and dreams, surely others must be too?

So I decided to channel that anxiety into learning more about nuclear weapons and create something that attempts to make them more real. They have an odd way of being both terrifying and yet unknowable, as if the scale of their danger is too great to fully grasp in the context of modern life.

The idea to build a Twitter bot about nuclear weapons was heavily inspired by the website NUKEMAP, an interactive web map that shows the effects of various nuclear weapons on major cities around the world. Like the NUKEMAP, I hope that the Broken Arrow Bot helps people better understand what these weapons can do in the context of the world around them.

HOW DOES IT WORK?

The heart of this Twitter bot is a dynamic image generator that uses the Node-based image processing library Jimp to create a composite image of stacked layers. The result is an image that shows a satellite image of a random location with information about a nuclear weapon and the size of its blast effects.

It relies on the Mapbox Static API to both generate a satellite image as a base layer and create a minimap with a higlighted location using a custom marker. Additional masks, icons and text are dynamically layered to build up a final composite image.

And finally, the entire Node.js project was uploaded to AWS Lambda for full Twitter bot functionality.

PERMISSIONS

In my rush to build this project, I never stopped to think about asking permission to use two resources that this bot relies on. Specifically, I had used a complex nuclear effects calculation script (nukeeffects.js) and an undocumented API for estimating nuclear blast casaulties, both of which are resources of the NUKEMAP website.

I reached out to the author of NUKEMAP, Dr. Alex Wellerstein, asking for his permission to use these resources, but I have not received a response. Therefore, I've disabled the Twitter bot to err on the side of caution in regards to using unlicensed code. But valuable lesson learned!

In the code hosted on this repo, I've .gitignore'd the nukeeffects.js library and disabled the request calls to the API resource. Instead, I've just used hardcoded values for the nuclear blast effects in order to still generate a final image.

HOW TO RUN THE CODE

Follow the steps below to run locally!

module.exports = {
  mapbox_token: '[MAPBOX_TOKEN]',
  twitter_consumer_key: '[TWITTER_CONSUMER_KEY]',  
  twitter_consumer_secret: '[TWITTER_CONSUMER_SECRET]',
  twitter_access_token: '[TWITTER_ACCESS_TOKEN]',  
  twitter_access_token_secret: '[TWITTER_ACCES_TOKEN_SECRET]'
}

You can skip the Twitter tokens but you'll need your own Mapbox token to use the Mapbox Static API.

var minimap_mapbox_style = '[MAPBOX_MAP_STYLE_ID]';
var minimap_icon_url = '[CUSTOM_MARKER_URL]'

You'll need to set your own Mapbox map style (or use a template) and a custom marker URL if needed. The current marker URL is hosted on Imgur so you can leave that if you want.

node index.js

SO WHAT IS A BROKEN ARROW?

The Department of Defense Manual 3150.08-M defines 'Broken Arrow' as...

"An unexpected event involving nuclear weapons or radiological nuclear weapon components that results in:

<ul> <li>Accidental or unauthorized launching, firing, or use by U.S. forces or U.S.-supported allied forces of a nuclear-capable weapon system that could create the risk of an outbreak of war.</li> <li>Loss or destruction of a nuclear weapon or radiological nuclear weapon component, including jettisoning.</li> <li>An increase in the possibility of, or actual occurrence of, an explosion, a nuclear detonation, or radioactive contamination.</li> <li>Nonnuclear detonation or burning of a nuclear weapon or radiological nuclear weapon component.</li> <li>Public hazard, actual or implied.</li> <li>Any act of God, unfavorable environment, or condition resulting in damage to the weapon, facility, or component.</li>
</ul>

TWITTER

I currently follow a very interesting mix of nuclear nonprofileration, policy and anthropology experts on Twitter. Here's an incomplete list of people and organizations that I highly recommend checking out if you're interested in learning more!

<img src="images/twitter-profile.png" width="200px;"/>