资源简介
国际麻将AI-根据向听数计算最优操作,用python写的。适合做棋牌的人参考。
代码片段和文件信息
#-*- coding: utf-8 -*-
from BasicDefinition import CardIndex
import mahjong
class Agent :
def __init__(selfplayer_number):
self.playerNumber = player_number
self.reset()
def reset(self):
self.handcard = None
self.cardsOnBoard = [[][][][]]
self.cardsThrowed = [[][][][]]
self.cardsThrowedNoTaken = []
self.cardOpened = []
self.wind =None
def setAction(selfaction):
self.action = action
def goalTest(self):
s1 = [] #distinguish 4 color
s2 = []
s3 = []
s4 = []
self.handcard.sort()
combination = []
for card in self.handcard:
if 1 <= card <= 9:
s1.append(card)
elif 11 <= card <=19:
s2.append(card)
elif 21 <= card <= 29:
s3.append(card)
else:
s4.append(card)
s = [s1s2s3]
twoPair = 0
while len(s4) != 0:
count = s4.count(s4[0])
if count == 3:
combination.append([s4[0]]*3)
s4 = s4[3:]
elif count == 2:
if twoPair == 0:
twoPair += 1
combination.append([s4[0]]*2)
s4 = s4[2:]
else:
return FalseNone
else:
return FalseNone
for color in s:
if len(color) != 0:
## 整除
if len(color) % 3 == 0:
while len(color) != 0:
first = color[0]
## 檢查碰
if color[1] == first:
if color[2] == first:
color = color[3:]
combination.append([first]*3)
else:
return FalseNone
## 檢查順子
elif color[1] == first + 1:
if first + 2 in color:
color.remove(first + 2)
color = color[2:]
combination.append([firstfirst+1first+2])
else:
return FalseNone
else:
return FalseNone
## 可能有pair
elif len(color) % 3 == 2:
if twoPair != 0:
return FalseNone
else:
i = 0
correct1 = False
while i < len(color):
count = color.count(color[i])
## 某類牌有2 3 4張在手上
if count > 1:
temp = color[:]
tempCombination = [[temp
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-03 17:11 MahjongAI\
文件 1059 2017-01-17 02:20 MahjongAI\.gitignore
文件 12513 2017-01-17 02:20 MahjongAI\Agent.py
文件 1893 2017-01-17 02:20 MahjongAI\BasicDefinition.py
文件 5862 2017-01-17 02:20 MahjongAI\Counter.py
文件 21646 2017-01-17 02:20 MahjongAI\evalScore.py
文件 23740 2017-01-17 02:20 MahjongAI\learningAgent.py
文件 40084 2017-07-06 11:10 MahjongAI\mahjong.py
文件 1694 2017-01-17 02:20 MahjongAI\main.py
文件 1801 2017-01-17 02:20 MahjongAI\README.md
文件 6074 2017-01-17 02:20 MahjongAI\scoreRules
文件 2243 2017-06-29 12:16 MahjongAI\SimpleAction.py
文件 17689 2017-01-17 02:20 MahjongAI\SimpleAgent.py
文件 15152 2017-01-17 02:20 MahjongAI\Table.py
文件 8620 2017-01-17 02:20 MahjongAI\train_main.py
文件 6341 2017-01-17 02:20 MahjongAI\util.py
- 上一篇:爬取瓜子二手车.py
- 下一篇:python摄像头视频显示到TK窗口
相关资源
- python+pyqt5+百度AI+车牌识别.rar
- python3.5 百度ai人脸识别
- GENERATIVE_ADVERSARIAL_NETWORKS_COOKBOOK
- 深度学习入门:基于Python的理论与实
- [PDF] Reinforcement Learning With Open AI Tens
- aircraft battle.zip
- Pillow-3.4.2-cp36-cp36m-win_amd64.whl python3
- Deep Learning with Python 原版PDF by Choll
- chainerrl 在Chainer之上,ChainerRL是一个深
- python aiml web 聊天机器人
- 卷积神经网络的Python实现 -《卷积神经
- hog_svm_train_python
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- python调用dlib库实现简单的人脸识别
- Packt.Python.Artificial.Intelligence.Projects.
- 深度学习入门:基于Python的理论与实
- python深度学习(Chollet中文版)
- Python-mathAI一个拍照做题程序输入一张
- Multi-Devices.rar
- 深度学习入门:基于Python的理论与实
- Python-Tensorflow实现SpatialAsDeepSpatialCNN
- python版本消消乐
- Reinforcement Learning - With Open AI TensorFl
- 文字版pdf书和源代码:深度学习入门
- Python强化学习实战:应用OpenAI Gym和
- Python-使用遗传算法和深度学习训练
- Python机器学习及实践高清
- Introduction to Machine Learning with Python 原
- Python3.5CongLingKaiShiXue-LiuYuZhou.pdf
- Deep Learning for Computer Vision Expert techn
评论
共有 条评论