python百行代码编码摇骰子模拟器(告诫网du)
发布日期:2021-06-29 18:19:16 浏览次数:2 分类:技术文章

本文共 7668 字,大约阅读时间需要 25 分钟。

有话说

该摇骰子项目起初只是想演示一下所谓的倍压法是否有效,实际测试中也发现如果运气够好的话倍押法是一种比较好的回本方式,但是前提是你有足够的本,如果运气一直差的话最后也会输的啥都不剩,而这一切的前提是你所谓的赌都是处于正常模式下,就是每个概率都是公平的。但是如果du的平台做了一点手脚,那么,别说倍压法回本,倾家荡产只是一瞬间的事。

所以,别相信所谓的网du,里面的水不知道有多深,而我只是尝试了一些小东西,往往搞这些du平台的多多少少熟知一些人的正常心理,比如先给你点甜头,后面再慢慢宰。

本来打算用此做一次大数据实验这个所谓的倍押法的,但是由于上班基本没多少时间,周末又不想动,所以当编码完成后做了一两次实验我就没动过了,结果显而易见,最好的回本方法就是碰都不要碰这些所谓的网du,就算上头了一次了,及时悬崖勒马,及时止损是最好的办法。

整体逻辑

  1. 初始金币
  2. 获得押注
  3. 扣除押注
  4. 随机出现点数,大:小于9点,小:大于9点
  5. 根据押注获得比例,压中大小:2倍。顺子:3倍,豹子:6倍。
  6. 上帝模式:这个是我临时想起来的,做一点手脚后,根本没赢的可能,最好的押注就是平手,而逻辑就是简单的判断你的押注,反向给你出点数,使得你的押注是不可能盈利的。

整体界面演示

在这里插入图片描述

上帝模式(不可能赢)

在这里插入图片描述

整体代码

