ô ăn quan

Có 50 quân dân, và 2 quân quan, mỗi quan tương đương 10 dân. Người chơi có quyền chọn di chuyển theo hướng bất kỳ, những game Mancala khác chỉ được di chuyển theo một chiều nhất định.

Ăn quân ở ô kế tiếp trong lượt đi chứ không phải ở ô đối diện của đối phương. Khi đến lượt mình mà không còn quân để đi thì phải bỏ 5 quân đã ăn được vào 5 ô của mình để tiếp tục chơi. Trường hợp không có đủ 5 quân thì phải vay của đối phương và trả lại khi trò chơi kết thúc.

Trò chơi dân gian Việt Nam Ô ăn quan thuộc họ Mancala, có nguồn gốc châu Phi và có hàng chục biến thể khác nhau trên thế giới. Khi nhỏ, tôi có chơi trò này vài lần, gọi theo tên địa phương là Ô làng chứ không phải Ô ăn quan. Hôm nay thử nhìn cái game này dưới góc độ tin học xem sao! Ô ăn quan có một số luật khác với những game Mancala khác.

Những luật bên, nhất là luật thêm & mượn quân làm Ô ăn quan phức tạp hơn nhiều so với những biến thể Mancala khác. Viết một chương trình cho máy tính chơi Ô ăn quan không phải là quá dễ dàng, dùng những heuristic đơn giản (hill-climbing, min-max, hay brute-force đến một độ sâu nhất định…) không đủ bảo đảm máy tính sẽ thắng trong nhiều trường hợp.

Trên internet, tôi không tìm được game Ô ăn quan nào theo đúng luật Việt Nam. Một số là những biến thể gần giống Ô ăn quan, một số tác giả claim là đã viết Ô ăn quan nhưng không cung cấp được link download. Có vẻ như game này không dể như khi vừa mới nghĩ đến! Bạn nào có ý kiến về chiến thuật chơi game này xin được trao đổi để cùng phát triển một trò chơi hoàn chỉnh.

Bên đây là screenshot của một Java applet tôi vừa viết trong vài tiếng đồng hồ, cho phép 2 người chơi với nhau (máy tính chỉ kiểm luật, chưa phải là một chương trình cho máy tính chơi thực sự). Những hiệu ứng đồ họa: di chuyển quân, ăn quân nhìn rất giống thật, graphics được vẽ bằng Photoshop: những viên sỏi và bàn chơi được vẽ bằng phấn trên mặt sân xi-măng… gợi lại những kỷ niệm thủa nhỏ.

old house

自嘆年來刺骨貧
吾廬今已屬西鄰
殷勤說向園中柳
他日相逢是路人

Ngôi nhà này, tôi chỉ ở thường trực trong thời gian khoảng 3, 4 năm, nhưng trở lại thường xuyên mười mấy năm sau đó. Sơn trắng, ốp gạch đỏ, nền xanh, ngôi nhà thân thương này nay đã thuộc về người khác, giờ thì: tha nhật tương phùng thị lộ nhân – ngày sau gặp lại xem như người qua đường rồi! Những bức hình này (hơi mờ do scan từ ảnh giấy) đều được thực hiện bởi “phó nháy” danh tiếng Hồ Xuân Bổn (chủ tịch hội nhiếp ảnh tp. Đà Nẵng).

for whom the bell tolls

Men of five still alive through the raging glow.
Gone insane from the pain that they surely know.

(Metallica)

Excerpts from the 1943 film following Hemingway’s novel. In some aspects, this is a great film, highly symbolic and dramatical, beautiful staging and casting, but still nowhere closed to the book. So read the book here (zipped text file)! It’s said that Hemingway handpicked the actors and actresses himself for the roles, but he greatly disliked the film due to it’s political content removal.

Excerpt 1: The old guerilla man of El Sordo and his last four men make their last stand on a dead-end hilltop. They’re waiting for their fate to come, and the young Joaquin does the praying when the Russian machine gun barrel turns hot on his shoulder as the planes approach: Holy Mary, Mother of God, pray for us sinners now and at the hour of our death, Amen!.

…Dying was nothing and he had no picture of it nor fear of it in his mind. But living was a field of grain blowing in the wind on the side of a hill. Living was a hawk in the sky. Living was an earthen jar of water in the dust of the threshing with the grain flailed out and the chaff blowing. Living was a horse between your legs and a carbine under one leg and a hill and a valley and a stream with trees along it and the far side of the valley and the hills beyond…

Excerpt 2: Robert Jordan, severely wounded on the way retreat after the mission, says farewell to his lover María. He stays behind to cover the enemy for others to safely escape. The scene removes the detail of Agustín asks if Jordan need a shot or he can manage himself once left behind. Counting the last minutes of his life, in such moment, one can hear the bell tolling for his soul!

