Now that I have experimented a little with Python, my mind is already considering which fun, sample programs I could write to learn the language. So far, I can think of two.
Idea #1: Create A Text Adventure
This would be a “fun with objects” learning experience. I could define a room object and an object object and populate a world with them.
I could create a stub of a def parser(): function, which would interpret text typed by the user.
In its own, tiny way, this would be my tribute to the Infocom games that I used to play.
If I am lucky, the game will be more exciting than my life at work:
You are seated at an office desk. Behind you is a window. To your right is a photocopier. Exits are to the south and west.
You are sitting behind dual 17” displays at work. In the right display, the Microsoft Outlook Inbox is maximized, like it is every day. A message from your brother Carl is highlighted there. To the left of your keyboard is a small cup of coffee with cream and sugar. The cup is half empty.
You hit the monitor with your fist. Your knuckles hurt.
- Press the reply button with the mouse.
A window appears in the left display. You can see happy little desktop icons in the background.
You don’t see any coffee here!
You take a sip of coffee. It is lukewarm. Your stomach turns.
- Type a reply using the keyboard
You place your fingers on the home row of the keyboard. The keys are slightly discoloured, possibly from the dirt from the factory floor beyond this room, possibly from one too many snacks eaten at this desk.
Idea #2: Create a Game of Life
Now, this game is notConway’s Game of Life, simply because I never enjoyed the stupid repeating patterns.
Instead, I would create a bug object. Each bug would have an x% and %{color:red}y position on a two-dimensional world.
Each bug would also have a energy level that would count down with every move. When the bug discovers food, its energy increases. When the bug moves, it expends energy. If it doesn’t eat frequently enough, it dies.
To make the game interesting, each bug could have its own genotype in a 3×3 matrix for each of the cardinal directions plus the middle element for no movement at all.
Two assumptions I have already made for now are that multiple bugs can inhabit the same x,y position on the screen peacefully, and that bugs are blind and move without sensing the world outside.