#!/usr/bin/env python# -*- coding: utf-8 -*-# @Time    : 2020/12/17 20:02# @Author  : Cxk# @File    : 摇塞子模拟.py# @文件下载地址 http://www.cxkboke.top/phone_win_file/%E6%91%87%E9%AA%B0%E5%AD%90%E6%A8%A1%E6%8B%9F.zipimport tkinterfrom PIL import Image, ImageTkimport random,time import tkinter.messagebox    def new_game():    global v,run_now,chiose,gold,chiose_once,is_god,old_gold    old_gold=gold    run_now = False    is_god=False    chiose_once=False    chiose={
"BIG":0,"SMORT":0,"SHUN":0,"BAO":0}# 添加按钮所实现的功能def run(count): try: global v,run_now,chiose,gold,chiose_once,is_god,old_gold if run_now: return is_run = True if not chiose_once: now_gold=gold-t1.get()-t2.get()-t3.get()-t4.get() if now_gold<0: tkinter.messagebox.showinfo(title = '提示',message='金币不够下注') return if CheckVar1.get()==0 and CheckVar2.get()==0 and CheckVar3.get()==0 and CheckVar4.get()==0 or t1.get()==0 and t2.get()==0 and t3.get()==0 and t4.get()==0: tkinter.messagebox.showinfo(title = '提示',message='未进行下注') return else: if CheckVar1.get()==1: gold-=t1.get() chiose['BIG']=t1.get() v.set('%s'%str(gold)) if CheckVar2.get()==1: gold-=t2.get() chiose['SMORT']=t2.get() v.set('%s'%str(gold)) if CheckVar3.get()==1: gold-=t3.get() chiose['SHUN']=t3.get() v.set('%s'%str(gold)) if CheckVar4.get()==1: gold-=t4.get() chiose['BAO']=t4.get() v.set('%s'%str(gold)) chiose_once=True #print(chiose) if is_god: if chiose['BIG']>chiose['SMORT']: a=[random.randint(1,3) for i in range(0,3)] else: a=[random.randint(3,6) for i in range(0,3)] else: a=[random.randint(1,6) for i in range(0,3)] diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[0])) # 更新图片 label1.configure(image=diceimage) label1.image = diceimage diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[1])) # 更新图片 label2.configure(image=diceimage) label2.image = diceimage diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[2])) # 更新图片 label3.configure(image=diceimage) label3.image = diceimage wait = [a for a in range(50, 200, 10)] + [b for b in range(200, 400, 300 // 2)] + \ [c for c in range(400, 600, 120)] + [d for d in range(600, 800, 200)] if count < len(wait): root.after(wait[count], run,count + 1) else: a.sort() if sum(a)>9: gold+=chiose['BIG']*2 if sum(a)<9: gold+=chiose['SMORT']*2 if a[0]+a[1]==a[2]: gold+=chiose['SHUN']*3 if a[0]==a[1] and a[0]==a[2]: gold+=chiose['BAO']*6 v.set('%s'%str(gold)) #print(old_gold) if gold-old_gold>=0: tkinter.messagebox.showinfo(title = '提示',message='本局押对,获得金币:%s'%str(gold-old_gold)) else: tkinter.messagebox.showinfo(title = '提示',message='本局押错,扣除金币:%s'%str(old_gold-gold)) new_game() except: new_game() tkinter.messagebox.showerror(title = '提示',message='出错了,请重新') def get_gold(golds): global gold,v gold=golds v.set('%s'%str(gold)) tkinter.messagebox.showinfo(title = '提示',message='金币已重置') def God(): global is_god if is_god: tkinter.messagebox.showinfo(title = '提示',message='上帝模式关闭,看运气模式') is_god=False else: tkinter.messagebox.showinfo(title = '提示',message='上帝模式开启,不可能获胜') is_god=Trueif __name__=='__main__': global v,run_now,gold,chiose,chiose_once,is_god,old_goid #初始金 gold=5000 old_gold=5000 is_god=False chiose_once=False chiose={
"BIG":0,"SMORT":0,"SHUN":0,"BAO":0} run_now=False # 创建主窗口 root = tkinter.Tk() winWidth = 800 winHeight = 400 screenWidth = root.winfo_screenwidth() screenHeight = root.winfo_screenheight() x = int((screenWidth - winWidth) / 2) y = int((screenHeight - winHeight) / 2) # 设置窗口初始位置在屏幕居中 root.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y)) root.title("摇塞子模拟") root.resizable(width=False, height=False) #绘制主界面 # 图片文件 # 使用随机数并生成图像 a=[6,6,6] diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[0])) label1 = tkinter.Label(root, image=diceimage) label1.image = diceimage # 放置在窗口中 label1.place(x=55, y=80) diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[1])) label2 = tkinter.Label(root, image=diceimage) label2.image = diceimage # 放置在窗口中 label2.place(x=255, y=80) diceimage = ImageTk.PhotoImage(Image.open("sz/%s.jpg"%a[2])) label3 = tkinter.Label(root, image=diceimage) label3.image = diceimage # 放置在窗口中 label3.place(x=455, y=80) v = tkinter.StringVar() v.set("%s"%gold) label4 = tkinter.Label(root, textvariable=v,fg="red", bg="yellow", font=("微软雅黑", 25, "bold")) label4.pack(side="top",pady=10) pailie=20 t1 = tkinter.IntVar() entry = tkinter.Entry(root,textvariable = t1,width = 10) entry.place(x=pailie, y=290) CheckVar1 = tkinter.IntVar() C1 = tkinter.Checkbutton(root,text = "买大(2倍)", variable = CheckVar1,onvalue = 1, offvalue = 0, height=3,width = 10) C1.place(x=pailie+70, y=270) t2 = tkinter.IntVar() entry = tkinter.Entry(root,textvariable = t2,width = 10) entry.place(x=pailie+200, y=290) CheckVar2 = tkinter.IntVar() C2 = tkinter.Checkbutton(root, text = "买小(2倍)", variable = CheckVar2, onvalue = 1, offvalue = 0, height=3,width = 10) C2.place(x=pailie+270, y=270) t3 = tkinter.IntVar() entry = tkinter.Entry(root,textvariable = t3,width = 10) entry.place(x=pailie+400, y=290) CheckVar3 = tkinter.IntVar() C3 = tkinter.Checkbutton(root, text = "顺子(3倍)", variable = CheckVar3,onvalue = 1, offvalue = 0, height=3,width =10) C3.place(x=pailie+470, y=270) t4 = tkinter.IntVar() entry = tkinter.Entry(root,textvariable = t4,width = 10) entry.place(x=pailie+600, y=290) CheckVar4 = tkinter.IntVar() C4 = tkinter.Checkbutton(root, text = "豹子(6倍)", variable = CheckVar4, onvalue = 1, offvalue = 0, height=3,width = 10) C4.place(x=pailie+670, y=270) # 添加按钮 设置按钮样式 实现上面所定义的功能 button = tkinter.Button(root, text="摇塞子", width=50,height=3,fg="red", command=lambda:run(0)) # 放置在窗口中 button.pack(side="bottom",pady=10) # 添加按钮 设置按钮样式 实现上面所定义的功能 button = tkinter.Button(root, text="重置金币", width=10,height=3,fg="red", command=lambda:get_gold(5000)) # 放置在窗口中 button.place(x=100, y=325) # 添加按钮 设置按钮样式 实现上面所定义的功能 button = tkinter.Button(root, text="上帝模式", width=10,height=3,fg="red", command=lambda:God()) # 放置在窗口中 button.place(x=620, y=325) root.mainloop()

转载地址:https://cxk-life.blog.csdn.net/article/details/109789675 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:批量保存微信收藏的表情包
下一篇:python多进程海量视频提取帧图片

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月11日 02时34分23秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章