Friday, December 28, 2007

Safari in iPhone

The bigtext version of EGDB query system is usable now over Safari for iPhone. Some improvements are wanted. However, it is usable for now.

Thursday, December 27, 2007

3G iPhone

iPhone? What is the relationship between EGDB and iPhone? Since the day I had EGDB posted on the net, I always want to be able to access EGDB anywhere I want, which could be the park people playing Chinese chess. I have a Palm Treo 650 connecting to a 3G phone just to do that (among other things). Being able to connect to internet anywhere has a special appeal to me for a long time. The Treo interface is not so great when compared to iPhone. What if I can have a iPhone with 3G connection? It will be great. I didn't know a way to achieve that until one day I saw the following article:

It described exactly what I want before Apple starts to sell 3G iPhone. Immediately, I tried out the idea in Apple store and prove it works as expect. I then bought a iPhone, and a XDA O2 atom as my 3G/3.5G modem. The combination works wonderfully. Now I can access my EGDB anywhere I want with good speed and good interface as long as there is 3G service available, which is pretty ubiquitous here.

I am pretty happy to have the combination. Saying that, there are still some rooms for improvement.

1. Of course, if there is true 3G/3.5G iPhone then I don't have to carry another phone as modem, it will be much better. For this, we have to wait for Apple.

2. XDA O2 atom runs out of battery really fast when both data connection and WiFi are on.

3. Safari refuses to run my big text interface as I intend it to be and no Java is available for it. I now stick to small text interface. Let me see if I can fix big text version from my cgi script.

If you also use iPhone to access EGDB, welcome you to leave your comments here.

Saturday, December 8, 2007

A bug or not?

In the previous post, Michael mentioned in the comment stating the EGDB is good except a bug related to indefinite checking and chasing. I will take this chance to explain the situation. Chinese chess is different from western chess in interpreting indefinite checking/chasing. In western chess, three-fold repetitions lead to a draw. However, the win/draw/loss condition is depending on the context of checking/chasing in Chinese chess. The best solution I can come up so far is to treat indefinite checking/chasing as seed positions with win/draw/loss status based on Asian rules. Retrograde analysis was then used from this point on. This method lead to some problems (or bugs in some people's mind). First of all, distance to mate is hard to define if indefinite checking/chasing is involved. How many moves will you count when the losing side repetitive checks several times then moves to an inferior position? Since I could not solve this problem, I define the indefinite checking/chasing positions as seed positions with order. They are treated as final positions if the losing side refuses to change the pattern and is declared loss. In this case, this is the terminal node. However, if the losing side finally decide to move to inferior position with lesser order, there are more moves to be played. Take the first position raised by Michael as example, 硨七進三 keeps the following positions in the order 0. By keeping the positions in order 0, final win is ensured with certain depth. However, 硨七進二 will force positions to order 1, then drop back to order 0. We don't know for sure it is a longer sequence or shorter one. My current strategy is to keep it in lower order. As for the second position, moving red pawn left and right will force black knight to indefinitely chasing, so it has to move out of pattern or lose immediately. However, keep moving red pawn left will also force black knight to break out chasing pattern. These are two different ways to win. I propose a way for sure win. However, it may not be the shortest win due to the indefinite checking/chasing condition. To some people, it is not "perfect" in the sense it is not aesthetic to their point of view. To me, it is a practical way to solve indefinite checking/chasing situation with perfect win/draw/loss information. I don't have better solution so far. Is it a bug? To me, it is just a practical solution given the problem set. It's not a bug to me. :-)

Thursday, December 6, 2007

马兵残局 -- 马底兵能否必胜单士象?

马兵残局 is a interesting and difficult endgame. 马底兵vs单士象 is especially interesting. It was said to be a win pattern in some places, and draw pattern in other places. If you look 马兵残局 up at 东萍棋谱仓库, you will see 5 positions are said to be draw. These positions are copied from endgame book. However, if you look up these positions from EGDB, you will see they are all win positions. According to the statistics page of EGDB, 马兵vs单士象 is win for red, even it is 马底兵vs单士象. The following links are some posts pertain to this topic.

