agt-the-walker / shogi-utils

Small utilities to download games from 81Dojo and generate Shogi22680 positions. Rambling about Shogi variants

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

Table of contents

Utilities

fetch-81dojo-games

This program fetches all 81Dojo games played by you.

Requirements

Usage

Please run the following command the first time:

# replace "Agt" and "hidden" below with your 81Dojo credentials
$ echo 'machine system.81dojo.com login Agt password hidden' >>~/.netrc

Then:

$ mkdir -p ~/81Dojo  # adapt accordingly

$ ./fetch-81dojo-games ~/81Dojo
Searching all games
Limit reached. Also searching games until 2018-04-22
Saving game 2692582
[...]
Saving game 3447638

$ ./fetch-81dojo-games ~/81Dojo
No game since last run

# after playing a few games
$ ./fetch-81dojo-games ~/81Dojo
Searching all games
Saving game 3450595
Saving game 3451125

$ ls ~/81Dojo
2692582.json
[...]
3451125.json

Notes

Some information is stored in ~/.fetch-81dojo-games.cfg to prevent unnecessary searches, especially considering they do cost D-Miles.

shuffle-first-row

This program prints Shogi22680 positions with optional restrictions. K = King, N = Knight, etc.

Requirements

Usage

$ cd ~/src/git/shogi-utils  # adapt accordingly

$ make

$ ./shuffle-first-row --help
[shows usage]

$ ./shuffle-first-row | wc -l
22680  # not surprisingly

# restriction: protect all squares on second row
$ ./shuffle-first-row --protect | wc -l
15750

# restriction: do the same without the help of the king
$ ./shuffle-first-row --protect-more | wc -l
8262

# additional restriction: don't put a lance behind pawns most likely
#  to be pushed during sente's first move
$ ./shuffle-first-row --protect-more | grep '^..[^L].[^L]..[^L].' | wc -l
3798

# the second position is the standard Shogi starting one
$ ./shuffle-first-row --protect | grep SGKGS
LLNSGKGSN
LNSGKGSNL
NSGKGSNLL

# shows a few Shogi22680 positions not listed with --protect
$ diff <(./shuffle-first-row) <(./shuffle-first-row --protect) | \
  grep '^<' | cut -c3- | shuf -n 3
SGGLKLSNN  # last square of second row is unprotected
NLSLGKGSN  # first square of second row is unprotected
SLLNNGSGK  # fourth square of second row is unprotected

# shows a few Shogi22680 positions not listed with --protect-more
$ diff <(./shuffle-first-row --protect) \
       <(./shuffle-first-row --protect-more) | \
  grep '^<' | cut -c3- | shuf -n 3
KNSGLLSNG  # first square of second row is only protected by the king
LKLSSGNNG  # second square of second row is only protected by the king
NKLNSGSGL  # first two squares of second row are only protected by the king

Credits

On Shogi variants

Article

I like Shogi, but I also like other abstracts such as Arimaa and especially Capablanca Random Chess, since I hate studying openings. For this reason, I'd like to try Shogi22680 (see above), but I'm also interested in other board sizes and pieces.

IMHO, a good Shogi variant:

  1. shouldn't be more drawish than Chess
  2. shouldn't give the first player an advantage greater than in Chess
  3. shouldn't require studying opening theory (principles are fine though)
  4. shouldn't last more than twice as long as the average Chess game (in plies)
  5. shouldn't be more difficult to learn than Wa Shogi

Any reasonable Shogi variant with drops shouldn't be near as drawish as Chess. I propose to use the Pie rule to address the second point, since randomizing the starting position (third point) will probably give the first player a greater than usual advantage in some cases. For the rest, Chu Shogi (and larger board variants) probably takes too long and is also too difficult to learn.

Let's get back to opening theory. If at the start of a game, each starting position has 1% (or less) chance of occurring, then we have probably succeeded in rendering its study pointless. Shogi22680 is an obvious possibility, but there are others. For instance, swapping the positions of only three pieces in the first row produces 145 different starting positions (111 with all squares on second row protected), which is acceptable.

What if we only swap two pieces in the first row? In this case, we only have 33 different starting positions, which is not enough. However if we also replace a random piece in the first row (except the king, obviously) by a random one introduced in Okisaki Shogi, then we get 33 * 8 * 3 = 792 different starting positions.

Using new pieces is not without consequences. Indeed how many points do they score as far as the Jishogi rule is concerned? Therefore this rule should probably be replaced by the Try Rule, where another way to win would be to bring one's king to the original square of the opponent's king (if this square is not controlled by enemy pieces).

Moreover we could keep the standard starting position but choose N random pieces (including pawns, excluding king, rook or bishop) which will promote differently. For instance, with N=2, assuming they promote to different pieces (like Chess queen and Chess knight instead of Shogi gold), we get 17 * 16 = 272 "different" starting positions (264 if we want to ensure that at least one piece of each type promotes as usual).

Finally we could choose a random piece in the first row (except the king, obviously) which will become a random one introduced in Wa Shogi the first time it is captured. In that case we get 8 * 15 = 120 "different" starting positions.

Play by forum

I'd like to try:

I'm also interested in unusual handicaps:

Personal announcements

  • (2022-05-26) I'm looking for Shogi (将棋) players in/around Lausanne (Switzerland). My level is 5 kyū according to 81Dojo. I can give/receive handicap, and beginners are welcome. I speak French, English and Japanese (somewhat). If you're interested, send me an email!

About

Small utilities to download games from 81Dojo and generate Shogi22680 positions. Rambling about Shogi variants

License:MIT License


Languages

Language:Python 70.4%Language:C++ 27.3%Language:Makefile 2.2%