PyEigen progress

Filed under Game development by Jussi Lepistö

Development of PyEigen is going really well. All the features I want for a 0.1 release are basically done and there’s just testing and documentation left now. For version 0.1 documentation I’ll just write some docstrings and a readme file, but I want full unit tests for the module. Vectors and matrices are really low-level stuff and writing C code is quite prone to errors, so I want to make sure everything works and it can’t be crashed.

I’d say you can expect a first release in about a week. It’s going to include support for fixed-size matrices (2×2, 3×3 and 4×4) and column and row vectors (2-, 3- and 4-dimensional). Major game development -related features missing include transformations and quaternions; they are probably coming in the 0.2 release along with coefficient-wise (aka element-wise) operations. I’ll probably add support for variable-size matrices and vectors later. Compatibility with ctypes and NumPy would probably also be useful. Feature requests are welcome. :)

No responses yet

More types and results

Filed under Game development by Jussi Lepistö

I implemented some new types for PyEigen, including a 4×4 matrix class and benchmarks for it. Same methods as last time, but quite different results.

Benchmark results

Benchmark results

PyEigen is still fastest by far, which is promising. This time it was about 5-10x faster than cgkit1, which was again the second fastest. You might also notice that vectypes is missing. For this test, it was so slow that I had to leave it out; other results would have been invisible if I had fitted the vectypes results in the graph. In the worst case, it was over 1000x slower than PyEigen! Euclid is missing addition and scalar multiplication scores since it doesn’t support those operations. NumPy performed much better. There has to be a faster way to do vector cross product in NumPy, since matrix multiplication was much faster than cross product. But it’s not a big deal anymore since PyEiglet is so much faster than anything else. :)

No responses yet

Surprising results

Filed under Game development by Jussi Lepistö

I did some preliminary benchmarking today and got very interesting results. I have only wrapped a 3D vector class so far, so I tested a couple of operations (add, multiply, dot & cross product) against the libs I mentioned in the previous post: NumPy, euclid, vectypes and cgkit. For cgkit, I tested both 1.2.0 and 2.0 alpha 9. All other libs were the latest version. I tested using the Python timeit module with 1,000,000 calls and 3 repeats per test and took the lowest number. Repeated test results generally differed only by milliseconds.

Benchmark results

Benchmark results

The immediately obvious surprise is the abysmal performance of NumPy especially in cross products. I don’t think NumPy optimizes for fixed-size arrays; I would have been better off with the pure-Python euclid and vectypes modules.

The other surprises were euclid vs vectypes and cgkit1 vs cgkit2. Euclid and vectypes are both by Alex Holkner of Pyglet fame. In both cases, the newer library (vectypes and cgkit2) was also slower.

Of course the most positive surprise for me was the performance of PyEigen. It’s only a trivial wrapping, but was about 2-8x faster than the best alternative, cgkit1. I’m very happy with the results and definitely going to continue development of the library / wrapper. :)

Update: Here’s the benchmark code. Also an interesting detail: PyEigen is 136x faster than NumPy with cross products.

No responses yet

PyEigen

Filed under Game development by Jussi Lepistö

I have a new project called PyEigen, a wrapper for the C++ linear algebra library Eigen. I just submitted the first batch of code and progress is good, at least so far. :) I’m hoping for an initial release within a month or so.

The whole thing started when I profiled my shooter project and found that matrix calculations take up a huge amount of time. Apparently NumPy isn’t really fast enough for 3D games, and I couldn’t find any replacements. While otherwise looking good, euclid and vectypes are pure Python so they aren’t going to make performance any better. cgkit is C++ with a Python wrapper so looking better already, but… it’s using Boost.Python, which apparently isn’t very fast. Also, it’s lacking SSE instrumentation and other optimizations included in Eigen. So I decided to wrap Eigen.

As I already found out, Boost.Python is slow and looked too complex for such a simple library anyway. I tried Cython next, but its C++ support is (still) very limited and the lack of support for C++ references destroyed any hope of wrapping Eigen, which relies heavily on them. My final option before resorting to manual wrapping using the Python C API was SWIG, but I had problems getting even a simple wrapper to compile. Besides, I don’t really like how SWIG generates function wrappers and a separate Python module that calls those wrappers instead of generating a Python C module directly.

So I was left with only the final option: Python C API. I feared it at first because I’ve never worked with it and it seemed really complex. It is complex, but not nearly as bad as I though, especially as Eigen has such a simple API. For Bullet, I’m sure I’ll use Cython or some other wrapper generator, but for Eigen the Python C API is just fine.

