鱼C论坛

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

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

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

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

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

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

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


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

下面是使用demo,以及gomoku文件
gomoku.rar (165.94 KB, 下载次数: 1)
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[3] 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[3] 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,-1]. 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[i] = {(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[5]:
            return 1
        if self.cnt_wht[5]:
            return -1
        return 0
想知道小甲鱼最近在做啥?请访问 -> 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 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> 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包,帮我检测是否有逻辑错误吗?
想知道小甲鱼最近在做啥?请访问 -> 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 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2025-3-13 09:42:55 | 显示全部楼层
6666666666666666666
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-4-2 02:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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