Lieutenant Berrendo, watching the trail, came riding up, his thin face serious and grave. His submachine gun lay across his saddle in the crook of his left arm. Robert Jordan lay behind the tree, holding onto himself very carefully and delicately to keep his hands steady. He was waiting until the officer reached the sunlit place where the first trees of the pine forest joined the green slope of the meadow. He could feel his heart beating against the pine needle floor of the forest.

Robert Jordan, as illustrated on this Vietnamese translate book cover, using a Lewis gun, or just called a mácquina as in the book.

songs for free men

…The reasoning behind his persecution centered not only on his beliefs in socialism and friendship with the peoples of the Soviet Union but also his tireless work towards the liberation of the colonial peoples of Africa, the Caribbean and Asia, his support of the International Brigades…

Listening to Paul Robeson’s album: Songs for free men… a very lovely basso profondo concert singer (he was one of the few true basses in American music), performing spirituals. Despite being a very famous and successful singer & performer, the man was kept under strict surveillance by US and UK governments for his international activities in Labor and Anti – Colonialist movements. It’s believed that he was unsuccessfully murdered by the CIA while in Moscow. He is now deserved a position in mainstream history by various posthumous recognitions.

The USSR anthem - Paul Robeson 

In the background video above (1945 victory parade in Moscow), Robeson presents the Soviet Union’s national anthem with a translated English lyric (let read the verses). I think, though it’s a very subjective idea, the song is the best anthem in the world, much more impressive than French’s La Marseillaise. The music’s still used as national anthem in Russia now, with a new lyric.

Don’t know why, but the music reminds me of spaces in the mesmerized text of Ernest Hemingway’s For whom the bell tolls (yet another American activist). As a child, I adored Hemingway’s writing style, and remembered many excerpts from his novel by heart, the spirits of International Brigades! The paragraph quoted on the left had been given a wonderful Vietnamese translation, it describes El Sordo’s final fighting on a hill, his thoughts on life and death, yet another picturesque Song for free men!

minesweeper

Two more hours of work and I’ve added this hexagonal tiles to my MineSweeper! Anyone interested in the game can found the tiny binary and source code (450 LOC) here. Mine sweeping with hexagons is quite a different experience! More about MineSweeper, a simple game?

On the left: Minesweeper with hexagonal tiles

virtualization

MineSweeper running in DOSBox

Click the demo page below (jpcapplet.jar – 1.8 MB in size), it would take some times to load, embedded in it is a DOS image (floppy.img) of a floppy’s size (1.4 MB). In Linux, using dd to create a blank image file, launch JPC app, mount the empty image, fdisk to give it a partition structure, format to give it a bootable FAT12 file system, copy the files over, edit autoexec.bat to have the game run at startup, and voila – there you are, the classic DOS game of MineSweeper on the web!

Beside is screen-shot of my very first programming, the classic MineSweeper, an exercise I did first year at university. After getting started with Borland C++ 3.1, I began to write numerous toys like this; small games, graphics, animation, 3D… are among the things I was very fond of. We still had not had Internet in Vietnam then, lacking of information, we’d reinvented many wheels, including a package for displaying 3D objects (in form of polygon mess), a complete GUI for DOS with window, menu, toolbar, all kinds of controls: combo, list, button… But as they say: don’t reinvent the wheel, unless you plan on learning more about wheels, the reason we did all that fun stuff.

Back to my MineSweeper, it’s tiny, about 350 LOC (Line Of Code), using BGI (Borland Graphics Interface), C/C++ and some ASM. Yesterday, just want to check the old source, but didn’t have a Windows machine at hand, I needed to run the Borland C++ 3.1 compiler on my Linux box. Wine is good for many Windows applications, but it simply won’t work with pure DOS programs. Then I found DOSBox, you start it up in form of a console, mount a directory in local file system, have BC 3.1 installed and compiles flawlessly, and MineSweeper runs well on this virtual DOS on top of Linux!

That’s some layers of virtualization, say I want more, I want to show MineSweeper on the web, but don’t want to make change to the code, or even to the compiled binary. Could it be possible? The answer is: YES! You would need JPC, a pure Java IBM-PC emulator, it runs where there is Java: x86, RISC, mobile phone… On top of it, you can run a bundle of different OS: DOS, Linux, Windows… Then comes the delicate distinction between virtualization and emulation, hardwares, softwares, all can be virtualized to some great extent. Imagine you would run some games & utilities on a virtual DOS (or Linux) running inside JPC, hosted in Firefox browser, which in turn runs on Windows (or Linux)!

JPC can only bring about 20% power of the native machine, and even a tiny game like this is overkill to it, and mouse functioning is really crappy too. But that’s suffice to demonstrate the idea, JPC could be improved I believe. More games would be added to this Web DOS console later on! Anyone still remember Tetris, Croix-Zero, Snake, Mario…? So, what’s the points for JPC? Demonstrating the fractal principles in hardware, software evolution? Too much “nostalgia” for the “good old days” – DOS games? Anything else or just reinventing the wheel? The answer may be so, but I love this idea of cultivating the past, and pop out new things for the future!