“Hacking Secret Ciphers with Python” Released

My third book, Hacking Secret Ciphers with Python, is finished. It is free to download under a Creative Commons license, and available for purchase as a physical book on Amazon for $25 (which qualifies it for free shipping). This book is aimed at people who have no experience programming or with cryptography. The book goes through writing Python programs that not only implement several ciphers but also can hack these ciphers.

100% of the proceeds from the book sales will be donated to the Electronic Frontier Foundation, Creative Commons, and The Tor Project.

Each chapter presents a new program and explains how the source code works. At the same time, various ciphers and cryptography concepts are explored. This book covers:

I first started this book two years ago. The Word doc calculates my editing time for the file at 85,860 minutes (not including the time to write and debug the programs). The book is over 400 pages long with over 1700 lines of code written for the programs (not including whitespace and comments).

The book’s website is at http://inventwithpython.com/hacking

Feel free to email me questions or comments at [email protected] or leave a comment below.

Read More

Taking Punches is a Sucker’s Game

There are two camps when it comes to issues of harassment, bullying, diversity, and making inclusive communities, especially when the medium is online or in the tech industry. Without trying to let my own bias tilt my presentation, I think these two camps can be summed up with the following sayings:

“Even if you think it’s a light jab, you shouldn’t throw punches.”

and

“I’ve taken worse and haven’t been bruised. You need to learn how to take a punch.”

If you don’t think the low rates of women and minorities participating in the tech industry is fundamentally a problem that should be corrected, you can stop reading now and save yourself a few minutes. But software developers are in high demand. There’s a lot of great software out there waiting to be written. And while the current generation is much more technically literate than say, 30 years ago, raising the general level of technical expertise would blossom the possibilities for more sophisticated products and avenues of communication. We should get as many people across all demographics on board as possible.

I’m not going to talk solely about sexism itself in the tech industry (though at the front of my views on that are pointing out how widely the Internet blames Adria Richards for the dongle-joker’s firing rather than Play Haven, who did the actual firing.) But I also want to talk about inclusion and how to build community, and the attitudes that tear community down.

(more…)

Read More

What Professional Games Use Pygame?

This came up as a question on Stack Overflow a while ago. While Python is noted for its use in many games, here’s a list of professional-quality games that use Pygame:

Dangerous High School Girls in Trouble is a 2D RPG by Keith Nemitz that was nominated for a Writers Guild Award, won “Most Innovative Game” by the Casual Games Association, and was also selected as a finalist for the 2008 IndieCade Festival of Independent Games. It is available for purchase off of Steam. Gameplay video
Analogue: A Hate Story is a visual novel-style game that was a 2012 IndieCade Finalist. As of December 2012, Analogue has sold at 40,000 copies. Steam store link (with videos).
Unity of Command is a turn-based, operational-level wargame that covers the entire 1942/43 Stalingrad Campaign on the Eastern Front. Trailer video. Available on Steam.

(more…)

Read More

Why I Recommend Against Hackety Hack

Disclosure: I sell a couple books that teach programming to kids (and are free to download). I don’t personally view them as being in competition with Hackety Hack, but someone else might.

Hackety Hack was a project originally started by _why the lucky stiff to teach kids programming in Ruby. It often comes up in “I want to teach my kid programming” forum threads. So I downloaded Hackety Hack and decided to give it a try.

I found Hackety Hack to be frustrating and was very unimpressed with it, and do not recommend it as a way to teach programming to a beginner.

It’s kind of crap.

Its main flaws are:

(more…)

Read More

8-bit NES Legend of Zelda Map Data

I’ve created Python & Pygame script that lets you walk around the overworld map of the original Legend of Zelda game on the 8-bit Nintendo. There are no monsters or levels or items; it is simply a walking tour. The Link walking sprite animation is implemented by my Pyganim module.

More importantly, this program does provide the raw map data the entire world map (something I haven’t been able to find on the web.) Getting this from the Zelda ROM is actually a pain due to the tricks used to store the map info. The game doesn’t store individual tiles and their XY location, but rather have one of three color schemes for the border and a color scheme for the center tiles. Even then, the game only stores columns of tiles, and then each room references which columns it uses. (You can notice the same columns being used in different rooms, even though their color scheme may change.)

These tricks aren’t really needed with today’s computers for a game as simple as Zelda, so I’ve compiled the tile map data for each individual location on the map. Here’s the world map data file (it is also included in the main download below.)

Download the Zelda Walking Tour program.

View raw tile map data.

(Just unzip all the files and run the nesZeldaWalkingTour.py file with Python. Runs with both Python 2 and Python 3. Requires the Pygame module to be installed.)

You can also download the code from the GitHub project.

(more…)

Read More

Programming AI Bots for Zombie Dice

UPDATE: I’ve set up a wiki for posting your own Zombie Dice bots: http://zombiedice.inventwithpython.com/

Download the Zombie Dice Python code from GitHub or as a zip file.

This tutorial outlines how to create a tournament simulation program for the Zombie Dice game in Python. With this tournament program, you can also code your own AI bots to play Zombie Dice against each other. You can quickly test out how the different strategies the bots use compare against each other over thousands of simulated games. This tutorial assumes you know basic Python programming. (You can learn to program from the free book on this site, “Invent Your Own Computer Games with Python”.

Computer game simulations make for great science fair experiments, and since the rules to Zombie Dice are so simple it’s fairly easy to program a simulation for it.

The Rules of Zombie Dice

Zombie Dice is a dice rolling game that is fun for groups, quick to play, and can be learned in a couple minutes. It has a “push your luck” game mechanic.

Each of the players is a zombie. Each of the dice represents a human victim. You want to eat brains and avoid shotgun blasts. If the footsteps come up, the human has eluded you. The rules are summarized below: (Or view the official rules PDF or view the Flash tutorial.)

(more…)

Read More