PC Awaker

Click to download it.
Click to download it.

Usually there are a lot of rules in global companies. One of them is the rule of forcing PC go into screen saving after 5 minutes, and if you want to use the PC again, you have to enter your password to unlock the PC.

I admit that this is necessary for security reasons. But sometimes it’s not so reasonable for some of the PCs. For example, if one needs to support a product in a fast paced environment, they cannot afford entering password every time they need the PC – and in fact, the PC’s screen should never be turned off during the work time at all.

The tricky part is that usually we cannot change the screen saver settings because this feature is locked to enforce this rule. In this case, this ‘PC Awaker’ comes to the rescue.

This application is a tiny Windows utility, it is designed as a ‘tray application’, that is, it usually stays in the ‘tray’ of Windows task bar, unless you bring it out. The way how it keeps PC ‘awake’ is to send simulated key strokes periodically – to press F14 key every 4 minutes, to be precise. These are hardcoded since I don’t think it’s necessary to make these configurable.

The license of this software is ‘HSL‘. Help yourself if you need it.

Download it here. It was built in Windows XP using Visual C++ 6.0. I hope that it can work in Windows 9x/ME/NT/2000/XP. Don’t know if it works in Windows Vista…

My Tetris with AI Functionalities

(click on image to play tetris)

Tetris game was invented by a Russian scientist. The concept is very simple but effective – even today there are a lot of people enjoying this game.

I am not only interested in playing this game, but also interested in writing it (since I am a programmer 🙂 ). It has been my habit to implement Tetris games to practise GUI programming with a newly learned language. The earliest one was done on MS-DOS using C language (in an Borland IDE called Turbo C, by the way), I worked on some tricks like writing directly to Video-RAM to increase the performance, etc; then I did it using Visual Basic 6.0; then Visual C++ 6.0. Unfortunately all these versions are lost due to hardware upgrades.

Then in 2000, I joined a New York based company called Financial Sciences Company. There Java was chosen as the main language to work on their next generation trading applications. I knew nothing about Java at that time (I was accepted because of my C++ skills). So I learned it by reading ‘Core Java 2’ and ‘Professional Java Server Programming (J2EE edition)’, and practised and sharpened the skill by writing some programs in my spare time. This implementation of Tetris was the result of my study and practice of Java GUI programming using Swing. I think that it is the best one among my Tetris series.

Lately I don’t have the time to play with these Swing stuffs any more, so I just got some time to improved the algorithm in AI part to make it demo better. You can choose ‘X’ level to see the demo.

Features:

* Employing M-V-C pattern, game logic, data and the game screen are seperated, this makes the code very clean;
* The game panel is encapsulated as a component, so it can be dropped to any container conveniently using an IDE;
* Except the control buttons etc., it doesn’t use any control in Java API, instead, it draws directly to screen;
* It supports multimedia;
* It supports internationalization (i18n), with built in English, Chinese (simplified & traditional) and Japanese languages support;
* It has a very easy-to-use and intuitive user interface;
* It has an effective AI logic to demonstrate how to play this game.

About AI:

The AI part was implemented in following way:

The basic idea was to try to turn and put the coming block at each possible positions, evaluate the results, then choose the best one. But how to evaluate the result is the main problem.

First, we need to find which factors affect the final result, and get them out. For example, the height is definitely not a good thing (0 is the best); and holes under other blocks are evil, and so on. Then put these factors into a formula, with a set of coefficients, one for each of the factors. Now the remaining problem is to find the optimal vector of coefficients.

In order to do that, a training program is needed. I prefer the ‘quick-death’ way to screen out the bad ones as quickly as possible. So I just put it in a server and let it run during the day while I left home to work, and when I came back home at night, I got the result…

Click here to have fun with this Tetris game!

Japanese Calendar

(click on image to use calendar)
(click on image to use calendar)

This is an online Japanese calendar, based on the wonderful online Chinese calendar written by Sean Lin.

This is very handy to check when you don’t have a calendar at hand. I made mistakes like rushing to office and eventually found that I was the only one there because it was a holiday. This calendar can help to prevent this kind of mistakes.

What I did:

  • replaced Chinese holidays with Japanese holidays
  • added the algorithm of calculating ‘furikae kyuujitu’ (振替休日)
  • added calculation of ‘rokuyou’ (六曜)
  • i18n & l10n
  • designed the GUI or the layout as shown in the screen shot.

Check Japanese calendar here.