Recently in 今日新发现 Category

Rules[1]

  • Board - The board is an 8×8 grid, with alternating black and red squares, called a checkerboard (in the U.S., in reference to its checkered pattern, also the source of the name checkers). The playable surface consists of the 32 dark squares only. A consequence of this is that, from each player's perspective, the left and right corners encourage different strategies.
  • Pieces - The pieces are usually made of wood and are flat and cylindrical. They are invariably split into one darker and one lighter color. Traditionally, these colors are red and white. There are two kinds of pieces: "men" and "kings". Kings are differentiated as consisting of two normal pieces of the same color, stacked one on top of the other. Often indentations are added to the pieces to aid stacking.
  • Starting Position - Each player starts with 12 pieces on the three rows closest to their own side, as shown in the diagram. The row closest to each player is called the "crownhead" or "kings row". The black (darker color) side moves first.
  • How to Move - There are two ways to move a piece: simply sliding a piece diagonally forwards (also diagonally backwards in the case of kings) to an adjacent and unoccupied dark square, or "jumping" one of the opponent's pieces. In this case, one piece "jumps over" the other, provided there is a vacant square on the opposite side for it to land on. Again, a man (uncrowned piece) can only jump diagonally forwards, and a king can also move diagonally backwards. A piece that is jumped is captured and removed from the board. Multiple-jump moves are possible if, when the jumping piece lands, there is another piece that can be jumped. Jumping is mandatory and cannot be passed up to make a non-jumping move, nor can fewer than the maximum jumps possible be taken in a multiple-jump move. When there is more than one way for a player to jump, one may choose which sequence to make, not necessarily the sequence that will result in the most amount of captures. However, one must make all the captures in that sequence. (Under traditional draughts rules jumping is not mandatory. If it is not done, the opponent may either force the move to be reversed, huff the piece or carry on regardless.)
  • Kings - If a player's piece moves into the kings row on the opposing player's side of the board, that piece is said to be "crowned" (or often "kinged" in the U.S.), becoming a "king" and gaining the ability to move both forwards and backwards. If a player's piece jumps into the kings row, the current move terminates; having just been crowned, the piece cannot continue on by jumping back out (as in a multiple jump), until the next move.
  • How the Game Ends - A player wins by capturing all of the opposing player's pieces, or by leaving the opposing player with no legal moves.

Compiling

Run command "make" to compiling. The main executable file is "ponder".

Playing

The below chart show the user interface of the Ponder engine. This is the official game board of American checkers game, 8x8 size. The squares are marked from "1" to "32" at the lower left.

$ ponder
  +---+---+---+---+---+---+---+---+
  |   |(w)|   |(w)|   |(w)|   |(w)|
  +---+32-+---+31-+---+30-+---+29-+
  |(w)|   |(w)|   |(w)|   |(w)|   |
  +28-+---+27-+---+26-+---+25-+---+
  |   |(w)|   |(w)|   |(w)|   |(w)|
  +---+24-+---+23-+---+22-+---+21-+
  | \ |   | \ |   | \ |   | \ |   |
  +20-+---+19-+---+18-+---+17-+---+
  |   | \ |   | \ |   | \ |   | \ |
  +---+16-+---+15-+---+14-+---+13-+
  |(b)|   |(b)|   |(b)|   |(b)|   |
  +12-+---+11-+---+10-+---+9--+---+
  |   |(b)|   |(b)|   |(b)|   |(b)|
  +---+8--+---+7--+---+6--+---+5--+
  |(b)|   |(b)|   |(b)|   |(b)|   |
  +4--+---+3--+---+2--+---+1--+---+
;[FEN "B:W21,22,23,24,25,26,27,28,29,30,31,32:B1,2,3,4,5,6,7,8,9,10,11,12"]
  *** Black ***
  • (b) indecate a black man
  • (B) indicate a black king
  • (w) indicate a white man
  • (W) indicate a white king
  •  \  indicate an unoccupied dark square

