lihongxun945 / gobang Goto Github PK
View Code? Open in Web Editor NEWjavascript gobang AI,JS五子棋AI,源码+教程,基于Alpha-Beta剪枝算法(不是神经网络)
Home Page: http://gobang2.light7.cn/
javascript gobang AI,JS五子棋AI,源码+教程,基于Alpha-Beta剪枝算法(不是神经网络)
Home Page: http://gobang2.light7.cn/
假设,按照你说的,每层搜索的棋子是50个,每个棋子go之后,需要更新空白的点分别机器和人computer[][]和human[][]在该处的得分,这个计算过程,我这边非常耗时,我粗略的估算了一下,这个更新的计算量:8(个方向) * 8 (每个方向的棋子,只算空白位置)* 2 (人和机器)* 4(个方向)(9) = 受影响的空白棋数量 * 2 (角色) (点评估算法)= 4608 ,这个常数可不能忽略。
所以,我这样更新每次计算出来都非常慢,慢到最后需要1分钟才能计算出结果,而且我的deep = 2,还只是评估2步,所以我想请教你,你是如何看
npm install 之后,npm test,npm run js。。。。全部都无法执行?在package.json文件里只找到了:
"scripts": {
"build": "tsc --build",
"clean": "tsc --build --clean",
"start": "node app"
},
这三个可执行语句。
但是运行npm run build 后显示:
npm run build
[email protected] build
tsc --build
error TS5083: Cannot read file 'D:/****/五子棋/gobang-master 2/gobang-master/gobang-master/tsconfig.json'.
Found 1 error.
你好,我之前按照你博客的思路有实现过python的版本。刚刚又和你最新(2018/07/07)的版本下过一局,我执黑在角落开局,最终赢下了比赛(我是休闲玩家,很多名词比如算杀都是在这次写AI的时候才第一次听说)。我就是一路感觉下来,基于极大极小搜索的AI引擎好像对于这种“角落开局”,会陷入一种困境——进行无意义冲四、往边上下、等等一些非常“愚蠢”的下法,最终就导致其棋力下降(如果我执黑在中间下的话是很难赢的。。)。
不知道作者你有没有思考过这个问题,如有想法,还请赐教!谢谢!
I placed the first chess far away from the center, the computer thought for a long time until I couldn't wait for it.
请各位大佬批评指点
击败了
interface P extends Partial<number[]> {
role?: number;
scoreCom?: number;
scoreHum?: number;
}
这样的吗?
当x xxx x empty=count-1
你的代码:
if (empty === 1 || empty == count - 1) {
//第1个是空位
if (count >= 6) {
return score.FIVE;
}
if (block === 0) {
switch (count) {
case 2:
return score.TWO / 2;
case 3:
return score.THREE;
case 4:
return score.BLOCKED_FOUR;
case 5:
return score.FOUR;
}
}
但这个不是稳赢的吗
目前程序异常,走棋后,程序不会继续运行
还需要改进哦。五子棋的正式规则好像很复杂,否则先行的有较大优势。
我发现点开始电脑就开始下了, 怎么能让玩家先手
大佬遇到过吗?希望大佬能指导一下
10 passing (25s)
7 failing
测试的时候碰到的Bug
冲四双三不能赢,因为对手可以冲四防双三,bug:
AssertionError: expected false to be true
-false
+true
at Context. (dist/main.bundle.js:1931:135)
at processImmediate (internal/timers.js:464:21)
测试 gen 函数
应该能生成冲四防守点:
AssertionError: expected false to be true
-false
+true
at Context. (dist/main.bundle.js:2031:145)
at processImmediate (internal/timers.js:464:21)
开局测试
测试浦月开局:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Library/WebServer/Documents/wzq/dist/main.bundle.js)
at processImmediate (internal/timers.js:464:21)
测试Star路径的bug
[6, 4] 能赢:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Library/WebServer/Documents/wzq/dist/main.bundle.js)
at processImmediate (internal/timers.js:464:21)
Test Time
无意义冲四过多的时候会不会很慢:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Library/WebServer/Documents/wzq/dist/main.bundle.js)
at processImmediate (internal/timers.js:464:21)
Test Time
此处有杀棋, 只有 [6, 5], [5, 4] 两种走法有杀棋:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Library/WebServer/Documents/wzq/dist/main.bundle.js)
at processImmediate (internal/timers.js:464:21)
非常长的时间
由于活三冲四太多,导致思考非常久:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Library/WebServer/Documents/wzq/dist/main.bundle.js)
at processImmediate (internal/timers.js:464:21)
MOCHA Tests completed with 7 failure(s)
ERROR mocha-webpack exited with code 7.
npm ERR! Test failed. See above for more details.
老师,你现在还在维护这个吗,这个程序现在存在个问题,就是只要是AI先手,点击开始,这里盘面是不会清理的。
evaluate-point.js中220行
if(empty == -1 && (x<len-1 && y<len-1) && board[x+1][y-1] == role)
应该写成
if (empty == -1 && (x < len - 1 && y > 0) && board[x + 1][y - 1] == role)
类似地,244行
if(empty == -1 && (x>0 && y>0) && board[x-1][y+1] == role)
应该写成
if (empty == -1 && (x > 0 && y < len - 1) && board[x - 1][y + 1] == role)
题主可否给个接口调用一下啊
npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: [email protected]
使用的是win10 ubuntu18.04子系统
博主,请问哪个是最终版本啊,就是最新网页那种效果的
玩家先手,默认设置,玩家31手已经走出五子本应获胜,但是未判定玩家获胜,而是32手电脑走出5子,也不判定电脑获胜,34手电脑走出6子判了电脑获胜
另外demo无法访问了,http://gobang.light7.cn/
您好,想请教一下棋子的位置是如何计算出来的?
Board.vue 15行:
style="{ marginTop: (1.5 + rowIndex*6.53) + '%', marginLeft: (1.5 + cIndex*6.53) + '%', }"
Board.vue 57行:
offset = width*0.044, step = width*0.065;
上面代码里面的1.5,6.53,0.044,0.065
这些值是如何计算出来的呢?
发现一开始把棋子下到角落里面电脑要思考好久哎
evaluate-point.js 里面的 countToScore 的 empty 是代表什么?我这里不太理解
白棋第一手着在某个范围外会报错。比如游戏开始后,白棋第一着落在棋盘外围边界或者附近,程序就会报错
在使用vscode搭建vue环境时 .npm install 会一直出错,可以请教一下如何解决嘛,错误提示如下
PS C:\Users\yf-wyr\Desktop\Wuziqi> npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated [email protected]: Critical bug fixed in v3.0.1, please upgrade to the latest version.
npm WARN deprecated [email protected]: Critical bug fixed in v2.0.1, please upgrade to the latest version.
npm WARN deprecated [email protected]: update to [email protected]
npm WARN deprecated [email protected]: Critical bug fixed in v3.0.1, please upgrade to the latest version.
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is
available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated [email protected]: Please use the native JSON object instead of JSON 3
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see request/request#3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is
available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: use String.prototype.padStart()
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi
support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: 3.x is no longer supported
npm WARN deprecated [email protected]: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi
support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi
support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi
support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated [email protected]: support for ECMAScript is superseded by uglify-js
as of v3.13.0
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is
available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is
available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see axios/axios#3410
npm WARN deprecated [email protected]: This version of 'buffer' is out-of-date. You must update to
v4.9.2 or newer
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old
core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\Program Files\nodejs\node.exe',
npm ERR! gyp verb cli 'C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-gyp\bin\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb which
failed Error: not found: python2
npm ERR! gyp verb which
failed at getNotFoundError (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:13:12)
npm ERR! gyp verb which
failed at F (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:68:19)
npm ERR! gyp verb which
failed at E (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:80:29)
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:89:16
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which
failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb which
failed python2 Error: not found: python2
npm ERR! gyp verb which
failed at getNotFoundError (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:13:12)
npm ERR! gyp verb which
failed at F (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:68:19)
npm ERR! gyp verb which
failed at E (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:80:29)
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\which\which.js:89:16
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which
failed at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which
failed at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb which
failed code: 'ENOENT'
npm ERR! gyp verb which
failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb which
succeeded python C:\Python310\python.EXE
npm ERR! gyp verb check python version C:\Python310\python.EXE -c "import platform; print(platform.python_version());"
returned: "3.10.2\r\n"
npm ERR! gyp verb could not find "C:\Python310\python.EXE". checking python launcher
npm ERR! gyp verb could not find "C:\Python310\python.EXE". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "C:\Python310\python.EXE", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack at PythonFinder.failNoPython (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-gyp\lib\configure.js:492:19)
npm ERR! gyp ERR! stack at PythonFinder. (C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-gyp\lib\configure.js:517:16)
npm ERR! gyp ERR! stack at C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\graceful-fs\polyfills.js:284:29
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.18363
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\yf-wyr\Desktop\Wuziqi\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v3.7.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Program Files\nodejs\node_cache_logs\2022-03-09T03_23_41_490Z-debug-0.log
PS C:\Users\yf-wyr\Desktop\Wuziqi>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.