The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:
The Blog-Health-o-Meter™ reads This blog is doing awesome!.
A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 3,000 times in 2010. That’s about 7 full 747s.
In 2010, there were 8 new posts, growing the total archive of this blog to 70 posts.
The busiest day of the year was March 22nd with 25 views. The most popular post that day was Zombieee.
Where did they come from?
The top referring sites in 2010 were facebook.com, en.wordpress.com, en.search.wordpress.com, stackoverflow.com, and yandex.ru.
Some visitors came searching, mostly for memory hacking, python line intersection, line intersection python, pygame dirtysprite, and openclonk.
Attractions in 2010
These are the posts and pages that got the most views in 2010.
Zombieee March 2010
Python 2d line-line intersection December 2009
Svn to Mercurial migration guide (Windows) February 2010
Memory hacking newbie February 2010
Dirty dirty tracking in Pygame January 2010
I just updated my browser, to Opera version 10.51 (recently switched from Chrome), and something strikes me as odd. Its hard to switch the active tab. It turns out that the designers aren’t, apparently, aware of Fitts’s law. In a strange twist of fate, this most important law in GUI design was just today given some attention in the (close to legendary) blog Coding Horror. Jeff Atwood also links to a great visual summary of the law so there is no need for further explanation here.
So where does Opera go wrong? Well, in its most extreme summary Fitts’ law states that the larger a button is, the easier it is to click. Simple and logical. Heres a screenshot of Opera and one of my open tabs:
The topmost two pixels aren’t considered part of the tab, so by moving my mouse cursor to the very top of the screen I can’t click the tab. I must stay put on it. This is bad.
Why is it bad? Because the mouse cursor can’t be moved outside the screen. Once it reaches the edge it stops. Thus, by placing a button at the edge of the screen, its width/height (and therefor size) is infinite. And, according to Fitts’ law, infinitely easy to click!
This is far from something new. According to Wikipedia, Paul Fitts proposed the law back in 1954. And Jeff Atwood has written about it before, close to three and a half years ago he touched on this exact same problem; the infinite size of buttons placed at a screen edge.
OSX places its menubar buttons at the top, by the edge of the screen, rather at the top of each window, which is more common. Thus giving them infinite height. Its about the only thing it does right when it comes to GUI design but it works. And really good at that.
Google Chrome understands Fitts’ law. Why doesn’t Opera? Why?
And how do you, by the way, correctly spell Fitts’s law?
Next step in the Zombieee project was to install something on it that could actually be used. FTP servers are basic and nice. FileZilla seems to be the server of choice, at least on the Windows platform. Lifehacker has a great guide on how to actually install it.
You’re probably behind a router, as I am, so we need to do some port forwarding. There are guides for most routers over at portforward.com, they also have a nice tool that can determine if the port was actually forwarded correctly. Now is also good time to read up on the theory behind this. Once everything seems in order, you can let some web tools (ftptest.net or g6ftpserver.com) test the connection. Since were dealing with port forwarding, testing inside the local network itself aren’t of much use.
I hope you read the theory because now its time for the fun part of this ftp adventure! Turns out that some routers think they are smarter than you and “improves” (read: destroys) data going through it. I spent quite a few hours trying to figure out why I couldn’t connect in PASV mode. EPSV mode worked, as can be tested on the g6ftpserver site.
When the client sends PASV to the server, the server sends the port back it should connect on. It looked like this in the FileZilla server interface when it failed:
> PASS *********
> 230 Logged on
> 215 UNIX emulated by FileZilla
> 257 "/" is current directory.
> TYPE I
> 200 Type set to I
> 227 Entering Passive Mode (xx,xxx,xxx,xxx,23,144)
The last two numbers in the 227 response indicates the port that should be used for transmitting data according to the formula 23*256+144 = 6032. I use 6000-6100 for passive mode (can be configured through the FileZilla server interface) so as far as the actual port forwarding goes, I should be fine. I made a thread about it on the FileZilla forums but managed to solve it before I got any responses.
The solution? Simply change the listening port for the server. Default is 21, after changing it to 2121 everything runs smoothly. Seems like the router only does its hazardous “optimizing” on the default ftp port.
On the other hand, I haven’t ruled out the option that my ISP doesn’t like the idea of me running an FTP server. So I’ll skip writing a long and angry rant about my routers manufacturer.
So the Zombieee project goes on. Next step was to setup a remote connection so that I could experiment with it without giving it a dedicated desktop space. Space is a rare commodity in my apartment. I usually use the built-in windows remote access tool to do this but after finding out that my Eee was shipped with Windows XP Home Edition (which lacks that feature) I started to look for alternatives.
You can find out which version of Windows you have by running winver.exe from the command prompt.
- Download TightVNC, I went wild and crazy with the shiny new 2.0 beta 1 release.
- Install the server, remember to set a password just in case.
- Open up port 5900 in the Windows Firewall.
- Now install TightVNC again, the viewer, on the client computer.
Heres a screenshot of the viewer connected to my Zombieee (I should seriously change its hostname):
After my old laptop started acting up, like, constantly I grew tired of it and bought an Asus Eee Pc to have something to surf the net on. Back then, I lacked the money to buy a “real” computer. Then I got some money and bought my new rig a couple of weeks back. Since then my Eee has been collecting dust. I want to find a use for it, surely it must be able to be used for something. Found a nice blog post containing quite some inspiration. Besides, the spelling Zombieee cracked me up when I thought about it. So the adventure to reanimate it (yes, that was a pun) is on. I placed it in the window, heres a photo:
Now, what should I use it for?
I recently wanted to work on a project hosted at SourceForge (SVN), to which I didnt have commit access. Since I still wanted to have my work version controlled, I decided to take a stab at converting the source tree. I was reading this guide and this post documents my experince.
You need to install:
- Python setup tools
- And add easy_install.exe to PATH, its located (by default) in C:\Python26\Scripts
Then install hgsvn by running
hgimportsvn https://dfhack.svn.sourceforge.net/svnroot/dfhack cd dfhack hgpullsvn hg update
hgpullsvn is going to take a while so go make yourself a cup of coffee. For me, I judged the average to be around 10 seconds per svn commit. Luckily, the project I converted only had 166 commits. During the import it failed a few times, but just running the command again seemed to make it pick up where it left off and just continue. The errors varied but always ended with that svn “couldnt connect to the sourceforge server”. Maybe I just hammered it to hard.
If you just installed mercurial you should set your username before your first commit. Open up notepad and save this to %USERPROFILE%\Mercurial.ini (obviously replaced with your own name):
[ui] username = John Doe <firstname.lastname@example.org>
After the import, there is a local .hgignore file, just add it:
hg add .hgignore hg ci -m "added ignore file generated by import"
When I first tried to push I got a authentication error so I went into my Bitbucket account settings and added my public ssh key. If you dont have one github has instructions on how to set one up, you can also use the git bash shell as a ssh agent.
The import is now done, after youve created a Bitbucket repos just push to it:
hg push http://bitbucket.org/mizipzor/dfhack/
Pulling new changes from SVN
By the time my conversion was complete and I had pushed it to my own repos two new revisions had been commited to the SVN. Fetching them was suprisingly simple:
hgpullsvn hg merge hg ci -m "merge from svn" hg push https://email@example.com/mizipzor/dfhack
But do note that since we dont track the .svn or .hgsvn folders, should ever you do a clean checkout from the Bitbucket repos, the hgpullsvn command will say this:
C:\Code\dfhack-hg2>hgpullsvn Traceback (most recent call last): File "C:\Python26\Scripts\hgpullsvn-script.py", line 8, in <module> load_entry_point('hgsvn==0.1.8', 'console_scripts', 'hgpullsvn')() File "build/bdist.linux-i686/egg/hgsvn/run/hgpullsvn.py", line 315, in main File "build/bdist.linux-i686/egg/hgsvn/run/common.py", line 90, in locked_main File "build/bdist.linux-i686/egg/hgsvn/run/hgpullsvn.py", line 196, in real_main File "build/bdist.linux-i686/egg/hgsvn/svnclient.py", line 152, in get_svn_info File "build/bdist.linux-i686/egg/hgsvn/common.py", line 236, in run_svn File "build/bdist.linux-i686/egg/hgsvn/common.py", line 169, in run_command File "build/bdist.linux-i686/egg/hgsvn/common.py", line 142, in _run_raw_command hgsvn.errors.ExternalCommandFailed: External program failed (return code 1): C:\ Program Files\SlikSvn\bin\svn.exe "info" "--xml" "."
Which is an ugly stack trace for simply stating that “this is not a working checkout of a svn repos”. I dont really like this. I wouldnt want those folders on my Bitbucket (the guide I read suggested it), but I really like the feeling of knowing that if I screw up I can just delete the folder and do a new checkout. With my current setup, I would have to run the svn import all over again. This issue alone might make me look into alternatives
but for now, this works well enough.
Talked to a friend today about the game Dwarf Fortress and the progress its visualizer Stonesense is making. Dwarf Fortress is not open source, Stonesense uses some memory hacking techniques to read the state of the game world and render it. Memory hacking is, in my eyes, a dark and arcane art. Theres that mythical feel to it. Probably due to my lack of knowledge about it.
Ive been at it a few times, trying to change that. The conversation today sparked my interest yet again and I downloaded a much simplier program this time, with a nice builtin tutorial and everything. Maybe I was aiming to high in my earlier attempts.
A screenshot of Cheat Engine:
I got all the way to step 8 in the tutorial. The lesson in that tutorial was how to handle multi level pointers. A bit to big of a hazzle I felt. Besides, there are only 9 steps, I want to save some fun.
Also I wanted to try this out for real! So I started up the Minesweeper game found in Windows. Had no luck modifying the number of mines left. Might be because my Windows 7 install is 64bit. Or that its a function writing to that variable (now that Im writing this, I realize that I forgot to check that). In the screenshot above you see me attacking the game, with the wikipedia assembly reference in the background.
My ultimate goal would be to gather enough knowledge and experince in this to be able to help the memory hackers making Stonesense possible. :)
My latest little pet project, a game, has progressed far enough to have some rendering put in. I’ve always used Pygame for my games in Python. This started out as no exception.
Pygame uses SDL, in which rendering is simple but slow. You can get some quite significant speed boosts if you only redraw the pixels on the screen that actually change. So you keep track of where the sprite was and if it moved, you redraw the background there and then draw the sprite at the new location. DR0ID has a great article (scroll down to “Dirty Rects”) explaining this!
Anyway, I made a snippet to show how its done, the code is at the bottom of the post. Notice the use of Pygame’s sprite group LayeredDirty, it handles dirty sprites and keeps track of sprites moving across each other. In that snippet the Below class would be a background tile, Above would be the player’s avatar moving across it.
So theres two things I don’t like here. First, when implementing the rendering in my game, all of the drawing bugs were related to me forgetting to set the dirty attribute when I should have. Rendering code is boring to write, so I want it to be as simple as possible. In a perfect world, the sprite would keep track of its dirty status itself. This is also the reason for the title of this post, since its a cumbersome part of Pygame, its dirty. Get it?
Jokes aside, the second thing is that I go through all this trouble to gain some speed. But how much extra speed? How many sprites do I need to put into it before it starts to slow down? I plan to do some benchmarking on this (anyone know about any Pygame benchmarks by the way?).
The norm in systems like OpenGL or DirectX, more commonly used in games, is to redraw the entire screen each frame. That way you don’t have to care about dirty attributes. Those systems are also, at least as far as I know, faster than SDL. There are OpenGL libs for Python. I recently found the project Pyglet, which seems to be written as an alternative to Pygame. I’ll look into that, if it both easier to code in (no manual dirty tracking) and faster, there’s no reason not to switch.
Now for the code:
import pygame from pygame.locals import * pygame.init() screen = pygame.display.set_mode((100,100)) background = pygame.surface.Surface(screen.get_size()).convert() background.fill((0,0,255)) group = pygame.sprite.LayeredDirty() class Below(pygame.sprite.DirtySprite): def __init__(self): pygame.sprite.DirtySprite.__init__(self, group) self.dirty = 1 self.layer = 10 self.image = pygame.surface.Surface((25,25)).convert() self.image.fill((255,0,0)) self.rect = self.image.get_rect() self.rect.center = (50,50) def update(self): pass class Above(pygame.sprite.DirtySprite): def __init__(self): pygame.sprite.DirtySprite.__init__(self, group) self.dirty = 1 self.layer = 20 self.image = pygame.surface.Surface((10,10)).convert() self.image.fill((0,255,0)) self.rect = self.image.get_rect() self.rect.center = (25,50) self.going_right = True def update(self): if self.going_right: self.rect.centerx += 1 if self.rect.centerx > 75: self.going_right = False else: self.rect.centerx -= 1 if self.rect.centerx < 25: self.going_right = True self.dirty = 1 def main(): Below() Above() while 1: for e in pygame.event.get(): if e.type in (KEYDOWN, QUIT): return group.clear(screen, background) group.update() group.draw(screen) pygame.display.flip() if __name__=="__main__": main()
One thing I didn’t decide on when starting this blog was the topic. I wanted to be able to write about anything that interested me. Nevertheless, a “topic” more or less evolved naturally. Although I haven’t really been able to figure out what it is, sometimes I don’t post something because I feel that it doesn’t belong on my blog, almost like its offtopic.
Disregarding the fact that its impossible to go offtopic on a blog without a topic, there are a few shortcomings I feel I have in my blog:
- No schedule, since I haven’t found the discipline to take Jeff Atwood’s advice to heart.
- No specific topic, for reasons stated above. Although I do not really care for readers, should I ever do, this needs to be improved.
- No specific goal. Deciding on a topic and a long term goal may greatly increase the overall quality of the blog. As I will explain later, a “create games” category could contain simple tips about making games, with focus on actually completing the projects.
Is there a way to remedy this? During the past few days I’ve been sick and home from work, so I’ve had way to much free time to think about different ways to approach this. Looking through my blog archives, there seem to be a few topics I like to write about:
- Programming, in general.
- Creating games.
- Open source applications and games, trying out new technologies I find.
- Artificial intelligence/life.
Getting a discussion going is great, and that may happen if I manage to get some readers. In order to get readers that keep coming back, what I write about must interest them. Simple really. I’m so aware of this myself when reading my RSS feeds, some blogs have posts thats feels either irrelevant or very interesting.
I’ve toyed with the idea of creating separate blogs for each topic. I just started the Game Gardener to direct some of my “create games” posts that way. Although WordPress does a good job of letting one user create multiple blogs, I cant escape the feeling that now is the time to investigate if there is another way to handle this.
Is it possible to contain several blogs inside one blog? Whatever that means. Some clever use of a tag/category system coupled with a different theme for each category might get very far. Then, of course, the most important part really is to be able to offer a separate RSS feed for each “blog” (that is, each category).
I just read about Wolfire switching blog system, and through that found about bloggart code. An opensource system that might get some attention through Wolfire. Maybe I can take a look at the code, it could be possible to add my new-kind-of-category, that is a blog in the blog, in that.
Sections. I will call my new kind of super category a section. Yes.