Archive for July, 2006

Pimp Mobile

Since I have finished work on the DSA website, I decided to get back to doing some 3d models.

Here is one I just started working on, a 1970’s style lowrider pimps car.

http://mwhite.slowchop.com/muscle.html

/wave

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

Python Quake 3 server rcon and query class

Once again, I couldn’t find a Quake 3 server query/rcon class for Python so I made one. This one is substantially better then the PHP Quake 3 rcon class that I made a few days ago. It’s called pyquake3. The features are:
* Simple interface
* Automatic retries
* Can access server variables
* Can send rcon commands
* Can collect player names, ping and frags.
* With an rcon password, can collect player ip addresses.

The Python Quake 3 project page is here and you can directly download the Python Quake 3 class here.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

Quake 3 PHP rcon class

I couldn’t find one, so I made my own Quake 3 PHP rcon class. It’s quite simple at the moment, but it works just fine. I put a one second pause before each rcon command because Quake 3 seems to ignore packets that are sent too quickly.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

A fast Python vector class

Since completing the first version of Roids, I decided to get right into optimisation. After running the Python profiler, I noticed my vector class was taking a long time in __getitem__, so I did some tests. It turns out that __getitem__ is extremely slow compared to direct attribute access. For example in some cases I was using pos[0], pos[1] instead of pos.x, pos.y. By using attribute access, it yielded approximately an 8-10 time improvement over __getitem__. I quickly removed any reference to this!

I became curious about what else I can improve, I tested the time difference between creating an old-style class and a new-style class. It turns out that new-style classes are created 1.5x faster then old-style classes.

An Old-style class looks like this:

class Vec:
    def __init__(self, x, y):
        self.x = x
        self.y = y

New-style classes look like:

class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

There was another test I did, which was using __slots__. By defining a list of attributes you will be using in your class, a new-style class will not create a __dict__ object for the class. This decreases the time it takes to create an instance of the class by a slight amount (13.6% in my tests). Here is an example:

class Vec(object):
    __slots__ = ('x','y')
    def __init__(self, x, y):
        self.x = x
        self.y = y

One final test was using a list as a base class instead of just using object. For example:

class Vec(list):
    def __mul__(self, o):
        return vec((self[0] * o, self[1] * o))
a = vec((1.0,2.5))

This was about 20% slower then my new-style class using __slot__.

Overall these changes improved the speed of Roids quite substantially. After all that, here is the fast Python vector class.

Note: These tests were run on a Pentium 4 running Windows XP with Python 2.4.2. Since I’m only testing on one platform these results may vary for you. I plan on testing these on other computers and operating systems soon.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

Thoughts

Firstly, welcome to the blog, I know all of you are very excited about it.

I’m currently working on a website and am always interested in opinions.

http://mwhite.slowchop.com/dsa/site2.html

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

40 hour python multiplayer game challenge

After 6 days and 40 hours I managed to make a simple multiplayer game called Roids. On the surface it looks like another Asteroids clone but it is a litte more then that. At the moment Roids has two teams with players that fly around just like the original Asteroids, but one player on each team can become a RTS player. It was written in Python so it runs a little slow and will be improved over time. The version released was 0.0.1 and I’ll be working on it for the next few weeks.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon

What is Slowchop Studios?

Good question. We like to keep our secrets, well, secret.

There have been many questions asked about Slowchop Studios and some of them may be answered on this web site.

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • description
  • Reddit
  • StumbleUpon