鱼C论坛

 找回密码
 立即注册
查看: 477|回复: 10

[原创] 斗地主

[复制链接]
发表于 2024-1-23 16:39:09 | 显示全部楼层 |阅读模式

找到一个以前突发奇想写的斗地主的程序,就给大伙发来看看,包含发牌:54张牌分别发三份,玩家出牌,以及控制两个电脑进行出牌(电脑跟托管差不多判断有大就出)
以下是运行程序:首先是随机选取地主,并且电脑出牌,显示玩家的牌,并且玩家进行出牌

                               
登录/注册后可看大图

玩家进行出牌

                               
登录/注册后可看大图


                               
登录/注册后可看大图

最后牌出完判断输赢

                               
登录/注册后可看大图

由于代码时间久远,应该还有一些bug(应该是关于判定出牌的问题)但懒得改了
整体代码放不下了就简单放一个电脑进行出牌判定的代码吧,大概就是判断出牌是啥,判断手牌有啥,打得过就出,其中判断手牌的函数比如单张,对子四带二飞机等等就不一一列出了
# 参数:
# 列表array       玩家的牌
# 列表last_cart   上次出牌  上次出牌默认符合规则
# 作用  判断 AI 本次应该出什么类型的牌
def count(array,last_cart,name):
    # print(last_cart,'666666666666')
    # 顺子和联对 比较特殊  就不按张数算了
    # print(last_cart,'6666')
    temp_list = delete_symbol(last_cart) # 去符号  因为jug_array函数不要符号
   
    # print(temp_list)
    if jug_array(temp_list) == 0:#顺子
        return straight(array,last_cart,name)
    elif Even_for(temp_list) == 0: # 连对
        return paired_count(array,last_cart,name)
    elif judge_airplane(temp_list) == 0:#干捞飞机
        return airplane_0(array,last_cart,name)
    elif judge_airplane(temp_list) == 1:#飞机带单
        return airplane_1(array,last_cart,name)
    elif judge_airplane(temp_list) == 2:#飞机带队
        return airplane_2(array,last_cart,name)

    else:
        if last_cart == []:#全都不要的时候的机器出牌
            return singel_count(array,last_cart,name)
        elif len(last_cart) == 1:# 出单
            return singel_count(array,last_cart,name)
        elif len(last_cart) == 2:# 出对子
            return double_count(array,last_cart,name)
        elif len(last_cart) == 3:# 出三张
            return triple_count(array,last_cart,name)
            

        elif len(last_cart) == 4:
            a = sort_array(last_cart) # 变成数字 按照大小 排列  如:[3,3,3,2]
            if a[zxsq-anti-bbcode-0][1:] == a[-1][1:]: # 说明是炸弹
                return has_boom(array,last_cart,name)
            elif a[zxsq-anti-bbcode-0][1:] != a[-1][1:]:# 说明是三代一
                return three_with_one(array,last_cart,name)

        elif len(last_cart) == 5:
            # a = sort_array(last_cart) # 变成数字 按照大小 排列  如:[3,3,3,2,2]    sort 会吃数组 先不用了
            a = last_cart
            #
            if ((a[zxsq-anti-bbcode-2][1:] != a[zxsq-anti-bbcode-3][1:]) and (a[zxsq-anti-bbcode-0][1:] == a[zxsq-anti-bbcode-1][1:])) or ((a[zxsq-anti-bbcode-2][1:] != a[zxsq-anti-bbcode-3][1:]) and (a[-1][1:] == a[-2][1:])):
                # 说明是 三代二
                return three_with_two(array,last_cart,name)
            else:
                print('你来到了奇怪的地方   ugsiduhoi')

        elif len(last_cart) == 6:
            # a = sort_array(last_cart) # 变成数字 按照大小 排列  如:[3,3,3,2,2]
            a = last_cart
            if (a[zxsq-anti-bbcode-2][1:] == a[zxsq-anti-bbcode-3][1:]) and ((a[zxsq-anti-bbcode-0][1:] != a[zxsq-anti-bbcode-1][1:]) or (a[zxsq-anti-bbcode-0][1:] != a[-1][1:]) or (a[-1][1:] != a[-2][1:])):
                # 说明是四代二单   [6,7,8,8,8,8] [6,8,8,8,8,9] [8,8,8,8,9,K]
                # print('这里是四代二')
                return four_with_1(array,last_cart,name)
            else:
                print('不要进来!淦')
                pass

        elif len(last_cart) == 8:#四代对
            return four_with_2(array,last_cart,name)

        else:
            return -1



购买主题 已有 2 人购买  本主题需向作者支付 10 鱼币 才能浏览
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-23 18:08:37 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-23 19:28:53 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-28 12:26:03 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-28 17:36:39 | 显示全部楼层

回帖奖励 +1 鱼币

厉害
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-29 10:49:44 | 显示全部楼层

回帖奖励 +1 鱼币

感谢大佬的馈赠
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-1-29 21:06:37 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-29 21:10:00 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-1-31 22:01:38 | 显示全部楼层

回帖奖励 +1 鱼币

评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +3 收起 理由
python爱好者. + 5 + 5 + 3 鱼C有你更精彩^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-2-1 11:19:15 | 显示全部楼层

回帖奖励 +1 鱼币

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-3-12 22:12:39 From FishC Mobile | 显示全部楼层
6
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-14 05:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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