风云剑
发表于 2019-12-17 12:37:34
简单介绍下主程序
int main()
{
int mvl;//这个数组用于存放招法列表
Position pos;//定义一个局面
Position::initGen();//初始化,重要!初始化只需要一次
pos.newGame();//局面回到初始局面
int rmc = pos.get_move_count(WHITE, mvl);//获得红方招法数
int bmc = pos.get_move_count(BLACK, mvl);//获得黑方招法数
cout << rmc << "/" << bmc << endl;
for (int id = 0; id < sizeof(bd) / sizeof(bd); id++)
{
for (int row = 0; row < 10; row++)
{
for (int col = 0; col < 9; col++)
{
pos.board_set_piece(row, col, char_to_pc(bd));//这个函数的作用是摆放棋子,在某行某列摆放一个棋子(可以是空白)
}
}
rmc = pos.get_move_count(WHITE, mvl);
bmc = pos.get_move_count(BLACK, mvl);
cout << pos.toFen() << endl;
cout << rmc << "/" << bmc << endl;
cout << pos.board_to_string() << endl;
}
}
风云剑
发表于 2019-12-17 12:41:20
不过现在我对暴力搜索这块没什么思路,帮不了太多忙。
主要是车马炮兵这四种棋子的可选位置太多了
dlpg070
发表于 2019-12-17 18:46:57
本帖最后由 dlpg070 于 2019-12-17 18:48 编辑
风云剑 发表于 2019-12-17 12:41
不过现在我对暴力搜索这块没什么思路,帮不了太多忙。
主要是车马炮兵这四种棋子的可选位置太多了
谢谢 ,及时雨
刚刚完成FEN转我的格式的转换,我的简陋象棋布局专用工具可以使用最先进象棋软件的布局数据了
正想开始研究分析走法,你的软件太及时了
我只想先玩一下,不一定完全暴力搜索,重点是预先先分析车炮马兵,简化布局
下面给出一张我画的布局图,
源于象棋巫师,没有走法步数数据(0),待计算
dlpg070
发表于 2019-12-20 13:00:55
本帖最后由 dlpg070 于 2019-12-20 13:07 编辑
dlpg070 发表于 2019-12-17 18:46
谢谢 ,及时雨
刚刚完成FEN转我的格式的转换,我的简陋象棋布局专用工具可以使用最先进象棋软件的布局 ...
布局的走法数分析工具已完成
谢谢风云剑的代码,修改了position.h(加了#define FENMOV),没用sthinker.cpp
只要在任意象棋软件上设计布局,可以给出走法分析
实现字符布局和走法数直观显示
也实现汉字布局和走法数直观显示
工具已经完备,待高手钻研象棋本身,期待有所突破!
请毒酒滴冻鸭尽可能的总结10个布局的特点和布局思路,不一定完整,想一条,写一条
下面是走法数分析工具的输出界面:
分析fen输出带有各棋子走法数 mon, 开始:
fen文件的字符串
rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w
最后输出 (fen + mon)到文件: out.fon
rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w,CCCBBBCC
C/9/1M5M1/B1B1B1B1B/9/9/B1B1B1B1B/1M5M1/9/CCCBBBCCC b
显示字符棋子走法数
r n b a k a b n r
2 2 2 1 1 1 2 2 2
. . . . . . . . .
. c . . . . . c .
12 12
p . p . p . p . p
1 1 1 1 1
. . . . . . . . .
. . . . . . . . .
P . P . P . P . P
1 1 1 1 1
. C . . . . . C .
12 12
. . . . . . . . .
R N B A K A B N R
2 2 2 1 1 1 2 2 2
显示汉字棋子走法数(红色车马用简体 )
車馬象士将士象馬車
2 2 2 1 1 1 2 2 2
. . . . . . . . .
.炮 . . . . .炮 .
12 12
卒 .卒 .卒 .卒 .卒
1 1 1 1 1
. . . . . . . . .
. . . . . . . . .
兵 .兵 .兵 .兵 .兵
1 1 1 1 1
.砲 . . . . .砲 .
12 12
. . . . . . . . .
车马相仕帅仕相马车
2 2 2 1 1 1 2 2 2
------ 结束 ------
dlpg070
发表于 2019-12-23 19:30:20
本帖最后由 dlpg070 于 2019-12-23 19:42 编辑
dlpg070 发表于 2019-12-20 13:00
布局的走法数分析工具已完成
谢谢风云剑的代码,修改了position.h(加了#define FENMOV),没用sthinker. ...
10个汉字文本象棋布局.txt
为了方便分析比较注释各典型布局生成这些文本象棋布局
如果有错,请指出
红方:帅仕相马车砲兵
黑方:将士象馬車炮卒
====================================
走法数: (102 , 0)
+---+---+0+0+0+0+2+---+---+
| | | 象| 車| 車| 士| 兵| | |
+---+---+---+0+0+ 13+---+---+---+
| | | | 将| 炮| 车| | | |
+0+---+3+0+3+---+8+---+---+
| 象| | 兵| 士| 兵| | 马| | |
+---+ 16+---+---+---+---+---+---+---+
| | 车| | | | | | | |
+---+---+3+---+3+---+8+---+---+
| | | 兵| | 兵| | 马| | |
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | | 砲| |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 砲|
+1+---+---+0+3+---+---+---+---+
| 相| | | 仕| 相| | | | |
+0+0+0+0+3+---+---+---+---+
| 卒| 卒| 卒| 炮| 仕| | | | |
+0+0+0+0+2+---+---+---+---+
| 卒| 卒| 馬| 馬| 帅| | | | |
+---+---+---+---+---+---+---+---+---+
走法数: (103 , 0)
+---+0+0+0+0+0+0+---+---+
| | 馬| 象| 車| 車| 炮| 象| | |
+---+3+---+0+0+3+---+3+---+
| | 兵| | 将| 馬| 兵| | 兵| |
+---+---+3+0+3+0+---+---+---+
| | | 兵| 士| 兵| 士| | | |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 车| | |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 车|
+ 17+---+---+---+---+---+---+---+---+
| 砲| | | | | | | | |
+---+ 16+---+---+---+---+---+---+---+
| | 砲| | | | | | | |
+---+---+7+---+3+0+---+6+---+
| | | 马| | 相| 仕| | 马| |
+---+---+---+1+3+---+---+---+---+
| | | | 帅| 仕| | | | |
+---+---+1+0+0+0+0+0+0+
| | | 相| 炮| 卒| 卒| 卒| 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (104 , 0)
+---+0+0+0+0+0+0+---+---+
| | 馬| 象| 車| 車| 炮| 象| | |
+---+3+---+0+0+3+---+3+---+
| | 兵| | 将| 士| 兵| | 兵| |
+---+---+3+0+---+0+---+---+---+
| | | 兵| 馬| | 士| | | |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 车| | |
+---+---+8+---+---+8+---+3+---+
| | | 马| | | 马| | 兵| |
+---+ 16+---+---+---+---+---+---+---+
| | 砲| | | | | | | |
+ 16+---+---+---+---+---+---+---+ 16+
| 砲| | | | | | | | 车|
+---+---+---+---+3+0+---+---+---+
| | | | | 相| 仕| | | |
+---+---+---+1+3+---+---+---+---+
| | | | 帅| 仕| | | | |
+---+---+1+0+0+0+0+0+0+
| | | 相| 炮| 卒| 卒| 卒| 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (105 , 1)
+---+0+0+0+0+0+2+---+---+
| | 馬| 象| 車| 車| 炮| 兵| | |
+---+3+---+0+0+3+---+---+---+
| | 兵| | 将| 馬| 兵| | | |
+0+---+---+0+3+0+3+---+---+
| 象| | | 士| 兵| 士| 兵| | |
+---+ 15+---+---+---+---+---+---+---+
| | 砲| | | | | | | |
+---+---+---+---+8+---+8+---+---+
| | | | | 马| | 马| | |
+---+---+---+---+---+---+---+ 16+---+
| | | | | | | | 砲| |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 车|
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+---+---+ 17+---+---+---+---+---+---+
| | | 车| | | | | | |
+0+0+0+2+---+---+1+0+0+
| 卒| 卒| 炮| 帅| | | 卒| 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (106 , 2)
+0+0+0+0+0+0+---+---+---+
| 車| 炮| 象| 士| 車| 士| | | |
+0+3+---+3+0+3+---+---+---+
| 馬| 兵| | 兵| 馬| 兵| | | |
+0+0+3+---+0+---+---+---+---+
| 象| 炮| 兵| | 将| | | | |
+---+3+---+8+---+8+---+---+---+
| | 兵| | 马| | 马| | | |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 车|
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | | 车| |
+---+---+---+---+---+---+ 16+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+---+---+ 15+---+---+---+---+---+---+
| | | 砲| | | | | | |
+0+1+---+2+---+---+1+0+0+
| 卒| 卒| | 帅| | | 卒| 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (107 , 3)
+0+0+0+0+0+0+---+---+---+
| 炮| 馬| 象| 士| 将| 士| | | |
+1+3+---+3+0+3+---+---+---+
| 車| 兵| | 兵| 馬| 兵| | | |
+0+---+---+---+3+---+---+---+---+
| 象| | | | 兵| | | | |
+---+3+---+8+---+8+---+---+---+
| | 兵| | 马| | 马| | | |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 车|
+---+---+---+---+---+---+---+ 16+---+
| | | | | | | | 砲| |
+---+---+---+---+---+---+ 16+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+1+---+ 17+---+---+---+---+---+---+
| 卒| | 车| | | | | | |
+0+0+0+2+---+---+1+0+0+
| 車| 卒| 炮| 帅| | | 卒| 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (108 , 3)
+0+0+0+0+0+0+---+---+---+
| 車| 炮| 象| 士| 車| 士| | | |
+0+3+---+0+0+3+---+---+---+
| 炮| 兵| | 将| 馬| 兵| | | |
+0+0+3+---+3+---+---+---+---+
| 象| 馬| 兵| | 兵| | | | |
+1+3+---+8+---+8+---+---+---+
| 卒| 兵| | 马| | 马| | | |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | | 车|
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | | 车| |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+---+---+ 15+---+---+---+---+---+---+
| | | 砲| | | | | | |
+0+1+---+---+3+---+---+1+0+
| 卒| 卒| | | 帅| | | 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (108 , 4)
+0+0+0+0+2+0+---+---+---+
| 車| 馬| 象| 士| 兵| 士| | | |
+0+3+---+0+0+3+---+---+---+
| 炮| 兵| | 将| 馬| 兵| | | |
+0+---+---+---+3+---+---+---+---+
| 象| | | | 兵| | | | |
+1+3+---+8+---+8+---+---+---+
| 卒| 兵| | 马| | 马| | | |
+---+---+---+---+---+---+---+---+ 16+
| | | | | | | | | 砲|
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | | 车| |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+---+---+ 17+---+---+---+---+---+1+
| | | 车| | | | | | 卒|
+0+0+1+---+3+---+---+1+0+
| 卒| 卒| 炮| | 帅| | | 卒| 車|
+---+---+---+---+---+---+---+---+---+
走法数: (109 , 5)
+0+1+0+0+0+0+---+---+---+
| 炮| 車| 象| 士| 将| 士| | | |
+1+3+---+3+0+3+---+---+---+
| 車| 兵| | 兵| 馬| 兵| | | |
+0+---+---+---+3+---+---+---+---+
| 象| | | | 兵| | | | |
+0+3+---+8+---+8+---+---+---+
| 馬| 兵| | 马| | 马| | | |
+1+---+---+---+---+---+---+---+ 17+
| 卒| | | | | | | | 车|
+---+---+---+---+---+---+---+ 16+---+
| | | | | | | | 砲| |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+---+---+ 17+---+---+---+---+---+---+
| | | 车| | | | | | |
+0+0+1+---+3+---+---+1+0+
| 卒| 卒| 炮| | 帅| | | 卒| 卒|
+---+---+---+---+---+---+---+---+---+
走法数: (110 , 6)
+0+0+0+0+0+0+---+---+---+
| 車| 馬| 象| 士| 将| 士| | | |
+1+3+---+3+0+3+---+---+---+
| 炮| 兵| | 兵| 馬| 兵| | | |
+0+---+---+---+3+---+---+---+---+
| 象| | | | 兵| | | | |
+1+3+---+8+---+8+---+---+---+
| 車| 兵| | 马| | 马| | | |
+1+---+---+---+---+---+---+---+ 17+
| 卒| | | | | | | | 车|
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | | 砲| |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | | 砲| | |
+2+---+---+1+4+1+---+---+---+
| 相| | | 仕| 相| 仕| | | |
+1+---+ 17+---+---+---+---+---+---+
| 卒| | 车| | | | | | |
+0+0+1+---+3+---+---+---+1+
| 卒| 卒| 炮| | 帅| | | | 卒|
+---+---+---+---+---+---+---+---+---+
dlpg070
发表于 2019-12-24 09:20:22
本帖最后由 dlpg070 于 2019-12-24 09:29 编辑
dlpg070 发表于 2019-12-23 19:30
10个汉字文本象棋布局.txt
为了方便分析比较注释各典型布局生成这些文本象棋布局
如果有错,请指出
这样改,可好?
走法数: (108 , 3)
+0+0+0+0+0+0+---+---+---+
|b車|b炮|b象|b士|b車|b士| | | |
+0+3+---+0+0+3+---+---+---+
|b炮|r兵| |b將|b馬|r兵| | | |
+0+0+3+---+3+---+---+---+---+
|b象|b馬|r兵| |r兵| | | | |
+1+3+---+8+---+8+---+---+---+
|b卒|r兵| |r马| |r马| | | |
+---+---+---+---+---+---+---+---+ 17+
| | | | | | | | |r车|
+---+---+---+---+---+---+---+ 17+---+
| | | | | | | |r车| |
+---+---+---+---+---+---+ 17+---+---+
| | | | | | |r砲| | |
+2+---+---+1+4+1+---+---+---+
|r相| | |r仕|r相|r仕| | | |
+---+---+ 15+---+---+---+---+---+---+
| | |r砲| | | | | | |
+0+1+---+---+3+---+---+1+0+
|b卒|b卒| | |r帅| | |b卒|b卒|
+---+---+---+---+---+---+---+---+---+
毒酒滴冻鸭
发表于 2019-12-24 19:20:14
不知为何你对象棋巫师这么执着,它只是其中一个象棋软件,而且你看到的“红砲黑炮”只是它提供的其中一种棋子的式样(虽然是一开始安装的默认选择),它有其他很多不同的棋子式样选择,例如我当年在贴吧用的就是另一种:
http://imgsrc.baidu.com/forum/pic/item/0dde76094b36acafc54265947cd98d1000e99cee.jpg
这个也是象棋巫师的输出,只不过是用了另一套棋子,证明“红砲黑炮”并不是绝对的标准,它只是某一套棋子式样设计者自己的选择(而且很可能是该设计者不严谨,张冠李戴了)。
然后可能你人在国内上不了维基百科,那么你去百度百科的词条看看好了:
https://baike.baidu.com/item/%E4%B8%AD%E5%9B%BD%E8%B1%A1%E6%A3%8B/278314
以下是该词条内提供的图,有图有真相:
https://gss1.bdstatic.com/-vo3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike80%2C5%2C5%2C80%2C26/sign=02991d737d1ed21b6dc426b7cc07b6a1/472309f790529822f703b542d7ca7bcb0a46d47b.jpg
毒酒滴冻鸭
发表于 2019-12-24 19:23:06
这是我在维基百科的截图:
dlpg070
发表于 2019-12-25 21:59:30
本帖最后由 dlpg070 于 2019-12-25 22:12 编辑
毒酒滴冻鸭 发表于 2019-12-24 19:23
这是我在维基百科的截图:
汉字文本布局又增加了标准的坐标和河界标志,趋于完善,暂时不改了
用于分析布局立见成效
暴力搜索求解的代码框架已经成型,
不过先要花点时间用这个文本工具好好分析一下
10个优秀布局的窍门
初步看了一下,不会有太大发现,可能会发现r-b =104 or 105的新布局,而且重点是 107 和 108
下面给出 (108,3)和 (108,4)的对比
可以直观分析出 108,4b大的关键原因,见右下角
走法数: (108 , 3) 走法数: (108 , 4)
+0+0+0+0+0+0+---+---+---+ +0+0+0+0+2+0+---+---+---+
|b車|b炮|b象|b士|b車|b士| | | |9|b車|b馬|b象|b士|r兵|b士| | | |9
+0+3+---+0+0+3+---+---+---+ +0+3+---+0+0+3+---+---+---+
|b炮|r兵| |b將|b馬|r兵| | | |8|b炮|r兵| |b將|b馬|r兵| | | |8
+0+0+3+---+3+---+---+---+---+ +0+---+---+---+3+---+---+---+---+
|b象|b馬|r兵| |r兵| | | | |7|b象| | | |r兵| | | | |7
+1+3+---+8+---+8+---+---+---+ +1+3+---+8+---+8+---+---+---+
|b卒|r兵| |r马| |r马| | | |6|b卒|r兵| |r马| |r马| | | |6
+---+---+---+---+---+---+---+---+ 17+ +---+---+---+---+---+---+---+---+ 16+
| | | | | | | | |r车|5| | | | | | | | |r砲|5
+---+---+---+---+---+---+---+ 17+---+===+---+---+---+---+---+---+---+ 17+---+===
| | | | | | | |r车| |4| | | | | | | |r车| |4
+---+---+---+---+---+---+ 17+---+---+ +---+---+---+---+---+---+ 17+---+---+
| | | | | | |r砲| | |3| | | | | | |r砲| | |3
+2+---+---+1+4+1+---+---+---+ +2+---+---+1+4+1+---+---+---+
|r相| | |r仕|r相|r仕| | | |2|r相| | |r仕|r相|r仕| | | |2
+---+---+ 15+---+---+---+---+---+---+ +---+---+ 17+---+---+---+---+---+1+
| | |r砲| | | | | | |1| | |r车| | | | | |b卒|1
+0+1+---+---+3+---+---+1+0+ +0+0+1+---+3+---+---+1+0+
|b卒|b卒| | |r帅| | |b卒|b卒|0|b卒|b卒|b炮| |r帅| | |b卒|b車|0
+---+---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+---+
A B C D E F G H I A B C D E F G H I
dlpg070
发表于 2019-12-26 13:26:49
毒酒滴冻鸭 发表于 2019-12-24 19:23
这是我在维基百科的截图:
好消息
发现第二个(108,3)布局 r-b=105
p1083.fen/txt
走法数: (108 , 3)
+0+0+0+0+0+0+---+---+---+
|b車|b炮|b象|b士|b車|b士| | | |9
+0+3+---+0+0+3+---+---+---+
|b炮|r兵| |b將|b馬|r兵| | | |8
+0+0+3+---+3+---+---+---+---+
|b象|b馬|r兵| |r兵| | | | |7
+---+3+---+8+---+8+---+---+---+
| |r兵| |r马| |r马| | | |6
+1+---+---+---+---+---+---+---+ 17+
|b卒| | | | | | | |r车|5
+---+---+---+---+---+---+---+ 17+---+===
| | | | | | | |r车| |4
+---+---+---+---+---+---+ 17+---+---+
| | | | | | |r砲| | |3
+2+---+---+1+4+1+---+---+---+
|r相| | |r仕|r相|r仕| | | |2
+---+---+ 15+---+---+---+---+---+---+
| | |r砲| | | | | | |1
+0+1+---+---+3+---+---+1+0+
|b卒|b卒| | |r帅| | |b卒|b卒|0
+---+---+---+---+---+---+---+---+---+
A B C D E F G H I