Here is another link that concludes knight-bottom pawn side will win.

Sunday, December 2, 2007

The endgame play in Movesky

I was fortunate to meet the author of 东萍棋谱仓库 over MSN last night. He offered me a VIP account in his database. I finally can check the so called 顶尖对局 in the database. The games are played in the highest level of Movesky with 30-minutes time control. I have checked with some endgame play to see in this over-the-board plays, how often do these top players, some with computer assistance, miss the winning or drawing move?

In the case of knpkpbb endgame, there are 12 incidents in the 顶尖对局 database. There are 3 wins and 3 draws hold, which means the outcome of the games matches the calculation of EGDB. In other word, the players didn't make blunder. In other 6 games, there are 5 missed win and 1 missed draw, which means the moving side missed the chance to win or to draw. These are 50% of improving space. I wonder if people study EGDB more, these kind of misses will be reduced.

With the method I mention in the previous post, this kind of survey became relative easy. If you find this to be useful, you may want to consider registering a VIP account from 东萍棋谱仓库.

Tuesday, November 27, 2007

UBB interface in 东萍棋谱仓库

This thread contains a long discussion of rook-cannon endgame. I think it is interesting. The main author uses UBB interface, which has become very popular Chinese chess board presentation in forum discussion. It was developed mainly to aid the Chinese chess databases hold in 东萍棋谱仓库.

There are a couple of functions in the UBB interface interest me a lot. First of all, this interface has a button link directly to the Chinese chess endgame databases query system. If the board position is available in my databases, it will automatically generate a page with the query string. That is a very neat feature. So far, it works well except the position sequence with black to move first. I have been trying to contact the author of UBB to fix it without success. If you know the author, maybe you can tell him/her to contact me by email.

To link to EGDB, click on right lower corner 棋谱搜索 button, then click on 搜索当前残局解法. It will bring you to the right page. Sometimes, it will be in background window, so look for which window it brings the page up.

Another way to use this UBB interface is to arrange piece on the board and then look for the position in EGDB so you don't have to input fen string yourself. You can also copy fen string from other program and look up the position in EGDB. To use it, click on 导出导入 button. For endgame, click on 清空棋盘 then move the piece to your intended position. Look for more pieces on 添加棋子. After you are done with arrangement, click on 将左侧局面设为开始. After this step, follow the method in previous paragraph to find the corresponding EGDB position. In the same 导出导入 screen, you can find way to paste in fen string.

There are many preset positions copied from ancient books that you may find interesting. If you like the service there, you can show your support by registering as higher-class user.

Have fun!

Monday, November 26, 2007

Western chess endgame website

There is a very good western chess endgame databases query website available here:

If you are capable of writing this kind of utility, I will be happy to hear from you so we can also have this nice interface available.

Sunday, November 25, 2007

Original poem

I feel the title of previous post is very suitable for endgame databases, so I spend some time to do a google search. Here is the whole poem.




Wednesday, November 21, 2007

獨翻舊局辨錯著 冷笑古人心許誰

Accidentally, I found a article in 【PChome電腦家庭雜誌】which introduce Chinese Chess Endgame Databases Query System. There is explanation in Chinese chess move notation. Should be a good read.


Long ago, meifire wrote a article called 神機妙算 in 東萍象棋網絡雜誌第八期, where he introduced me and the inception of EGDB. It should be a interesting read if you are interested in EGDB.

Monday, November 19, 2007

Total endgames as of today (2007/11/19)

I have completed this stage of server update. As of today, there are total 1,334 endgame databases available. Currently, it is filling up my third hard disk and growing. More and more, it is harder to add new endgame databases as each one that has not been done is rather big and will take long time to construct. While I am building more that I think are more interesting, I always welcome the suggestions. If you see some endgame missing that you really want to see, please leave a comment here. You will see it sooner. Please limit total attacking pieces under four.

