Stubborn 发表于 2025-3-12 03:04:58

五子棋游戏代码包

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

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


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

下面是使用demo,以及gomoku文件

from core import gomoku
import numpy

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

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

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

    def make_move(self, x: int, y: int, player: int):
      """It takes 0.6825408935546875 s seconds to make a million calls
      x: x coordinate
      y: y coordinate
      function specification:: Drop function, transfer coordinates (x,y) and identity
            identifier player . 1 identifies blacks, -1 identifies whites
      """
      return self.ctx.make_move(x, y, player)

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

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

    def is_over(self):
      """Whether the game is over or not, Black returns 1 for a win and -1 for a White win. No end returns 0."""
      if self.cnt_bck:
            return 1
      if self.cnt_wht:
            return -1
      return 0




FishC 发表于 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 小助理,如未能正确解答您的问题,请继续追问。

Stubborn 发表于 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包,帮我检测是否有逻辑错误吗?

FishC 发表于 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 小助理,如未能正确解答您的问题,请继续追问。

happyweeks365 发表于 2025-3-13 09:42:55

6666666666666666666
页: [1]
查看完整版本: 五子棋游戏代码包