Move a piece by type the starting square and the destination square with a dash between them.

;[FEN "B:W21,22,23,24,25,26,27,28,29,30,31,32:B1,2,3,4,5,6,7,8,9,10,11,12"]
+---+---+---+---+---+---+---+---+
| |(w)| |(w)| |(w)| |(w)|
+---+32-+---+31-+---+30-+---+29-+
|(w)| |(w)| |(w)| |(w)| |
+28-+---+27-+---+26-+---+25-+---+
| |(w)| |(w)| |(w)| |(w)|
+---+24-+---+23-+---+22-+---+21-+
| \ | | \ | | \ | | \ | |
+20-+---+19-+---+18-+---+17-+---+
| | \ | | \ | | \ | | \ |
+---+16-+---+15-+---+14-+---+13-+
|(b)| |(b)| |(b)| |(b)| |
+12-+---+11-+---+10-+---+9--+---+
| |(b)| |(b)| |(b)| |(b)|
+---+8--+---+7--+---+6--+---+5--+
|(b)| |(b)| |(b)| |(b)| |
+4--+---+3--+---+2--+---+1--+---+
*** Black ***
10-14
;[FEN "W:W21,22,23,24,25,26,27,28,29,30,31,32:B1,2,3,4,5,6,7,8,9,11,12,14"]
+---+---+---+---+---+---+---+---+
| |(w)| |(w)| |(w)| |(w)|
+---+32-+---+31-+---+30-+---+29-+
|(w)| |(w)| |(w)| |(w)| |
+28-+---+27-+---+26-+---+25-+---+
| |(w)| |(w)| |(w)| |(w)|
+---+24-+---+23-+---+22-+---+21-+
| \ | | \ | | \ | | \ | |
+20-+---+19-+---+18-+---+17-+---+
| | \ | | \ | |(b)| | \ |
+---+16-+---+15-+---+14-+---+13-+
|(b)| |(b)| | \ | |(b)| |
+12-+---+11-+---+10-+---+9--+---+
| |(b)| |(b)| |(b)| |(b)|
+---+8--+---+7--+---+6--+---+5--+
|(b)| |(b)| |(b)| |(b)| |
+4--+---+3--+---+2--+---+1--+---+

While capture a piece, use character "x" instead of dash.

;[FEN "B:W15,21,22,24,25,26,27,28,29,30,31,32:B1,2,3,4,5,6,8,9,10,11,12,14"]
+---+---+---+---+---+---+---+---+
| |(w)| |(w)| |(w)| |(w)|
+---+32-+---+31-+---+30-+---+29-+
|(w)| |(w)| |(w)| |(w)| |
+28-+---+27-+---+26-+---+25-+---+
| |(w)| | \ | |(w)| |(w)|
+---+24-+---+23-+---+22-+---+21-+
| \ | | \ | | \ | | \ | |
+20-+---+19-+---+18-+---+17-+---+
| | \ | |(w)| |(b)| | \ |
+---+16-+---+15-+---+14-+---+13-+
|(b)| |(b)| |(b)| |(b)| |
+12-+---+11-+---+10-+---+9--+---+
| |(b)| | \ | |(b)| |(b)|
+---+8--+---+7--+---+6--+---+5--+
|(b)| |(b)| |(b)| |(b)| |
+4--+---+3--+---+2--+---+1--+---+
*** Black ***
11x18
;[FEN "W:W21,22,24,25,26,27,28,29,30,31,32:B1,2,3,4,5,6,8,9,10,12,14,18"]
+---+---+---+---+---+---+---+---+
| |(w)| |(w)| |(w)| |(w)|
+---+32-+---+31-+---+30-+---+29-+
|(w)| |(w)| |(w)| |(w)| |
+28-+---+27-+---+26-+---+25-+---+
| |(w)| | \ | |(w)| |(w)|
+---+24-+---+23-+---+22-+---+21-+
| \ | | \ | |(b)| | \ | |
+20-+---+19-+---+18-+---+17-+---+
| | \ | | \ | |(b)| | \ |
+---+16-+---+15-+---+14-+---+13-+
|(b)| | \ | |(b)| |(b)| |
+12-+---+11-+---+10-+---+9--+---+
| |(b)| | \ | |(b)| |(b)|
+---+8--+---+7--+---+6--+---+5--+
|(b)| |(b)| |(b)| |(b)| |
+4--+---+3--+---+2--+---+1--+---+