Updated databases

I have been building new databases since 2003. The indefinite chasing bug was fixed later so all the databases were re-constructed with new algorithm. Since then, new databases were added periodically. Due to the expansion of databases, my server can no longer host the full set of databases as it only has two USB ports for my USB hard disks. Recently, I obtained a old PC that has 6 usable USB ports, so I have put all the databases I have so far into the server. If you check the database list and look for the built date. Anything built in 2007 should be the new addition. There are some databases having quite long line. Here are some examples:

Thank cck for Java Chessboard

krcbkree 硨炮仕--車象象 175

Thank cck for Java Chessboard

You can look for more examples. Enjoy!

Friday, November 16, 2007


For people who wonder why the "" domain name, here is the explanation.

The Chinese Endgame Databases Project started when I wanted to write a Chinese chess program to beat some of my friends. Naturally, I use my most proficient programming language "Forth" to write the program. Forth is a peculiar language that some people just grow inert in using it after they obtain the ability. I am one of them. Over the years, I even wrote a couple of compilers for it. One runs under Linux environment (lpforth), the other runs under Palm OS (ppforth). lpforth actually stands for "Linux pForth", and not something else. ppforth stands for "Palm pForth". When I first had my EGDB server running, I had an IP address as web address. One of the Forthers, Lothar Schmidt, saw it and provided me with "" domain name free of charge. My thanks to Mr. Schmidt.


Four posts down and I have not listed the link to the content page. Here it is:

This link should also present in my profile. There are traditional Chinese version as well as English version. I figure the people who can read simplified Chinese should also be able to read traditional Chinese. As for English reader, the Chinese name for the pieces should not be the problem. If there is one, I welcome you post comment or leave me email.

EGDB and Engine

An interesting discussion in AI-Master regarding endgame use in Chinese chess engine.

Some history regarding indefinite chasing

When I first have EGDB available over internet, I was not sure if it was correct. I basically followed Haw-ren Fang's paper (Haw-ren Fang, Tsan-sheng Hsu and Shun-chin Hsu. "Indefinite Sequence of Moves in Chinese Chess Endgames", Proc. 3rd International Conference on Computers and Games (CG), to appear in a Springer-Verlag LNCS volume, 2002.) and hoped it would be correct. I didn't know if anyone will actually look into the databases. I was surprised to find out "meifire" asked in AI-Master forum if my server was still up while it was temperately off-line. He later found mistakes in positions pertain to indefinite chasing. He even went into length in explaining how to view Asian rules in a simplified way, which prompt me to modify the code so it could generate correct databases. I constructed all the EGDB again with the new algorithm and posted the databases again. This time, meifire didn't find indefinite chasing error until one day he raised a position here.

Thank cck for Java Chessboard

Click here to see the position in EGDB.

It lead to a interesting discussion and an unexpected conclusion. I thought it is a significant history of EGDB. :-)

Initial plan for this blog

Ok! The first blog post went smoothly, so I can safely write more now. My plan for this blog is to add some quick and current informations relevant to the Chinese Chess Endgame Databases (EGDB). Examples are:

1. announcing the newly constructed endgame databases
2. posting links to discussions that are related to EGDB
3. posting interesting positions that EGDB plays interesting role
4. random thoughts on EGDB
5. any things pertain to EGDB
6. some thoughts on Chinese chess programming

In the meantime, I welcome anyone adding any kind of comments related or not related to EGDB.

The plan may morph any time. The goal is for everyone to enjoy this space.

Blog opening

I have set up this blog to add some current informations regarding the Chinese Chess Endgame Databases. I have plan to upgrade the server recently. Hopefully, some bigger databases that I have can now be also available to everyone through cgi interface.