用PostgreSQL玩国际象棋
背景
PG的玩家有点疯狂。看看PG怎么玩国际象棋吧。
http://pgxn.org/dist/pg2podg/
http://pgxn.org/dist/pgchess/
http://api.pgxn.org/dist/pg2podg/0.1.3/pg2podg-0.1.3.zip
http://api.pgxn.org/dist/pgchess/0.1.7/pgchess-0.1.7.zip
-rwxr-xr-x 1 root root 60K Sep 7 08:33 chess.so
-rw-r--r-- 1 root root 94 Sep 7 08:33 pg2podg.control
-rw-r--r-- 1 root root 21K Sep 7 08:33 pg2podg--0.1.3.sql
-rw-r--r-- 1 root root 131 Sep 7 08:33 pgchess.control
-rw-r--r-- 1 root root 14K Sep 7 08:33 pgchess--0.1.7.sql
postgres=# create extension pgchess;
CREATE EXTENSION
postgres=# \dT
List of data types
Schema | Name | Description
--------+----------+-----------------------------------------------------------------------
public | game | "moves" is encoded via the %% operators, which throughout this file +
| | represent a compact textual encoding of a game or a move. +
| | +
| | "board" could be computed from "moves", but only for standard games +
| | (e.g. not for chess problems). Also, remembering "board" is efficient+
| | and simpler. +
| | +
| | The first 64 characters of "board" represent the chessgame locations;+
| | the next four characters encode castling information, and the last +
| | character is the piece captured in the last move (if any).
public | location |
public | move |
(3 rows)
postgres=# create extension pg2podg;
CREATE EXTENSION
玩法参考
http://api.pgxn.org/src/pgchess/pgchess-0.1.7/doc/pgchess-QUICKSTART.md
游戏在以下目录
pgchess-0.1.7/test/sql/play