summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO20
-rw-r--r--Makefile.patch11
-rw-r--r--PKGBUILD40
-rwxr-xr-xbonanza2
-rw-r--r--bonanza.install14
-rw-r--r--shogidokoro_usi_20140611.patch382
6 files changed, 469 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..21605ee9ca6f
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,20 @@
+pkgbase = bonanza
+ pkgdesc = The Computer Shogi Program
+ pkgver = 6.0
+ pkgrel = 5
+ url = http://www.geocities.jp/bonanza_shogi/
+ install = bonanza.install
+ arch = i686
+ arch = x86_64
+ license = CUSTOM
+ source = http://gi.cs.uec.ac.jp:10140/bonanza_v6.0.zip
+ source = shogidokoro_usi_20140611.patch
+ source = bonanza
+ source = Makefile.patch
+ md5sums = 7e993748c8fd596dc6756e04c4732b5c
+ md5sums = 708675832b9c56fa807b78fa3a321f70
+ md5sums = 7224c254dd6cf5812b5feea20c675ae2
+ md5sums = e47b5538512d03bf61d60ed97d8fa937
+
+pkgname = bonanza
+
diff --git a/Makefile.patch b/Makefile.patch
new file mode 100644
index 000000000000..dbca4fa27cdc
--- /dev/null
+++ b/Makefile.patch
@@ -0,0 +1,11 @@
+--- bonanza_v6.0/src/client/Makefile.orig 2011-05-09 14:11:44.000000000 +0900
++++ bonanza_v6.0/src/client/Makefile 2014-05-22 13:05:56.424956348 +0900
+@@ -23,7 +23,7 @@
+ # -DDFPN build the DFPN worker of mate-problems server.
+ # -DDFPN_CLIENT enables the client-mode of mate-problem server.
+
+-OPT =-DNDEBUG -DMINIMUM -DHAVE_SSE4 -msse4.1 -DDFPN -DTLP -DDFPN_CLIENT -DINANIWA_SHIFT -DMNJ_LAN -DCSA_LAN
++OPT =-DUSI -DNDEBUG -DMINIMUM -DHAVE_SSE4 -msse4.1 -DDFPN -DTLP -DDFPN_CLIENT -DINANIWA_SHIFT -DMNJ_LAN -DCSA_LAN
+
+ help:
+ @echo "try targets as:"
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..8ab28c0934d1
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,40 @@
+# $Id: pkgbuild-mode.el,v 1.23 2007/10/20 16:02:14 juergen Exp $
+# Maintainer: Daichi Shinozaki <dsdseg@gmail.com>
+pkgname=bonanza
+pkgver=6.0
+pkgrel=5
+pkgdesc="The Computer Shogi Program"
+arch=('i686' 'x86_64')
+url="http://www.geocities.jp/bonanza_shogi/"
+source=("http://gi.cs.uec.ac.jp:10140/${pkgname}_v${pkgver}.zip"
+'shogidokoro_usi_20140611.patch'
+'bonanza'
+'Makefile.patch')
+license=('CUSTOM')
+install="bonanza.install"
+md5sums=('7e993748c8fd596dc6756e04c4732b5c'
+ '708675832b9c56fa807b78fa3a321f70'
+ '7224c254dd6cf5812b5feea20c675ae2'
+ 'e47b5538512d03bf61d60ed97d8fa937')
+
+prepare() {
+ cd ${pkgname}_v$pkgver
+ patch -p1 --verbose -i $srcdir/shogidokoro_usi_20140611.patch
+ patch -p1 --verbose -i $srcdir/Makefile.patch
+}
+
+build() {
+ cd ${pkgname}_v$pkgver/src/client
+
+ make gcc
+}
+
+package() {
+ cd ${pkgname}_v$pkgver
+
+ mkdir -m755 -p $pkgdir/opt/$pkgname/log
+ install -m755 ./src/client/$pkgname ./winbin/*.bin $pkgdir/opt/$pkgname/
+ install -Dm755 $srcdir/$pkgname $pkgdir/usr/bin/$pkgname
+}
+
+# vim:set ts=2 sw=2 et:
diff --git a/bonanza b/bonanza
new file mode 100755
index 000000000000..c761f1742db7
--- /dev/null
+++ b/bonanza
@@ -0,0 +1,2 @@
+#!/usr/bin/bash
+cd /opt/bonanza && ./bonanza "$@" \ No newline at end of file
diff --git a/bonanza.install b/bonanza.install
new file mode 100644
index 000000000000..b50e8b6d7de6
--- /dev/null
+++ b/bonanza.install
@@ -0,0 +1,14 @@
+post_install() {
+ getent passwd bonanza >/dev/null || useradd --no-create-home --no-user-group --shell /sbin/nologin -d /dev/null bonanza
+ chown bonanza -R /opt/bonanza/ /usr/bin/bonanza
+ chmod 4755 /opt/bonanza/bonanza
+}
+
+post_upgrade() {
+ chown bonanza -R /opt/bonanza/ /usr/bin/bonanza
+ chmod 4755 /opt/bonanza/bonanza
+}
+
+pre_remove() {
+ getent passwd bonanza && userdel bonanza
+}
diff --git a/shogidokoro_usi_20140611.patch b/shogidokoro_usi_20140611.patch
new file mode 100644
index 000000000000..3924b67041bc
--- /dev/null
+++ b/shogidokoro_usi_20140611.patch
@@ -0,0 +1,382 @@
+diff -Nur bonanza_v6.0/src/client/main.c bonanza_v6.0_patched/src/client/main.c
+--- bonanza_v6.0/src/client/main.c 2011-05-09 14:01:40 +0900
++++ bonanza_v6.0_patched/src/client/main.c 2015-01-23 11:27:33 +0900
+@@ -37,8 +37,10 @@
+ #endif
+
+ #if defined(USI)
+- if ( argc == 2 && ! strcmp( argv[1], "usi" ) ) { usi_mode = usi_on; }
++/* if ( argc == 2 && ! strcmp( argv[1], "usi" ) ) { usi_mode = usi_on; }
+ else { usi_mode = usi_off; }
++*/
++ usi_mode = usi_on;
+ #endif
+
+ if ( ini( ptree ) < 0 )
+diff -Nur bonanza_v6.0/src/client/proce.c bonanza_v6.0_patched/src/client/proce.c
+--- bonanza_v6.0/src/client/proce.c 2011-05-06 23:01:08 +0900
++++ bonanza_v6.0_patched/src/client/proce.c 2015-01-23 11:39:28 +0900
+@@ -6,6 +6,38 @@
+ #include <string.h>
+ #include "shogi.h"
+
++#if defined(USI)
++/* USI options */
++struct {
++ char time_control[ BUFSIZ ];
++ char time_a[ BUFSIZ ];
++ char time_b[ BUFSIZ ];
++ char nodes[ BUFSIZ ];
++ char depth[ BUFSIZ ];
++ char use_book[ BUFSIZ ];
++ char narrow_book[ BUFSIZ ];
++ char strict_time[ BUFSIZ ];
++ char resign[ BUFSIZ ];
++ char memory[ BUFSIZ ];
++ char ponder[ BUFSIZ ];
++ char threads[ BUFSIZ ];
++} usi_name;
++struct {
++ char time_control[ BUFSIZ ];
++ int time_a;
++ int time_b;
++ int nodes;
++ int depth;
++ char use_book[ BUFSIZ ];
++ char narrow_book[ BUFSIZ ];
++ char strict_time[ BUFSIZ ];
++ int resign;
++ int memory;
++ char ponder[ BUFSIZ ];
++ int threads;
++} usi_value;
++#endif
++
+ /* unacceptable when the program is thinking, or quit pondering */
+ #define AbortDifficultCommand \
+ if ( game_status & flag_thinking ) \
+@@ -401,6 +433,172 @@
+
+
+ #if defined(USI)
++/* initialize usi options */
++static void CONV
++init_usi_option( void )
++{
++ strcpy( usi_name.time_control, "TimeControl" );
++ strcpy( usi_name.time_a, "TimeA[min]" );
++ strcpy( usi_name.time_b, "TimeB[sec]" );
++ strcpy( usi_name.nodes, "Nodes" );
++ strcpy( usi_name.depth, "Depth" );
++ strcpy( usi_name.use_book, "UseBook" );
++ strcpy( usi_name.narrow_book, "NarrowBook" );
++ strcpy( usi_name.strict_time, "StrictTime" );
++ strcpy( usi_name.resign, "Resign" );
++ strcpy( usi_name.memory, "Memory[MB]" );
++ strcpy( usi_name.ponder, "Ponder" );
++ strcpy( usi_name.threads, "Threads" );
++
++ strcpy( usi_value.time_control, "Time" );
++ usi_value.time_a = 0;
++ usi_value.time_b = 3;
++ usi_value.nodes = 100000;
++ usi_value.depth = 5;
++ strcpy( usi_value.use_book, "true" );
++ strcpy( usi_value.narrow_book, "false" );
++ strcpy( usi_value.strict_time, "true" );
++ usi_value.resign = 3000;
++ usi_value.memory = 12;
++ strcpy( usi_value.ponder, "false" );
++ usi_value.threads = 1;
++}
++
++
++/* set usi_options */
++static void CONV
++set_usi_option( tree_t * restrict ptree, const char *name, const char *value )
++{
++ char str[ SIZE_CMDLINE ];
++ char *last, *token, *ptr;
++
++ if ( ! strcmp( name, usi_name.time_control ) )
++ {
++ strcpy( usi_value.time_control, value );
++ }
++ else if ( ! strcmp( name, usi_name.time_a ) && ! strcmp( usi_value.time_control, "Time") )
++ {
++ usi_value.time_a = (int)strtol( value, &ptr, 0 );
++ }
++ else if ( ! strcmp( name, usi_name.time_b ) && ! strcmp( usi_value.time_control, "Time") )
++ {
++ usi_value.time_b = (int)strtol( value, &ptr, 0 );
++ sprintf( str, "limit time %d %d", usi_value.time_a, usi_value.time_b );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_limit( &last );
++ }
++ else if ( ! strcmp( name, usi_name.nodes ) && ! strcmp( usi_value.time_control, "Nodes") )
++ {
++ usi_value.nodes = (int)strtol( value, &ptr, 0 );
++ sprintf( str, "limit nodes %d", usi_value.nodes );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_limit( &last );
++ }
++ else if ( ! strcmp( name, usi_name.depth ) && ! strcmp( usi_value.time_control, "Depth") )
++ {
++ usi_value.depth = (int)strtol( value, &ptr, 0 );
++ sprintf( str, "limit depth %d", usi_value.depth );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_limit( &last );
++ }
++ else if ( ! strcmp( name, usi_name.use_book ) )
++ {
++ strcpy( usi_value.use_book, value );
++ sprintf( str, "book %s", ( ! strcmp( usi_value.use_book, "true" ) ? str_on : str_off ) );
++ token = strtok_r( str, str_delimiters, &last );
++ CmdBook( ptree, &last );
++ }
++ else if ( ! strcmp( name, usi_name.narrow_book ) )
++ {
++ strcpy( usi_value.narrow_book, value );
++ sprintf( str, "book %s", ( ! strcmp( usi_value.narrow_book, "true" ) ? "narrow" : "wide" ) );
++ token = strtok_r( str, str_delimiters, &last );
++ CmdBook( ptree, &last );
++ }
++ else if ( ! strcmp( name, usi_name.strict_time ) )
++ {
++ strcpy( usi_value.strict_time, value );
++ sprintf( str, "limit time %s", ( !strcmp( usi_value.strict_time, "true" ) ? "strict" : "extendable" ) );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_limit( &last );
++ }
++ else if ( ! strcmp( name, usi_name.resign ) )
++ {
++ usi_value.resign = (int)strtol( value, &ptr, 0 );
++ sprintf( str, "resign %d", usi_value.resign );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_resign( ptree, &last );
++ }
++ else if ( ! strcmp( name, usi_name.memory ) )
++ {
++ int hash;
++ usi_value.memory = (int)strtol( value, &ptr, 0 );
++ hash = (int)(log(usi_value.memory * 1e6 / 48) / log(2)) + 1;
++ sprintf( str, "hash %d", hash );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_hash ( &last );
++ }
++ else if ( ! strcmp( name, usi_name.ponder ) )
++ {
++/* (not implemented)
++ strcpy( usi_value.ponder, value );
++ sprintf( str, "ponder %s", ( ! strcmp( usi_value.ponder, "true" ) ? str_on : str_off ) );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_ponder( &last );
++*/
++ }
++ else if ( ! strcmp( name, usi_name.threads ) )
++ {
++ usi_value.threads = (int)strtol( value, &ptr, 0 );
++#if defined(TLP)
++ sprintf( str, "tlp num %d", usi_value.threads );
++ token = strtok_r( str, str_delimiters, &last );
++ cmd_thread( &last );
++#endif
++ }
++}
++
++
++/* "setoption name XXX value YYY" */
++static int CONV
++usi_option( tree_t * restrict ptree, char **lasts )
++{
++ const char *str1, *str2, *str3, *str4;
++
++ str1 = strtok_r( NULL, str_delimiters, lasts );
++ if ( str1 == NULL || strcmp( str1, "name" ) )
++ {
++ str_error = str_bad_cmdline;
++ return -1;
++ }
++
++ str2 = strtok_r( NULL, str_delimiters, lasts );
++ if ( str2 == NULL )
++ {
++ str_error = str_bad_cmdline;
++ return -1;
++ }
++
++ str3 = strtok_r( NULL, str_delimiters, lasts );
++ if ( str3 == NULL || strcmp( str3, "value" ) )
++ {
++ str_error = str_bad_cmdline;
++ return -1;
++ }
++
++ str4 = strtok_r( NULL, str_delimiters, lasts );
++ if ( str4 == NULL )
++ {
++ str_error = str_bad_cmdline;
++ return -1;
++ }
++
++ set_usi_option( ptree, str2, str4 );
++
++ return 1;
++}
++
++
+ static int CONV proce_usi( tree_t * restrict ptree )
+ {
+ const char *token;
+@@ -414,16 +612,44 @@
+ {
+ USIOut( "id name %s\n", str_myname );
+ USIOut( "id author Kunihito Hoki\n" );
++
++ /* options */
++ init_usi_option();
++ USIOut( "option name %s type combo default %s var Time var Nodes var Depth\n", usi_name.time_control, usi_value.time_control );
++ USIOut( "option name %s type spin default %d min 0 max 600\n", usi_name.time_a, usi_value.time_a );
++ USIOut( "option name %s type spin default %d min 0 max 36000\n", usi_name.time_b, usi_value.time_b );
++ USIOut( "option name %s type spin default %d min 1000 max 100000000\n", usi_name.nodes, usi_value.nodes );
++ USIOut( "option name %s type spin default %d min 1 max 30\n", usi_name.depth, usi_value.depth );
++ USIOut( "option name %s type check default %s\n", usi_name.use_book, usi_value.use_book );
++ USIOut( "option name %s type check default %s\n", usi_name.narrow_book, usi_value.narrow_book );
++ USIOut( "option name %s type check default %s\n", usi_name.strict_time, usi_value.strict_time );
++ USIOut( "option name %s type combo default %d var 1000 var 2000 var 3000 var 5000 var 32596\n", usi_name.resign, usi_value.resign );
++ USIOut( "option name %s type combo default %d var 12 var 24 var 48 var 96 var 192 var 384 var 768 var 1536\n", usi_name.memory, usi_value.memory );
++ USIOut( "option name %s type check default %s\n", usi_name.ponder, usi_value.ponder );
++ USIOut( "option name %s type spin default %d min 1 max 256\n", usi_name.threads, usi_value.threads );
++
+ USIOut( "usiok\n" );
++
+ return 1;
+ }
+
++ /* set options */
++ if ( ! strcmp( token, "setoption" ) )
++ {
++ return usi_option( ptree, &lasts );
++ }
++
+ if ( ! strcmp( token, "isready" ) )
+ {
+ USIOut( "readyok\n", str_myname );
+ return 1;
+ }
+
++ if ( ! strcmp( token, "usinewgame" ) )
++ {
++ return 1;
++ }
++
+ if ( ! strcmp( token, "echo" ) )
+ {
+ USIOut( "%s\n", lasts );
+@@ -448,10 +674,15 @@
+ return iret;
+ }
+
++ if ( ! strcmp( token, "gameover" ) )
++ {
++ return 1;
++ }
++
+ if ( ! strcmp( token, "stop" ) ) { return cmd_move_now(); }
+ if ( ! strcmp( token, "position" ) ) { return usi_posi( ptree, &lasts ); }
+ if ( ! strcmp( token, "quit" ) ) { return cmd_quit(); }
+-
++
+ str_error = str_bad_cmdline;
+ return -1;
+ }
+@@ -471,7 +702,7 @@
+ {
+ token = strtok_r( NULL, str_delimiters, lasts );
+ if ( token == NULL ) { break; }
+-
++
+ if ( usi2csa( ptree, token, str_buf ) < 0 ) { return -1; }
+ if ( interpret_CSA_move( ptree, &move, str_buf ) < 0 ) { return -1; }
+
+@@ -499,7 +730,7 @@
+ str_error = str_game_ended;
+ return -1;
+ }
+-
++
+ token = strtok_r( NULL, str_delimiters, lasts );
+
+ if ( ! strcmp( token, "book" ) )
+@@ -518,6 +749,9 @@
+ node_limit = UINT64_MAX;
+ sec_limit_depth = UINT_MAX;
+ }
++ else if ( ! strcmp( token, "btime" ) )
++ {
++ }
+ else if ( ! strcmp( token, "byoyomi" ) )
+ {
+ token = strtok_r( NULL, str_delimiters, lasts );
+@@ -533,18 +767,22 @@
+ str_error = str_bad_cmdline;
+ return -1;
+ }
+-
++
+ usi_byoyomi = (unsigned int)l;
+ depth_limit = PLY_MAX;
+ node_limit = UINT64_MAX;
+ sec_limit_depth = UINT_MAX;
+ }
++ else if ( ! strcmp( token, "mate" ) )
++ {
++ /* not implemented */
++ }
+ else {
+ str_error = str_bad_cmdline;
+ return -1;
+ }
+
+-
++
+ if ( get_elapsed( &time_turn_start ) < 0 ) { return -1; }
+
+ iret = com_turn_start( ptree, 0 );
+@@ -552,7 +790,7 @@
+ if ( str_error == str_no_legal_move ) { USIOut( "bestmove resign\n" ); }
+ else { return -1; }
+ }
+-
++
+ return 1;
+ }
+
+diff -Nur bonanza_v6.0/src/client/searchr.c bonanza_v6.0_patched/src/client/searchr.c
+--- bonanza_v6.0/src/client/searchr.c 2011-05-06 23:01:08 +0900
++++ bonanza_v6.0_patched/src/client/searchr.c 2015-01-23 11:38:44 +0900
+@@ -372,7 +372,7 @@
+ Out( "%2d.%c%-7s", ply, ach_turn[tt], str );
+
+ #if defined(USI)
+- if ( usi_mode != usi_off && ply <= 4 )
++ if ( usi_mode != usi_off )
+ {
+ char str_usi[6];
+ csa2usi( ptree, str_CSA_move(ptree->pv[0].a[ply]), str_usi );
+diff -Nur bonanza_v6.0/src/client/utility.c bonanza_v6.0_patched/src/client/utility.c
+--- bonanza_v6.0/src/client/utility.c 2011-05-06 23:01:08 +0900
++++ bonanza_v6.0_patched/src/client/utility.c 2015-01-23 11:38:14 +0900
+@@ -519,6 +519,12 @@
+ if ( iret < 0 ) { return iret; }
+ }
+ #endif
++#if defined(USI)
++ if ( usi_mode != usi_off )
++ {
++ USIOut( "bestmove resign\n" );
++ }
++#endif
+ OutCsaShogi( "resign\n" );
+ }
+ else {