最近学了一点QT的绘图,因而乎照着学长的代码绘制了五子棋的小游戏。算法
最基础的东西这里就不说了,本身的知识也仅仅比会用多那么一点,下面咱们来讲说这里貌似高大上的人机AI吧。编程
评分表算法数组
通常状况下棋盘是15*15的。那么应该是572个五元组。而这五元组由黑棋白棋还有空格组成。也就是 3^5 * 572 = 138996; 看着不少吧,实际上是能够分类的。每一个五元组就是一种局势。.net
咱们只用统计只有己方棋子的局势,以及只有敌方棋子的局势,针对这两种局势给予肯定的评分,而其余局势直接评分为0。code
下面是我使用的是评分表
blog
// tuple is empty
Blank,
// tuple contains a black chess
B,
// tuple contains two black chesses
BB,
// tuple contains three black chesses
BBB,
// tuple contains four black chesses
BBBB,
// tuple contains a white chess
W,
// tuple contains two white chesses
WW,
// tuple contains three white chesses
WWW,
// tuple contains four white chesses
WWWW,
// tuple does not exist
Virtual,
// tuple co