• 大小: 3.7M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-15
  • 语言: 其他
  • 标签: 其他  

资源简介

3878872wuziqi.zip

资源截图

代码片段和文件信息

#--coding:utf-8--
from PIL import Image 
import pygame as pg
#from pygame.locals import *#导入一些常用的函数和常量
from sys import exit #用exit来退出程序
import easygui 
import gloval 
import random
gloval.init()
##打分表
tuple_score=[None]*10
tuple_score[0]=7                #没有子
tuple_score[1]=35 #一个己方子
tuple_score[2]=800 #两个己方子
tuple_score[3]=15000 #三个己方子
tuple_score[4]=800000 #四个己方子
tuple_score[5]=15 #一个对方子
tuple_score[6]=400 #两个对方子
tuple_score[7]=8000 #三个对方子
tuple_score[8]=100000 #四个对方子
tuple_score[9]=0 #又有白又有黑

##计算一个空位的分数(需要棋谱数组和空位位置,返回该位置的分数)
def chess_score(arraychess_poswhiteround):
pos_score=0
x=chess_pos[0]
y=chess_pos[1]
black_num=0
white_num=0
##竖列
for i in range(5):#1234  统计竖列所有五元组的得分总和
for j in range(5):#01234 统计一个五元组的得分
if [x-j+iy] in array[::2]:#黑子判断 #横向
black_num+=1
if [x-j+iy] in array[1::2]:#白子判断 #横向
white_num+=1
pos_score=pos_score+chess_tuple_score(black_num white_numwhiteround)#计算一个元组
white_num=0
black_num=0
##横列
for i in range(5):
for j in range(5):
if [xy-j+i] in array[::2]:#黑子判断 #横向
black_num+=1
if [xy-j+i] in array[1::2]:#白子判断 #横向
white_num+=1
pos_score=pos_score+chess_tuple_score(black_num white_numwhiteround)
white_num=0
black_num=0
##左斜/
for i in range(5):
for j in range(5):
if [x+j-iy-j+i] in array[::2]:#黑子判断 #横向
black_num+=1
if [x+j-iy-j+i] in array[1::2]:#白子判断 #横向
white_num+=1
pos_score=pos_score+chess_tuple_score(black_num white_num whiteround)
white_num=0
black_num=0
##右斜\
for i in range(5):
for j in range(5):
if [x-j+iy-j+i] in array[::2]:#黑子判断 #横向
black_num+=1
if [x-j+iy-j+i] in array[1::2]:#白子判断 #横向
white_num+=1
pos_score=pos_score+chess_tuple_score(black_num white_num whiteround)
white_num=0
black_num=0
return pos_score


##计算每一个五连
def chess_tuple_score(black_numwhite_numwhiteround):
if black_num==0 and white_num==0:  #没有子
pos_tuple_score=tuple_score[0]
elif black_num>0 and white_num>0:  #又有白又有黑
pos_tuple_score=tuple_score[9]
else:                              #只有黑或者只有白
if whiteround == -1:
if black_num != 0: #计算横着一格黑子
pos_tuple_score=tuple_score[black_num]
if white_num != 0: #计算横着一格白子
pos_tuple_score=tuple_score[white_num+4]
if whiteround == 1:
if black_num != 0: #计算横着一格黑子
pos_tuple_score=tuple_score[black_num+4]
if white_num != 0: #计算横着一格白子
pos_tuple_score=tuple_score[white_num]
return pos_tuple_score


##寻找棋盘上分数最高的空格返回bestpos最佳位置
def find_maxscore(arraywhiteround):
if array==[]:
best_pos=[88]
else:
chess_score_array=[]
for row in range(115):
for col in range(115):
chess_pos = [rowcol]
if chess_pos not in array:
pos_score=chess_score(arraychess_poswhiteround)
chess_score_array.append([pos_score row col])
chess_score_array.sort(reverse=True)

#随机落子
if chess_score_array[0][0]-chess_score_array[2][0]<50:
choose_pos=random.randint(02)

elif chess_score_array[0][0]-che

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件           0  2019-03-14 11:05  Cheney_wuziqi鐨勫壇鏈?
     文件        1753  2019-04-07 20:27  Cheney_wuziqi鐨勫壇鏈?judgewin.py
     目录           0  2019-06-17 02:11  __MACOSX\
     文件           0  2019-06-17 02:11  __MACOSX\Cheney_wuziqi鐨勫壇鏈?
     文件         385  2019-04-07 20:27  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._judgewin.py
     文件         567  2019-03-14 11:20  Cheney_wuziqi鐨勫壇鏈?chesswhite.png
     文件         268  2019-03-14 11:20  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._chesswhite.png
     文件         130  2019-03-16 12:37  Cheney_wuziqi鐨勫壇鏈?gloval.py
     文件         542  2019-03-16 12:37  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._gloval.py
     文件      301380  2019-03-15 03:44  Cheney_wuziqi鐨勫壇鏈?menu.gif
     文件         531  2019-03-15 03:44  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._menu.gif
     文件        6148  2019-06-17 01:49  Cheney_wuziqi鐨勫壇鏈?.DS_Store
     文件         120  2019-06-17 01:49  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._.DS_Store
     文件     1158341  2019-06-14 18:09  Cheney_wuziqi鐨勫壇鏈?csdn.gif
     文件         323  2019-06-14 18:09  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._csdn.gif
     文件        4281  2019-03-14 11:03  Cheney_wuziqi鐨勫壇鏈?20170814184315173.png
     文件         268  2019-03-14 11:03  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._20170814184315173.png
     文件         912  2019-06-17 00:46  Cheney_wuziqi鐨勫壇鏈?new_chessblack.png
     文件       49201  2019-03-14 11:02  Cheney_wuziqi鐨勫壇鏈?background.jpeg
     文件         490  2019-03-14 11:02  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._background.jpeg
     文件     3730468  2018-12-26 11:07  Cheney_wuziqi鐨勫壇鏈?mufont.ttf
     文件         212  2018-12-26 11:07  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._mufont.ttf
     目录           0  2019-03-16 10:32  Cheney_wuziqi鐨勫壇鏈?__pycache__\
     文件         490  2019-03-16 12:37  Cheney_wuziqi鐨勫壇鏈?__pycache__\gloval.cpython-37.pyc
     文件        2343  2019-04-27 18:14  Cheney_wuziqi鐨勫壇鏈?__pycache__\easy_pc.cpython-37.pyc
     文件        1335  2019-06-15 15:55  Cheney_wuziqi鐨勫壇鏈?__pycache__\windows.cpython-37.pyc
     文件        9950  2019-04-27 13:15  Cheney_wuziqi鐨勫壇鏈?__pycache__\menu.cpython-37.pyc
     文件        1728  2019-04-07 20:29  Cheney_wuziqi鐨勫壇鏈?__pycache__\judgewin.cpython-37.pyc
     文件       43777  2019-03-14 11:04  Cheney_wuziqi鐨勫壇鏈?chessboard.jpeg
     文件         268  2019-03-14 11:04  __MACOSX\Cheney_wuziqi鐨勫壇鏈?._chessboard.jpeg
     文件         912  2019-03-14 11:19  Cheney_wuziqi鐨勫壇鏈?chessblack.png
............此处省略17个文件信息

评论

共有 条评论