« May 2007 | Main | July 2007 »

June 24, 2007

Reading, 乱, and Rostropovich

Technorati Tags:

June 19, 2007

Shogi Game Collection Analysis

This Shogi game analysis uses Eric’s games collection, last updated 2006-07-16. The Portable Shogi Notation (PSN) files were converted into a PostgreSQL database using psn-util. SQL then used to analyze the moves. For reference:

Side NameChess EquivalentKing
先手 [せんて: Sente]White
後手 [ごて: Gote]Black

Sente and Gote used hereafter to denote the sides, as other documentation I’ve found uses Black and White as in Chess, but with Black going first.

Technorati Tags:

Wins versus losses shows Sente racking up only 52% of the wins. Draws also rare, unlike Chess, where White enjoys a larger advantage, and draws very common at high levels of play. Shogi games last longer then Chess games, averaging 103 moves with a standard deviation of 30 (weighted lower by a fair number of 30 or 40 move example games).

Brief Opening Analysis

Most Shogi games begin with 1. P7f, opening a line for the Bishop (77% of the 3078 games). Exchanging Bishops is not common, Sente instead favoring pawn development in 87% of moves where Gote exposes the Bishops with P3d. The second most popular opening 1. P2f again favors pawn moves to open the Bishop or advance the Rook pawn.

1. ... 1. P7f ... P3d 2. ... ========== ========== ========== P3f 1 P2d 1 G6h 1 P4f 1 R5b 2 K6h 1 P9f 1 S6b 6 P8f 1 S4h 2 G3b 8 R5h 1 G7h 3 P5d 14 R7h 1 P6f 3 P8d 929 G45h 4 P1f 5 P3d 1426 R6h 5 R5h 9 P5f 13 P5f 13 G7h 16 P2f 626 1. P2f ... P9f 17 P7f 2386 ========== P1f 21 S6b 1 P7e 31 R5b 2 S4h 31 G3b 3 Bx2b+ 40 P8d 281 P6f 429 P3d 339 P2f 814

Additional Work

Need to improve on analysis of certain moves (popularity of various castles) or following game trees. Notation syntax not reversible like the Concise Reversible Algebraic Notation (CRAN) for Chess is. This makes analysis by computer more difficult, especially where the relative xS move listed. xS requires that the positions of all Silver general to be known at the time of the move: obvious to a human looking at a board, difficult for a computer dealing with 19.xR Nx4e 20.xN xR 21.R2a+ P*4g 22.xS P*4f.

Also would like to code a web or other easy interface to the games, and flip between random SQL queries and a game board. Maybe something via GNU Shogi or similar engine, to avoid coding the board and rules myself?

June 16, 2007

Knight

A chess Knight, thanks to a Lensbabies lens with macro additions.

Chess Knight

Technorati Tags:

June 09, 2007

map for x

In Perl, the map function can simplify the code required to SQL quote a string:

#!/usr/bin/perl -w use strict; #use Data::Dumper; my @list = ( qw{abe baker}, "can't" ); my $result = sqlify_with_map( \@list ); #print Dumper \@list; print $result, "\n"; $result = sqlify_with_for( \@list ); #print Dumper \@list; print $result, "\n"; sub sqlify_with_for { my $list_ref = shift; my $result; for my $i ( 0 .. $#$list_ref ) { my $item = $list_ref->[$i]; $item =~ s/'/\\'/g; $result .= "'$item'"; if ( $i != $#$list_ref ) { $result .= ','; } } return $result; } sub sqlify_with_map { my $list_ref = shift; return join ',', map { my $item = $_; $item =~ s/'/\\'/g; "'$item'"; } @$list_ref; }

The $item variable in both cases avoids modification of the original list elements. The map allows the escaped and quoted items to be passed as a list to join, while the for loop requires more code to decide when not to add a joining comma (leading to many false checks in a loop, which is usually not a Good Thing). Another option: always add a comma, then strip off the final comma after the for loop. But why bother, with map available?

Technorati Tags: ,

SQL placeholders for DBI are another solution, though with a list of variable size, a corresponding number of ? must be listed in the prepared statement. Here, the x operator makes the most sense:

my $sth = $dbh->prepare( $prefix . join( ',', ('?') x @list ) . $suffix ); my $rv = $sth->execute(@list);

June 05, 2007

Shogi Stuff

A chess board for Shogi players. Or to confuse people trying to follow your chess games. The Queen has no equivalent in Shogi, so hopefully 妃 suffices. In chess, color differentiates the Kings, though I retained the 玉 abbreviation for the black king. Unlike chess, black moves first.

Chess-like Shogi pieces to print and use on a chess board. These use the Shogi piece outline, so one knows which side the piece belongs to without coloring.

And finally, a Shogi game move marker, for highly asynchronous games. Fold down center line and staple together edges.

Also consider a rescue vehicle for wounded kings.

Technorati Tags:

June 01, 2007

Bike to Work

Participated in Bike to Work month for the first time. Definite changes due to biking most days of the week, rather than just two or three days: no bus time to read, though biking to work faster than bussing. Biking to work good, as the ride wakes me up, though biking home much harder (perhaps need to snack more in the afternoon, or use a longer route that avoids the initial uphill climb through downtown Seattle). However, energy spent (plus biking out to Ballard for rock climbing) makes me less liable to do housework. A cleaning service and a dishwasher could help there. Need gloves with thick padding, as road bike none too kind on the wrists. A recliner bike may be in order for later years, or commuter bike that keeps weight off the arms.

Downtown Seattle is a toxic wasteland: too many vehicles, too much noise, and a bad stench most days of the week. Anecdotal evidence (myself) links increased biking to increased sneezing, either due to allergy triggering Diesel particles, or perhaps something else. The Winter rains help keep pollution down and pavement dust to a minimum, but these largely vanish during the summer months in Seattle.

In related news:

Technorati Tags: