资源简介
此次资源为期末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
相关资源
- 五子棋C 源代码
- 五子棋游戏实现悔棋功能
- labview设计的五子棋游戏(源码+文档)
- 超强五子棋软件 奕心2015
- AI五子棋训练棋谱
- 最强五子棋
- 基于S3C2410的触摸屏五子棋游戏毕业设
- 五子棋可单机双人,单机与电脑和局
- stm32实现的五子棋AI人机对战+人人对战
- 微信小程序--五子棋单机版
- VC五子棋毕业论文
- unity3D网络五子棋
- 弈心五子棋人工智能引擎
- 基于STM32的五子棋对战平台
- unity网络五子棋源代码
- 智能AI,QT五子棋
- AlphaGo Zero nature 论文
- 可判定禁手保存棋局的五子棋源码
- 用汇编编写的五子棋代码
- 五子棋实习报告五子棋实习报告
- 五子棋
- 五子棋(GoBang) 安卓APP 源码
- STM32五子棋游戏
- 蓝牙五子棋 安卓
- VC五子棋源代码 想要的速度下哦 多线
- 五子棋局域网对战 项目源码
- alphaZero五子棋
- 中国象棋和五子棋的算法讲解和vc源代
- 人机博弈 游戏源码解析以及基本搜索
- Google Deepmind AlphaGo原理解析完整54页
评论
共有 条评论