资源简介
此次资源为期末Tensorflow实战项目,实现了基本的人机对战、机机对战、有10*10-4*4规格,其中样本已经训练好,但是并不是很智能,大家可以自己训练。代码完整可运行,使用pycharm进行编写的
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Sun Apr 8 17:23:01 2018
@author: sjt
“““
import numpy as np
base = [1]
for i in range(1 300):
base.append(base[i - 1] * 3)
class chessboard(object):
def __init__(self length = 10 n_in_rows = 5):
#chessboard size
self.n_in_rows = n_in_rows
self.length = length
self.player = int(1)
self.board = np.zeros((self.length self.length)).astype(int)#0 empty 1 black 2 white
#valid moves
self.availables = set()
limit = self.length * self.length
for i in range(limit):
self.availables.add(i)
#direction for check
self.direction_x = [1 -1 1 -1 0 0 1 -1]
self.direction_y = [1 -1 -1 1 1 -1 0 0]
#value for hashing
self.hash_board = 0
#record the history board
self.excuted_step = 0
self.history1 = [] #record the history of first player
self.history2 = [] #record the history of second player both are in value 0 or 1
def change_player(self):
self.player = 3 - self.player
def position_to_index(self position):
return self.length * position[0] + position[1]
def index_to_position(self index):
return (index // self.length index % self.length)
def point_in_chessboard(self x y):
return x >= 0 and x < self.length and y >= 0 and y < self.length
def check_point(self position):
x = position[0]
y = position[1]
player = self.board[position]
for i in range(4):
cnt = 1
for j in range(1 self.n_in_rows):
dx = x + j * self.direction_x[i * 2]
dy = y + j * self.direction_y[i * 2]
#print(dx dy)
if (self.point_in_chessboard(dx dy) and self.board[(dx dy)] == player):
cnt = cnt + 1
#print(dx dy)
else:
break
for j in range(1 self.n_in_rows):
dx = x + j * self.direction_x[i * 2 + 1]
dy = y + j * self.direction_y[i * 2 + 1]
if (self.point_in_chessboard(dx dy) and self.board[(dx dy)] == player):
cnt = cnt + 1
else:
break
if cnt >= self.n_in_rows:
return True
return False
def get_state(self num_history):#need to see as current player
if self.player == 1:
state = [np.zeros_like(self.board)]
for i in range(1 num_history + 1):
#print(‘get_state‘ i)
if i < self.excuted_step:
state = np.concatenate((state [self.history1[-i]]))
state = np.concatenate((state [self.history2[-i]]))
else:
state = np.concatenate((state [np.zeros_like(self.board)]))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-01-10 16:30 五子棋\人工智障\
目录 0 2020-01-10 16:30 五子棋\人工智障\.idea\
文件 559 2019-12-25 16:45 五子棋\人工智障\.idea\Gobang-AlphaGo-Zero-master.iml
目录 0 2020-01-10 16:30 五子棋\人工智障\.idea\inspectionProfiles\
文件 174 2019-12-12 14:38 五子棋\人工智障\.idea\inspectionProfiles\profiles_settings.xm
文件 313 2019-12-12 14:39 五子棋\人工智障\.idea\misc.xm
文件 311 2019-12-12 14:38 五子棋\人工智障\.idea\modules.xm
文件 239 2019-12-25 16:45 五子棋\人工智障\.idea\other.xm
文件 20588 2019-12-30 14:40 五子棋\人工智障\.idea\workspace.xm
目录 0 2020-01-10 16:30 五子棋\人工智障\code\
目录 0 2020-01-10 16:30 五子棋\人工智障\code\__pycache__\
文件 3858 2019-12-17 23:19 五子棋\人工智障\code\__pycache__\chessboard.cpython-37.pyc
文件 6472 2019-12-21 19:41 五子棋\人工智障\code\__pycache__\interface.cpython-37.pyc
文件 3439 2019-12-19 08:23 五子棋\人工智障\code\__pycache__\policy_value_net.cpython-37.pyc
文件 3403 2019-12-21 01:27 五子棋\人工智障\code\__pycache__\pure_mcts.cpython-37.pyc
文件 3893 2019-12-21 00:39 五子棋\人工智障\code\__pycache__\real_mcts.cpython-37.pyc
文件 1771532 2019-12-20 01:51 五子棋\人工智障\code\best_policy.model.data-00000-of-00001
文件 1757 2019-12-20 01:51 五子棋\人工智障\code\best_policy.model.index
文件 142151 2019-12-20 01:51 五子棋\人工智障\code\best_policy.model.me
文件 145 2019-12-20 22:21 五子棋\人工智障\code\checkpoint
文件 5372 2019-12-17 23:17 五子棋\人工智障\code\chessboard.py
文件 1771532 2019-12-20 22:21 五子棋\人工智障\code\current_policy.model.data-00000-of-00001
文件 1757 2019-12-20 22:21 五子棋\人工智障\code\current_policy.model.index
文件 142151 2019-12-20 22:21 五子棋\人工智障\code\current_policy.model.me
文件 13068 2019-12-29 19:33 五子棋\人工智障\code\interface.py
文件 6672 2019-12-18 21:35 五子棋\人工智障\code\policy_value_net.py
文件 5736 2019-12-21 01:26 五子棋\人工智障\code\pure_mcts.py
文件 8380 2019-12-21 00:33 五子棋\人工智障\code\real_mcts.py
文件 13147 2019-12-21 19:41 五子棋\人工智障\code\train_pipeline.py
文件 4444 2018-07-21 08:51 五子棋\人工智障\README.md
文件 695695 2020-04-13 16:06 五子棋\五子棋实验报告.docx
............此处省略0个文件信息
- 上一篇:STC51指纹密码锁.rar
- 下一篇:白日门相关修改教程合集.zip
相关资源
- 蓝牙五子棋
- 安卓五子棋源码 可实现人机对战
- Deep Reinforcement Learning Hands-On pdf
- 五子棋fltk代码
- ARM9 Linux系统下的五子棋游戏
- 基于QT的五子棋系统
- 五子棋算法源码
- Qt编写局域网内五子棋对战
- 蓝牙对战五子棋(+文档).zip
- 阿尔法贝塔剪枝算法五子棋
- apicloud案例+五子棋+人机对战+人人对战
- 三个AI小游戏unity-五子棋、扫雷、Wu
- Visual Studio实现五子棋含人机对战
- 基于TCP协议的五子棋
- unity—五子棋源码
- 五子棋(人机,人人,联网)
- FPGAEGO1板五子棋.rar
- 剪枝算法五子棋源程序
- 网络课程设计基于Linux的五子棋游戏开
- 人工智能实验报告 五子棋游戏
- 五子棋人机博弈 游戏
- 使用socket实现的五子棋游戏
- 五子棋人机对战 图解 算法举例
- 五个汇编小程序,乘法表,俄罗斯方
- 五子棋程序_毕业设计报告
- IOS五子棋小
- 基于ALPHA-BETA算法的五子棋程序
- 简易五子棋qt实现
- 五子棋alphabeta
- 五子棋终结者
评论
共有 条评论