鱼C论坛

 找回密码
 立即注册
查看: 427|回复: 4

[技术交流] 五子棋游戏代码包

[复制链接]
发表于 2025-3-12 03:04:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
之前就一直想写一个人机对战五子棋,陆陆续续脱坑,今天终于实现部分代码,

我更希望渔友们一起使用检测,如果有逻辑错误,或者其他方面错误,给我留言反馈


确认你的python解释器安装好numpy,你可以使用下面命令,安装numpy库
  1. pip install numpy
复制代码


下面是使用demo,以及gomoku文件
gomoku.rar (165.94 KB, 下载次数: 1)
  1. from core import gomoku
  2. import numpy

  3. class Game:
  4.     def __init__(self):
  5.         self.board = []
  6.         self.ctx = gomoku.create_context()

  7.     @property
  8.     def cnt_bck(self):
  9.         """Return to the list of statistics for black chess patterns.
  10.         function specification::The function returns a list with an index representing the number of pieces of the same color, e.g.
  11.             result[3] indicates the number of 572 vectors on the board containing 3 pieces of the same color
  12.         """
  13.         return self.ctx.black_counts

  14.     @property
  15.     def cnt_wht(self):
  16.         """Return to the list of statistics for white chess patterns.
  17.         function specification::The function returns a list with an index representing the number of pieces of the same color, e.g.
  18.             result[3] indicates the number of 572 vectors on the board containing 3 pieces of the same color
  19.         """
  20.         return self.ctx.white_counts

  21.     def make_move(self, x: int, y: int, player: int):
  22.         """It takes 0.6825408935546875 s seconds to make a million calls
  23.         x: x coordinate
  24.         y: y coordinate
  25.         function specification:: Drop function, transfer coordinates (x,y) and identity
  26.             identifier player [1,-1]. 1 identifies blacks, -1 identifies whites
  27.         """
  28.         return self.ctx.make_move(x, y, player)

  29.     def undo_move(self):
  30.         """It takes 0.7378938106269836 s seconds to make a million calls
  31.         function specification::undo_move does not need to pass parameters, and the data of the previous step is undone
  32.         """
  33.         self.ctx.undo_move()

  34.     def get_sorted_moves(self, player: int, counts: int = 10):
  35.         """100W calls take 3.1213883638381956 s seconds
  36.         function specification::Get the points of the score and sort them according to the score. By default, 10 best hits are returned.
  37.             result[i] = {(x,y),score}
  38.         """
  39.         return self.ctx.get_sorted_moves(player, counts)

  40.     def is_over(self):
  41.         """Whether the game is over or not, Black returns 1 for a win and -1 for a White win. No end returns 0."""
  42.         if self.cnt_bck[5]:
  43.             return 1
  44.         if self.cnt_wht[5]:
  45.             return -1
  46.         return 0




复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-3-12 03:05:10 | 显示全部楼层
It looks like you are sharing a Gomoku (Five-in-a-Row) game implementation in Python and asking for feedback or improvements. Could you clarify what specific help you need? Are you looking for bug fixes, performance improvements, or additional features?

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2025-3-12 03:09:39 | 显示全部楼层
FishC 发表于 2025-3-12 03:05
It looks like you are sharing a Gomoku (Five-in-a-Row) game implementation in Python and asking for  ...

你会下载我的Gomoku包,帮我检测是否有逻辑错误吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2025-3-12 03:09:48 | 显示全部楼层
Stubborn 发表于 2025-03-12 03:09
FishC 发表于 2025-3-12 03:05
It looks like you ar ...


我无法直接下载和运行你的Gomoku包,但我可以帮助你检查代码的逻辑错误、优化代码结构,或者提供改进建议。你可以把完整的代码贴出来,我会帮你分析并指出可能的问题。

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2025-3-13 09:42:55 | 显示全部楼层
6666666666666666666
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-5 19:35

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表