I made another game – Worm Game!

September 19, 2019 Leave a comment

I took part in the “LOWREZJAM 2019” on itch.io – the challenge was to create a game in 2 weeks, with a maximum resolution of 64×64 pixels. My entry can be found at https://i82much.itch.io/worm-game. It was a lot of fun and a good learning experience – I’ve never used PICO-8 before, and it’s only the second ‘real’ game I’ve released (see my previous Rocket Runner game if you’re interested).

 

Advertisements
Categories: Gaming, programming

rstripping Simon Pegg: Don’t use rstrip for file extension removal

March 12, 2018 Leave a comment

In Python, what does '/path/to/my/simon_pegg.jpeg'.rstrip('.jpeg') yield?

If you guessed '/path/to/my/simon_pegg' – good try, but not quite right. The real answer is '/path/to/my/simon_'.

Despite what you might intuitively think, rstrip does NOT strip off a substring from the end of a string. Instead, it eliminates all of the characters from the end of the string that are in the argument. (Note that this is not mutating the string; it returns a copy of the string.)

Since pegg contains the characters that are in .jpeg, it is eliminated as well.

While this behavior is documented, it may be surprising.

Why does it matter? There are many instances of people attempting to use this rstrip approach to strip off a file extension. For instance, you might be converting an image from one filetype to another, and need to construct the final path. Or you might want to rename a bunch of files to have consistent extensions (jpegjpg).

This buggy implementation of stripping a file extension is tricky because most of the time it works – but it works by coincidence (the file name happens not to end with the characters in the file extension).

Github is rife with examples of people making this same mistake. For instance,

main.py: name = str(name).rstrip(".tif")

fixname.py:os.rename(i.path,
i.path.rstrip('.gzip').rstrip('.gz') + '.gzip')

selector.py:l = [i.rstrip(".jpg") for i in k]

The Go language has the same semantics for its TrimRight function. This leads to the same sort of mistakes when people use it to trim file names. For instance,

filehelper.go: filename := strings.TrimRight(f.Name( ".pdf")

latest_images.go: idStr := strings.TrimRight(f.Name(), ".jpg")

The lessons to be learned from this are,

  1. Read the documentation of the library functions you use.
  2. Test your code, and not just of the happy paths. Good tests should try to break your implementation and exercise edge cases.

 

(Hat tip to my colleague Fredrik Lundh who alerted me to this problem and inspired this post)

Video: “Meet Spot, the robot dog that can run, hop and open doors”

August 9, 2017 Leave a comment

Still from TED talk video of

This is an incredible video. When I worked on a robotics team in college, we had a hard enough time with the four legged Sony AIBO robots on a fixed field with fixed landmarks. In this live demo, they show the dog pathfinding and adapting to changing terrain in real time. Inspiring engineering

I made a game – Rocket Runner is live now!

May 22, 2017 Leave a comment

After months of Coursera classes in game design, I just finished the capstone project – an eight week course to build a game from scratch. I built the game Rocket Runner using Unity. You can play it now on Kongregate. I hope to put it in the iOS and Android app stores in the next few weeks.

 

I hope you enjoy! Let me know what you think in the comments.

Categories: Uncategorized Tags: , ,

Link: graphics analysis of Deus Ex: Human Revolution

March 21, 2015 Leave a comment

Screenshot from the article showing normal map generation

http://www.adriancourreges.com/blog/2015/03/10/deus-ex-human-revolution-graphics-study/

This is one of the best presentations I’ve ever seen. Each step of the rendering pipeline is explained clearly, and the animated transitions between the screenshots are incredible. I can’t wait to read more from this author.

Categories: Uncategorized

Your update is not more important than my work

March 5, 2015 Leave a comment

I love TextMate, but I just saw the most user-hostile, infuriating thing. I’m doing work when all of a sudden I get the pop-up:

 

TextMate forced update

TextMate forced update

It closed my document (thankfully giving me a chance to save), and now the program refuses to launch until updated.

sigh

Link: At Chipotle, How Many Calories Do People Really Eat?

February 20, 2015 Leave a comment

http://www.nytimes.com/interactive/2015/02/17/upshot/what-do-people-actually-order-at-chipotle.html?abt=0002&abg=0&_r=0

This article makes good use of histograms to display distributions rather than just standard descriptive statistics like “average”. For those who haven’t taken much math or haven’t been exposed to these sorts of distributions, the author also picks out certain points along the cumulative frequency distribution chart to explain what they mean; for instance only 10 percent of meals have less than 625 calories.

For many data sets (especially non-normal ones that arise in social networks, arithmetic mean (sum and divide by the number of elements) is a gross approximation of the real central tendency. See Ed Chi’s great article about this subject.  (Full disclosure: I have worked with Ed at Google)

Categories: Uncategorized