Use "help" or "?" in the game engine to show the help information.

help
? Show this help information.
analyze Engine thinks about what move it make next if it were on
move.
black Set Black on move, and the engine will play White.
force Set the engine to play neither color ("force mode").
go Leave force mode and set the engine to play the color that
is on move. Start thinking and eventually make a move.
help Show this help information.
history Show the record of moves.
new Reset the board to the standard starting position.
ping N N is a decimal number. Reply by sending the string
"pong N"
print Show the current board.
quit Quit this program.
rotate Rotate the board 180 degrees.
setboard FEN Set up the pieces position on the board.
sd DEPTH The engine should limit its thinking to DEPTH ply.
st TIME Set the time control to TIME seconds per move.
undo Back up a move.
verbose Toggle verbose mode.
white Set White on move, and the engine will play Black.

Source Code

You can download the source code of Ponder, the American checkers engine from Mamiyami Web site.

Copyrights

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

狂写 bash 脚本数日,偶有所得。

Usually, we use [ -n "$VAR" ] to check if a shell variable contain non null string. But bash man page does not describe how to check if a shell variable is set or not.

After some search and investigation, I got the following missing bash manual

Parameter Expansion

${parameter-word}
Use Default Values. If parameter is unset, the expansion of word
 is substituted. Otherwise, the value of parameter is substituted.
${parameter=word}
Assign Default Values. If parameter is unset, the expansion of
 word is assigned to parameter. The value of parameter is then
 substituted. Positional parameters and special parameters may not
 be assigned to in this way.
${parameter?word}
Display Error if Unset. If parameter is unset, the expansion of
 word (or a message to that effect if word is not present) is
 written to the standard error and the shell, if it is not
 interactive, exits. Otherwise, the value of parameter is
 substituted.
${parameter+word}
Use Alternate Value. If parameter is unset, nothing is
 substituted, otherwise the expansion of word is substituted.

Some section in bash man page for reference

