上海智位机器人股份有限公司 沪ICP备09038501号-4
作品创意灵感:
华容道是古老的中国民间益智游戏,以其变化多端、百玩不厌的特点与魔方、独立砖石一起被国外智力专家并称为"智力游戏界的三个不可思议"。在科技飞速发展的今天,我们突发奇想,为什么不使用科技手段改造一下传统的华容道游戏,让它能够更加具有科技感与实用性呢?所以这样一款基于华容道与拼图游戏模式,结合开源硬件与人工智能模块,具有娱乐与科教功能的智能拼图的游戏诞生了。它拥有着两个模式,可以进行单人游戏与历史科技人物认识与学习,也可以进行双人对抗,决出赢家,在游戏的同时我们也可以了解图灵,冯诺依曼,乔布斯,蔡元培等历史上对计算机与科技发展带来重大变革意义的科学家们,边玩边学,科普与趣味与竞技性兼得。
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from pinpong.libs.dfrobot_huskylens import Huskylens
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from pinpong.board import Board
from unihiker import GUI
import time
# 事件回调函数
def u_x1_function():
mingzi=u_gui.draw_text(text="趣识历史科技名人",x=20,y=50,font_size=18, color="#000000")
mingzi1=u_gui.draw_text(text="智能拼图游戏",x=85,y=90,font_size=12, color="#000000")
mingzi2=u_gui.draw_image(image="tulin(1).jpg",x=45,y=150)
kaishi=u_gui.add_button(text="开始",x=90,y=120,w=50,h=30,onclick=ks)
time.sleep(5)
def ks():
zhuyemian=u_gui.start_thread(u_zhuyemian_function)
buzzer.play(buzzer.DADADADUM,buzzer.OnceInBackground)
def u_zhuyemian_function():
u_gui.clear()
wx=u_gui.draw_emoji(emoji="Wink",x=15,y=0,duration=0.2)
yxms=u_gui.draw_text(text="游戏模式",x=70,y=200,font_size=20, color="#FF0000")
danrms=u_gui.add_button(text="单人模式",x=80,y=150,w=40,h=30,onclick=danrms1)
duorms=u_gui.add_button(text="多人模式",x=140,y=150,w=40,h=30,onclick=duorms1)
def danrms1():
u_gui.clear()
dr1=u_gui.start_thread(u_dr1_function)
def u_dr1_function():
u_gui.clear()
xyg=u_gui.add_button(text="切换人物",x=120,y=40,w=80,h=30,onclick=xyg1)
qd=u_gui.add_button(text="拼好了",x=40,y=40,w=60,h=30,onclick=qd1)
tp0=u_gui.draw_image(image="tulin(1).jpg",x=45,y=120)
jishi=u_gui.draw_text(text="计时:",x=80,y=80,font_size=15, color="#0000FF")
jishi1=u_gui.draw_digit(text="0",x=140,y=88,font_size=15, color="#0000FF")
ShiJian = 0
global ZuiHouShiJian
ZuiHouShiJian = 1
while True:
jishi1.config(text=ShiJian)
ShiJian = (ShiJian + 1)
time.sleep(1)
ZuiHouShiJian = ShiJian
def duorms1():
u_gui.clear()
dr2=u_gui.start_thread(u_dr2_function)
def u_dr2_function():
mingzi=u_gui.draw_text(text="请点击按钮确定开启",x=10,y=50,font_size=15, color="#000000")
mingzi1=u_gui.draw_text(text="绿方:",x=40,y=90,font_size=12, color="#000000")
zhunbei1=u_gui.draw_text(text="未准备",x=100,y=90,font_size=12, color="#FF0000")
mingzi2=u_gui.draw_text(text="黄方:",x=40,y=120,font_size=12, color="#000000")
zhunbei2=u_gui.draw_text(text="未准备",x=100,y=120,font_size=12, color="#FF0000")
HuangSe = 0
LvSe = 0
while not (((HuangSe == 1) and (LvSe == 1))):
if (p_p1_analog.read_analog() > 2000):
p_p4_out=Pin(Pin.P4, Pin.OUT)
p_p4_out.write_digital(1)
LvSe = 1
zhunbei1.config(text="已准备")
if (p_p10_analog.read_analog() > 2000):
p_p6_out=Pin(Pin.P6, Pin.OUT)
p_p6_out.write_digital(1)
HuangSe = 1
zhunbei2.config(text="已准备")
mingzi.config(text="正在开始...")
time.sleep(1)
ks2=u_gui.start_thread(u_ks2_function)
def qd1():
time.sleep(0.2)
buzzer.play(buzzer.ENTERTAINER,buzzer.OnceInBackground)
u_gui.clear()
gx=u_gui.draw_text(text="恭喜完成",x=65,y=0,font_size=20, color="#0000FF")
gx1=u_gui.draw_text(text="本次成绩:",x=60,y=40,font_size=15, color="#0000FF")
js=u_gui.draw_text(text=ZuiHouShiJian,x=160,y=40,font_size=15, color="#0000FF")
gx2=u_gui.draw_text(text="秒",x=190,y=40,font_size=15, color="#0000FF")
lj1=u_gui.add_button(text="了解人物",x=80,y=70,w=80,h=30,onclick=lj)
tp0=u_gui.draw_image(image="tulin(1).jpg",x=45,y=120)
def u_ks2_function():
u_gui.clear()
p_p6_out=Pin(Pin.P6, Pin.OUT)
p_p6_out.write_digital(0)
p_p4_out=Pin(Pin.P4, Pin.OUT)
p_p4_out.write_digital(0)
mingzi=u_gui.draw_text(text="对抗开始",x=50,y=5,font_size=20, color="#000000")
mingzi1=u_gui.draw_text(text="绿方:",x=40,y=50,font_size=12, color="#000000")
mingzi2=u_gui.draw_text(text="黄方:",x=40,y=70,font_size=12, color="#000000")
tp0=u_gui.draw_image(image="tulin(1).jpg",x=45,y=120)
global ZuiHouShiJianLv
global z1
z1 = 0
ZuiHouShiJianLv = 1
global ZuiHouShiJianHuang
ZuiHouShiJianHuang = 1
js77=u_gui.start_thread(u_js77_function)
js66=u_gui.start_thread(u_js66_function)
def xyg1():
time.sleep(0.2)
u_gui.clear()
xyg11=u_gui.add_button(text="切换人物",x=120,y=40,w=80,h=30,onclick=qihuan1)
tp0=u_gui.draw_image(image="feng(1).jpg",x=30,y=120)
qd11=u_gui.add_button(text="确定",x=40,y=40,w=60,h=30,onclick=ks)
def u_js77_function():
zhunbei1=u_gui.draw_text(text="0",x=100,y=50,font_size=12, color="#0000FF")
ShiJian = 0
global JieShu
JieShu = 0
while not ((JieShu == 1)):
while not ((p_p1_analog.read_analog() > 2000)):
zhunbei1.config(text=ShiJian)
ShiJian = (ShiJian + 1)
time.sleep(1)
ZuiHouShiJianLv = ShiJian
zhunbei1.config(text=ZuiHouShiJianLv)
zt1=u_gui.draw_text(text="暂停",x=140,y=50,font_size=12, color="#0000FF")
for index in range(15):
p_huskylens.command_request()
if p_huskylens.is_appear(1, "blocks"):
buzzer.play(buzzer.ENTERTAINER,buzzer.OnceInBackground)
p_p4_out=Pin(Pin.P4, Pin.OUT)
p_p4_out.write_digital(1)
zt1.config(text="拼图成功")
JieShu = 1
time.sleep(0.2)
zt1.config(text=" ")
zt1.config(text="有效成绩")
def u_js66_function():
zhunbei2=u_gui.draw_text(text="0",x=100,y=70,font_size=12, color="#0000FF")
ShiJian1 = 0
global JieShu1
JieShu1 = 0
while not ((JieShu1 == 1)):
while not ((p_p10_analog.read_analog() > 2000)):
zhunbei2.config(text=ShiJian1)
ShiJian1 = (ShiJian1 + 1)
time.sleep(1)
ZuiHouShiJianHuang = ShiJian1
zhunbei2.config(text=ZuiHouShiJianHuang)
zt2=u_gui.draw_text(text="暂停",x=140,y=70,font_size=12, color="#0000FF")
for index in range(15):
p_huskylens.command_request()
if p_huskylens.is_appear(1, "blocks"):
buzzer.play(buzzer.ENTERTAINER,buzzer.OnceInBackground)
p_p6_out=Pin(Pin.P6, Pin.OUT)
p_p6_out.write_digital(1)
zt2.config(text="拼图成功")
JieShu1 = 1
time.sleep(0.2)
zt2.config(text=" ")
zt2.config(text="有效成绩")
def lj():
time.sleep(0.2)
u_gui.clear()
tl=u_gui.draw_text(text="阿兰·麦席森·图灵 (Alan Mathison Turing )",x=5,y=10,font_size=7, color="#0000FF")
tl2=u_gui.draw_text(text="英国著名的数学家和逻辑学家,被称为",x=5,y=20,font_size=7, color="#0000FF")
tl3=u_gui.draw_text(text="计算机科学之父、人工智能之父,是计算机逻辑的奠",x=5,y=30,font_size=7, color="#0000FF")
tl3=u_gui.draw_text(text="基者,提出了“图灵机”和“图灵测试”等重要概念。",x=5,y=40,font_size=7, color="#0000FF")
tl3=u_gui.draw_text(text="曾协助英国军方破解德国的著名密码系统“谜”",x=5,y=50,font_size=7, color="#0000FF")
tl3=u_gui.draw_text(text="帮助盟军取得了二战的胜利。人们为纪念",x=5,y=60,font_size=7, color="#0000FF")
tl3=u_gui.draw_text(text="其在计算机领域的卓越贡献而设立“图灵奖”。",x=5,y=70,font_size=7, color="#0000FF")
tp0=u_gui.draw_image(image="tulin(1).jpg",x=45,y=120)
fanhui=u_gui.add_button(text="返回",x=160,y=85,w=40,h=30,onclick=ks)
def qihuan2():
time.sleep(0.2)
u_gui.clear()
xyg11=u_gui.add_button(text="切换人物",x=120,y=40,w=80,h=30,onclick=danrms1)
qd11=u_gui.add_button(text="确定",x=40,y=40,w=60,h=30,onclick=ks)
tp0=u_gui.draw_image(image="cai(1).jpg",x=40,y=120)
def qihuan1():
time.sleep(0.2)
u_gui.clear()
xyg11=u_gui.add_button(text="切换人物",x=120,y=40,w=80,h=30,onclick=qihuan2)
qd11=u_gui.add_button(text="确定",x=40,y=40,w=60,h=30,onclick=ks)
tp0=u_gui.draw_image(image="qiao(1).jpg",x=30,y=120)
Board().begin()
u_gui=GUI()
p_p1_analog=Pin(Pin.P1, Pin.ANALOG)
p_p10_analog=Pin(Pin.P10, Pin.ANALOG)
p_huskylens = Huskylens()
p_huskylens.command_request_algorthim("ALGORITHM_FACE_RECOGNITION")
x1=u_gui.start_thread(u_x1_function)
time.sleep(9000)