资源简介
设计的人工智能重力四子棋的对抗AI,实现了α-β剪枝和较好的估价算法,有不错的性能。

代码片段和文件信息
#include “Judge.h“
bool userWin(const int x const int y const int M const int N int* const* board){
//横向检测
int i j;
int count = 0;
for (i = y; i >= 0; i--)
if (!(board[x][i] == 1))
break;
count += (y - i);
for (i = y; i < N; i++)
if (!(board[x][i] == 1))
break;
count += (i - y - 1);
if (count >= 4) return true;
//纵向检测
count = 0;
for (i = x; i < M; i++)
if (!(board[i][y] == 1))
break;
count += (i - x);
if (count >= 4) return true;
//左下-右上
count = 0;
for (i = x j = y; i < M && j >= 0; i++ j--)
if (!(board[i][j] == 1))
break;
count += (y - j);
for (i = x j = y; i >= 0 && j < N; i-- j++)
if (!(board[i][j] == 1))
break;
count += (j - y - 1);
if (count >= 4) return true;
//左上-右下
count = 0;
for (i = x j = y; i >= 0 && j >= 0; i-- j--)
if (!(board[i][j] == 1))
break;
count += (y - j);
for (i = x j = y; i < M && j < N; i++ j++)
if (!(board[i][j] == 1))
break;
count += (j - y - 1);
if (count >= 4) return true;
return false;
}
bool machineWin(const int x const int y const int M const int N int* const* board){
//横向检测
int i j;
int count = 0;
for (i = y; i >= 0; i--)
if (!(board[x][i] == 2))
break;
count += (y - i);
for (i = y; i < N; i++)
if (!(board[x][i] == 2))
break;
count += (i - y - 1);
if (count >= 4) return true;
//纵向检测
count = 0;
for (i = x; i < M; i++)
if (!(board[i][y] == 2))
break;
count += (i - x);
if (count >= 4) return true;
//左下-右上
count = 0;
for (i = x j = y; i < M && j >= 0; i++ j--)
if (!(board[i][j] == 2))
break;
count += (y - j);
for (i = x j = y; i >= 0 && j < N; i-- j++)
if (!(board[i][j] == 2))
break;
count += (j - y - 1);
if (count >= 4) return true;
//左上-右下
count = 0;
for (i = x j = y; i >= 0 && j >= 0; i-- j--)
if (!(board[i][j] == 2))
break;
count += (y - j);
for (i = x j = y; i < M && j < N; i++ j++)
if (!(board[i][j] == 2))
break;
count += (j - y - 1);
if (count >= 4) return true;
return false;
}
bool isTie(const int N const int* top){
bool tie = true;
for (int i = 0; i < N; i++)
{
if (top[i] > 0)
{
tie = false;
break;
}
}
return tie;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2730 2011-10-22 00:22 重力四子棋\Judge.cpp
文件 2517 2011-10-22 00:22 重力四子棋\Judge.h
文件 503 2011-10-22 00:22 重力四子棋\Point.h
文件 12241 2012-12-05 11:49 重力四子棋\Strategy.cpp
文件 877 2012-12-04 17:13 重力四子棋\Strategy.h
目录 0 2012-12-17 11:00 重力四子棋
----------- --------- ---------- ----- ----
18868 6
- 上一篇:精易VIP模块4.30源码
- 下一篇:pic16f877a的跑马灯
相关资源
- 推箱子及人工智能寻路C 源代码
- 北航人工智能原理课大作业源代码,
- 双光子共振作为暗物质的重力介质
- N $$ \\ mathcal {N} $$ = 2个同质超重力的单
- N = 2 $$ \\ mathcal {N} = 2 $$超重力和部分
- 爱因斯坦-麦克斯韦-狄拉通重力中的李
- 陈-西蒙斯重力加速的FRW解决方案
- 精确地得出具有重力异常的二维手性
- 从11 + 3维流形上的Chern-Simons修正重力
- 关于Chern–Simons修正重力场中Taub
- 与重力相互作用的3 Chern–Simons的三
- Bosonic D = 11广义Chern–Simons动作的超
- d = 4时的Chern–Simons重力作用
- 3d N = 1 $$ \\ mathcal {N} = 1 $有效超重力和
- EGM2008重力模型计算器
- 使用半整数自旋发生器扩展Poinca
- AI人工智能学习资料全套
- 用户网络行为画像 大数据中的用户网
- 中科院自动化所历年模式识别博士题
- 华南理工大学人工智能期末考试卷
- LabVIEW实现Fuzzy_PID的补充资源
- 微信小程序Demo/---欧拉蜜自然语言理解
- 微信小程序完整Demo--支持人工智能对
- 艾媒-2017年中国人工智能产业专题研究
- 工信部人工智能产业人才岗位能力标
- AMiner:2018年人工智能之自动驾驶研究
- 艾瑞咨询:2018年中国人工智能+金融行
- 2019技术趋势:人工智能报告
- 法院行业方案宣讲稿-海康
- 8.2 心智探奇 人类心智的起源与进化
评论
共有 条评论