${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion
 of word is substituted. Otherwise, the value of parameter is
 substituted.
${parameter:=word}
Assign Default Values. If parameter is unset or null, the
 expansion of word is assigned to parameter. The value of
 parameter is then substituted. Positional parameters and special
 parameters may not be assigned to in this way.
${parameter:?word}
Display Error if Null or Unset. If parameter is null or unset,
 the expansion of word (or a message to that effect if word is not
 present) is written to the standard error and the shell, if it is
 not interactive, exits. Otherwise, the value of parameter is
 substituted.
${parameter:+word}
Use Alternate Value. If parameter is null or unset, nothing is
 substituted, otherwise the expansion of word is substituted.

Here are some examples

[ -n "${VAR+x}" ]  ## Fails if VAR is unset
[ -n "${VAR:+x}" ] ## Fails if VAR is unset or empty
[ -n "${VAR}" ]    ## Fails if VAR is unset or empty
[ -n "${VAR-x}" ]  ## Succeeds if VAR is unset
[ -n "${VAR:-x}" ] ## Succeeds if VAR is unset or empty
[ -z "${VAR}" ]    ## Succeeds if VAR is unset or empty

北纬40度地标

| | Comments (1) | TrackBacks (0)

位于北京植物园内的北纬40度地标。

img_2880s.jpg

39°59.985'N, 116°12.138'E

参考资料

蝈蝈死掉了

| | Comments (1) | TrackBacks (0)

蝈蝈死掉了。一共养了一百八十六天。

***** 552 ** pts/1 * <neo@zircon> *** ~ *****
$ echo $(( ( $(date -d 'Jul 23, 2008' +%s) \
> - $(date -d 'Jan 19, 2008' +%s) ) \
> / 86400 ))
186

今天在厨房中橱柜的角落里发现了某种未知昆虫的幼虫......吓,好可怕。

白色的幼虫,约有两三毫米长短。在橱柜上面爬来爬去,行进速度约有每秒五毫米左右,一波一波地向前蠕动。
Canon EOS 400D + Zeiss 50mm F1.4 + Kenko Extension Tube (24mm + 36mm)
ISO400 50mm F1.4 1/40s
img_2256a.jpg

淡褐色的卵?茧?身形较幼虫短小且胖,约一粒芝麻般大小。
Canon EOS 400D + Zeiss 50mm F1.4 + Kenko Extension Tube (24mm + 36mm)
ISO400 50mm F1.4 1/30s
img_2262b.jpg

为了彻底的无害化处理,决定一个一个抓起来放在汽水罐中焚毁。收集了好多好多...... -_-|||
Canon EOS 400D + Zeiss 50mm F1.4
ISO400 50mm F4 1/200s
img_2274a.jpg

虫子浸在二锅头酒中安静的燃烧,升起淡橙色的火焰,间或发出轻微的噼啪声。
Canon EOS 400D + Zeiss 50mm F1.4
ISO400 50mm F4 1/200s
img_2281a.jpg

用做燃料的红星牌五十六度二锅头酒,清澈透明,气味香馥、醇厚甘冽、清香纯正、回味悠长。
Canon EOS 400D + Zeiss 50mm F1.4
ISO400 50mm F2.8 1/100s
img_2285a.jpg

这个东东实在是太惊人了。它让你在赶往公司的途中,出租车上,火车上,都可以维护自己的服务器,随时随地 SSH 一下。

完整的规格包括支持 SSH1/SSH2/Telnet 协议,可以通过手机键盘输入各种特殊键和组合键,可以移动光标,VT320 终端模拟。这整个软件还是开放源代码并且使用 GPL 协议发布。

说到缺点,手机屏幕上的字实在是太......太小了。当然可以把字体变大,不过这样的话,屏幕上显示的内容就会相应的变少了。通过手机键盘输入命令也非常......非常的让人抓狂,尤其是要输入各种奇怪的标点符号的时候。不过这毕竟是全功能的 SSH 客户端,不佩服一下作者也不行。

详情就请大家自己看图好了,点击看大图。在 Nokia 6275 CDMA 的 QVGA 屏幕上竟然可以显示 80 列 40 行字符呢,真是让人绝倒。

img_1522s.jpg

img_1517s.jpg

全国哀悼日

| | Comments (0) | TrackBacks (0)

全国哀悼日,决定把 Weblog 变成黑色。

2008年5月12日14时28分 让我们永远铭记这一刻,愿逝者安息,生者坚强

使用 vim scp://remoteuser@server.tld//path/to/document 运行 vim。或者在 vim 运行时输入 :e scp://remoteuser@server.tld//path/to/document

Vim 支持通过 dav、fetch、ftp、http、rcp、rsync、scp 或者 sftp 编辑远程文件。

在 Windows 上面使用 gVim

  1. 下载及安装 gVim
  2. 下载及安装 PuTTY
  3. %ProgramFiles%\PuTTY 加入 PATH
  4. 创建 %ProgramFiles%\PuTTY\scp.bat
    @echo off
    pscp.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

参考资料

北京动物园是个吃喝玩乐的好地方。可以看粉颜色的河马,可以吃棉花糖,还可以和一人多高的熊猫布偶拍合影纪念照。

附上泥偶自制 Google Earth XML 文件和去年拍的片片

冬虫儿

| | Comments (2) | TrackBacks (0)

新败了一只蝈蝈。闲话少叙,没图没真相......

img_0861s.jpg

img_0865s.jpg

img_0869s.jpg

About this Archive

This page is a archive of recent entries in the 今日新发现 category.

摄影败家 is the previous category.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.12