Python! Is! Truly! Amazing!

Erik Bethke erikbethke at gmail.com
Sun Jan 2 04:17:41 EST 2005


Hello Everyone,

I have to say:

Python! Is! Truly! Amazing!

So I started with python about a month ago and put in 24 hours across
three weekends.

My first project was to recreate a simple maze-let thingie that I
remember as my first program way back on the Vic-20.  That was a quick
snap and a pleasure.

Since then I have settled down into working on a Mahjong game.  I have
uploaded a current version at my personal website:

www.erikbethke.com/Python/mahjong.zip

also note screenshots:

www.erikbethke.com/Python/screenshot01.jpg
www.erikbethke.com/Python/screenshot02.pg
www.erikbethke.com/Python/screenshot03.pg
www.erikbethke.com/Python/screenshot04.pg
www.erikbethke.com/Python/screenshot05.pg

So I have been using Python 2.3.4 as that is what was compatible with
the excellent PyGame last month.  After reading the posts here I am
using wing IDE, and over all I like it... some minor issues and I am
sure if I RTFM I would have these handled.  I will be buying a bunch of
licenses for us.

I also used this project to learn a little about XML, so I used XML to
fully describe the UI, the tilesets and the tile layouts and have it
able to go back and forth between 3 different tilesets, and backgounds.
The XML is crappy as you can see I am experimenting with putting some
data in attributes and elsewhere in elements.

So now I have it laying out the tiles, tile picking correctly, and I
was even able to write many new little feature-ettes in wickedly fast
single edit-run passes such as this to highlight the currently
available matches:

def findMatchingTiles(self):
matchList = []
visibleTiles = []
for i, c in enumerate ( self.tiles ):
if c.state != 'clear':
visibleTiles.append( c )

for i, c in enumerate ( visibleTiles ):
if self.testForClear( c ):
for j, d in enumerate ( visibleTiles ):
if d != c and d.tileNum == c.tileNum and self.testForClear( d ):
matchList.append( [c, d] )
return matchList

def showHint(self):
matchList = self.findMatchingTiles()
for i, c in enumerate( matchList ):
c[0].state='clicked'
c[1].state='clicked'
self.draw()


I have NEVER experienced this kind of programming joy.  I am a 33
year-old professional game developer (www.gopetslive.com) and have been
in the industry for 11 years, and have been programming since 4th grade
like all the rest of you guys.  And I am not saying all this to brag,
no seriously I am delirious in joy right now.  I have a bad cold and
went to sleep at 1am last night and woke at 5am just to get back to
playing with Python!

I have been looking into Python to see if it is a good answer for
getting a lot of new fresh mini-game and UI work done for our project
GoPets, and clearly it is.  I haven't yet explored the server-side
but I will.  The Mahjong game in the future will take its tile art
dynamically from the portraits of the users that are your friends and
the people your GoPet has visited recently.

Anyways, I am now a super gushing fan-boy.  I have worked my way up
from a scripter working in crappy proprietary languages to a c++
programmer, to now biz guy.  But when I walked away from programming I
gave it a grim farewell, c++ work is good, but so much mind goes into
it to make progree compared to other creative uses of the mind.  But
Python rocks, it makes programming very fun again and now I finding
myself coming home earlier so I can get to work on Python and I have an
entire heap of new projects I wanted to get done.

Anyways, the Mahjong game code is quite crappy.  No effort has been
made to optimize it, nor have I handled any sorts of errors whatsoever.
I know it sucks.  But I posted the code there anyways in case any one
else is just coming along and wants some more example code.

I also have no real UI going on.  Hit R to randomize the tiles, M to
try to setup a solvable game (but my algorithm for this is not very
effective yet), and H for hints on tiles that can be matched.

Other than the tile art anyone can do what the feel with it.

Thank you all for posting here, you have already solved dozens and
dozens of questions for me with a little help of google groups.
Truly thank you.

-Erik




More information about the Python-list mailing list