Anyway, since there doesn’t seem to be anything like this out there, I decided to make it an open source project so hopefully other people in the same situation won’t have to jump through the same hoops as I did. I’ll post progress reports, releases and especially benchmarks against the other options as soon as I have them.

http://launchpad.net/pyeigenI h

No responses yet

Stealth prototyping

Filed under Game development by Jussi Lepistö

Yes, I know, I have been quiet on this blog for over half a year now. That doesn’t mean I’m dead; quite the opposite, since I have been really busy with Real Life and professional game development. :) However, as some of you might have noticed from my Twitter feed, I have been working on a new game. It started as a vertical-scrolling shoot’em’up but has transformed into something else entirely. At the moment I have just a load of ideas and an early prototype, so I don’t want to write too much about it yet, but more on the project later. And yes, it’s in Python. :)

As for Artillery Brawl, the code became a mess and destroyed my motivation to continue the project, which is why I started the new game to begin with. I might start Artillery Brawl again based on this new codebase, but for now I’m working on the shooter.

I hope to write more about the new project and its progress again in the near future, but in the meantime, the best way to follow the project is my Twitter feed.

Comments Off

Work!

Filed under Real life by Jussi Lepistö

My latest excuse for not getting anything done on Artillery Brawl or any other projects is that I just landed a job in the game industry! I didn’t want to announce it on the blog before I got a contract, but today I got one as a programmer for Bugbear Entertainment. It’s interesting and kind of refreshing to seriously program in C++ for a change.

One response so far

New city, new portfolio

Filed under Real life by Jussi Lepistö

I have succesfully moved to Helsinki, though the apartment is of course still a mess. While organizing the apartment, I also decided to reorganize my Portfolio page. Please check it out, all kinds of comments are very welcome!

I should be hearing about the job next week.

Comments Off

Sampling some C++

Filed under Real life by Jussi Lepistö

Since I have the job interview on Thursday, I decided to brush up my rusty C++ skills and make a quick work sample while at it, as I haven’t really worked with the language since about 2004. The position I’m applying for is UI programmer, so I made a simple but relatively flexible “game style” menu system. At first, I had to look up lots of things in documentation, but at least I knew what to look for, and overall it went surprisingly smoothly. I spent about two evenings on it, so don’t expect anything polished.

If you want to check out the demo and some old stuff of mine, see http://www.brainfold.org/portfolio/. I’m releasing the code in public domain, but check copyright.txt for the font copyright. Apart from the demo, my time has been spent preparing for the move to Helsinki on Wednesday, so again, don’t expect any real updates for at least a week or two.

Comments Off

Moving on

Filed under Game development, Real life by Jussi Lepistö

I haven’t updated for a while again. Let’s get gamedev news out of the way first. I haven’t worked on Artillery Brawl for a couple of weeks; instead, I have tried to get the card game ready for testing. I made some prototype cards by putting pieces of paper in sleeves that are opaque on one side. This has the advantage that I don’t have to go through the trouble of making the back sides of the cards look identical, so it’s much easier to make changes. Unfortunately, while the rules are basically ready for testing, I ran out of card sleeves, and when I bought some more I accidentally bought a different size… Now I’ll have to wait until next week to buy some more, sigh.

Anyway, about next week… I have a job interview at a game company (wish me luck!) and I’ll be moving back to Helsinki where I used to live four years ago before I moved here to Tampere. I also have a couple of deadlines looming for university courses, so I’ll be quite busy for the next week or two! At least I already have internet connection at the new apartment, so my connection to civilization won’t be severed. ;) See you in a couple of weeks!

Comments Off

Good news, bad news

Filed under Game development, Real life by Jussi Lepistö

The good news is, suddenly I got a whole lot more free time for game development.

The bad news is, I don’t have a job anymore (yay for the economic situation).

I didn’t just freeze and panic though; instead, I called a friend at a game company I was applying to for the summer, and told I might be available for work a bit earlier after all… I hope to hear more from them next week, so wish me luck!

As for other news, I have been working on Artillery Brawl a lot, though still no particle effects… I think they might be cursed, since every time I get close to implementing them, I run into problems or some other thing I just have to fix. Anyway, the good thing about this is that the entity system and a lot of the code in general is starting to look really good and reusable. This is how I should have approached building a reusable codebase to begin with; writing a game, then generalizing the solutions that work.

One response so far

Older Entries »