资源简介
用tensorflow写的麻将智能出牌的打码,实现传入手牌后自动选择应该出的牌。
代码片段和文件信息
import copy
import argparse
import xml.etree.ElementTree as ET
import os
class GameRecord:
def __init__(self):
self.record = [None for i in range(4)]
self.outrecord = []
self.total = []
def write_out(self filename):
with open(filename mode=“w“ encoding=“utf-8“) as f:
for r in self.total:
f.write(“{0}\n“.format(r))
def read_one(self child):
#U E 1
#V F 2
#W G 3
#T D 0
fmu = child.tag[0:1]
#print(child.tag fmu)
if child.tag == ‘GO‘:
return
if child.tag == ‘UN‘:
return
if child.tag == ‘TAIKYOKU‘:
return
if child.tag == ‘DORA‘:
return
if child.tag == ‘INIT‘:
#self.total.append(self.record)
self.record = [None for i in range(4)]
self.record[0] = self.get_card_from_string(child.attrib[‘hai0‘])
self.record[1] = self.get_card_from_string(child.attrib[‘hai1‘])
self.record[2] = self.get_card_from_string(child.attrib[‘hai2‘])
self.record[3] = self.get_card_from_string(child.attrib[‘hai3‘])
if fmu == ‘U‘:
c = child.tag[1:len(child.tag)]
#print(“玩家1 摸牌:{0}“.format(c))
self.in_card(self.record[1] int(c))
if fmu == ‘E‘:
c = child.tag[1:len(child.tag)]
#print(“玩家1 出牌:{0} {1}“.format(c self.get_out_string(self.record[1] int(c))))
self.total.append(self.get_out_string(self.record[1] int(c)))
self.out_card(self.record[1] int(c))
if fmu == ‘V‘:
c = child.tag[1:len(child.tag)]
#print(“玩家2 摸牌:{0}“.format(c))
self.in_card(self.record[2] int(c))
if fmu == ‘F‘:
c = child.tag[1:len(child.tag)]
#print(“玩家2 出牌:{0} {1}“.format(c self.get_out_string(self.record[2] int(c))))
self.total.append(self.get_out_string(self.record[2] int(c)))
self.out_card(self.record[2] int(c))
if fmu == ‘W‘:
c = child.tag[1:len(child.tag)]
#print(“玩家3 摸牌:{0}“.format(c))
self.in_card(self.record[3] int(c))
if fmu == ‘G‘:
c = child.tag[1:len(child.tag)]
#print(“玩家3 出牌:{0} {1}“.format(c self.get_out_string(self.record[3] int(c))))
self.total.append(self.get_out_string(self.record[3] int(c)))
self.out_card(self.record[3] int(c))
if fmu == ‘T‘:
c = child.tag[1:len(child.tag)]
#print(“玩家0 摸牌:{0}“.format(c))
self.in_card(self.record[0] int(c))
if fmu == ‘D‘:
c = child.tag[1:len(child.tag)]
#print(“玩家0 出牌:{0} {1}“.format(c self.get_out_string(self.record[0] int(c))))
self.total.append(self.get_out_string(self.record[0] int(c)))
self.out_card(self.record[0] int(c))
if child.tag == ‘N‘:
#print(“玩家 鸣牌“)
who = int(child.attrib[‘who‘])
other = int(child.attrib[‘m‘]) & 3
ischi = (int(child.attrib[‘m‘]) >> 2) & 1
ispen = (int(child.attrib[‘m‘]) >> 3) & 1
isgang = (int(child.attrib[‘m‘]) >> 3) & 3
if ischi == 1:
out = (int(child.attrib[‘m‘]) >> 10) & 63
_k = int(out / 3)
_h = int(out % 3)
_v = int(_k % 7)
_c = int(_k / 7)
_ot = _c * 36 + _v * 4
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7913 2018-07-24 16:19 gen.py
文件 10657 2018-07-24 16:34 mahjong_ai.py
文件 21879 2018-05-06 09:51 mahjong_common.py
文件 19355 2018-07-18 21:04 mahjong_common.pyc
文件 5671 2018-07-19 21:35 mahjong_generator.py
文件 2099 2018-05-06 09:51 mahjong_loader.py
文件 2183690 2018-07-25 10:31 dahai_data.txt
相关资源
- TensorFlow1.4 官方手册
- pip-10.0.1.tar.gz
- Data Science from Scratch 2nd Edition
- shape_predictor_68_face_landmarks.dat.bz2 68个标
- 爬取豆瓣电影TOP250程序,包含非常详
- 齐齐哈尔麻将游戏源码
- 中文维基百科语料库百度网盘网址.
- MSCNN_dehaze.rar
- 基于双向LSTM+tensorflow中文分词
- 爬取豆瓣排行榜电影数据(含GUI界面
- 字典文本资源
- Brainfuck / OoK 解码脚本
- 案例实战信用卡欺诈检测数据集
- TensorFlow Machine Learning Cookbook+无码高清
- Hands-On Machine Learning with Scikit-Learn an
- TensorFlow 官方文档中文版高清无码PD
- 招商策略_抱团启示录那些年我们一起
- sip-4.19.zip
- 树莓派3b+学习使用教程
- numpy 中文学习手册
- pytorch-1.4.0-py3.7_cpu_0.tar.bz2
- 机器学习实战 高清完整版PDF
- 泰坦尼克号0.81准确率实验报告.docx
- 基于tensorflow的深度学习图像分类案例
-
abaqus sc
ripting reference manual.pdf - 基于Tensorflow多层神经网络的MNIST手写
- 网页版聊天程序--网络程序设计课程大
- Give Me Some Credit
- TensorFlow Tutorial
-
ba
semap安装出错时,正确得pyproj文件
评论
共有 条评论