12浏览
查看: 12|回复: 3

[项目] 【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏

[复制链接]
【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图1

Kitronik ARCADE 是一款由英国教育科技公司 Kitronik 精心打造的可编程游戏机开发板,专为编程教学与创客实践而设计。该设备原生支持微软的 MakeCode Arcade 平台,用户可通过图形化或 JavaScript 编程方式,轻松创建、下载并运行复古风格的街机游戏。

它集成了彩色 LCD 显示屏、方向控制键、功能按键、蜂鸣器和震动马达等交互组件,提供完整的游戏输入输出体验。无论是初学者进行编程启蒙,还是创客群体开发交互式作品,Kitronik ARCADE 都能作为理想的硬件载体,助力创意实现。

凭借其开源友好、易于上手、兼容性强等特点,该开发板广泛应用于中小学编程课程、创客工作坊、游戏开发教学以及个人项目原型设计,深受教育者与技术爱好者的喜爱。


【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图2

驴友花雕  中级技神
 楼主|

发表于 2 小时前

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏

作为学习、练习与尝试,这里创建一个时尚青蛙的小游戏。
打开网页版:https://arcade.makecode.com/,设置项目名称:时尚青蛙

MicroPython实验代码

  1. @namespace
  2. class SpriteKind:
  3.     Frog = SpriteKind.create()
  4.     Menu = SpriteKind.create()
  5. def Think(R: number, G: number, B: number, Net: List[List[List[number]]]):
  6.     global OutputArray, OutputArray2
  7.     OutputArray = [0, 0, 0, 0]
  8.     OutputArray2 = [0, 0, 0, 0]
  9.     for index in range(4):
  10.         OutputArray[index] = R * Net[0][index][0] + G * Net[0][index][1] + (B * Net[0][index][2] + Net[0][index][3])
  11.     for index2 in range(4):
  12.         OutputArray2[index2] = OutputArray[0] * Net[1][index2][0] + OutputArray[1] * Net[1][index2][1] + (OutputArray[2] * Net[1][index2][2] + (OutputArray[3] * Net[1][index2][3] + Net[1][index2][4]))
  13.     print(OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])))
  14.     if OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= 2:
  15.         return "...Ribbit?"
  16.     elif OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= 1:
  17.         return "LOVE"
  18.     elif OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= 0.75:
  19.         return "Like"
  20.     elif OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= 0.5:
  21.         return "OK"
  22.     elif OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= 0.25:
  23.         return "Dislike"
  24.     elif OutputArray2[0] * Net[2][0][0] + OutputArray2[1] * Net[2][0][1] + (OutputArray2[2] * Net[2][0][2] + (OutputArray2[3] * Net[2][0][3] + Net[2][0][4])) >= -1:
  25.         return "HATE"
  26.     else:
  27.         return "...Ribbit?"
  28. def on_a_pressed():
  29.     global Stage, Count, Net_3
  30.     music.play(music.melody_playable(music.zapped),
  31.         music.PlaybackMode.IN_BACKGROUND)
  32.     if mySprite.tile_kind_at(TileDirection.CENTER, assets.tile("""
  33.         Seat
  34.         """)) and Stage > 0:
  35.         if Stage < 3:
  36.             if Frog_1.image.equals(assets.image("""
  37.                 Frog_1
  38.                 """)) and mySprite.overlaps_with(Frog_1):
  39.                 Frog_1.set_image(assets.image("""
  40.                     Frog_1_Love
  41.                     """))
  42.                 Frog_1.start_effect(effects.hearts, 500)
  43.                 LoveArray.append(Net_1)
  44.                 Stage += 1
  45.             if Frog_2.image.equals(assets.image("""
  46.                 Frog_2
  47.                 """)) and mySprite.overlaps_with(Frog_2):
  48.                 Frog_2.set_image(assets.image("""
  49.                     Frog_2_Love
  50.                     """))
  51.                 Frog_2.start_effect(effects.hearts, 500)
  52.                 LoveArray.append(Net_2)
  53.                 Stage += 1
  54.             if Frog_3.image.equals(assets.image("""
  55.                 Frog_3
  56.                 """)) and mySprite.overlaps_with(Frog_3):
  57.                 Frog_3.set_image(assets.image("""
  58.                     Frog_3_Love
  59.                     """))
  60.                 Frog_3.start_effect(effects.hearts, 500)
  61.                 LoveArray.append(Net_3)
  62.                 Stage += 1
  63.             if Frog_4.image.equals(assets.image("""
  64.                 Frog_4
  65.                 """)) and mySprite.overlaps_with(Frog_4):
  66.                 Frog_4.set_image(assets.image("""
  67.                     Frog_4_Love
  68.                     """))
  69.                 Frog_4.start_effect(effects.hearts, 500)
  70.                 LoveArray.append(Net_4)
  71.                 Stage += 1
  72.             if Frog_5.image.equals(assets.image("""
  73.                 Frog_5
  74.                 """)) and mySprite.overlaps_with(Frog_5):
  75.                 Frog_5.set_image(assets.image("""
  76.                     Frog_5_Love
  77.                     """))
  78.                 Frog_5.start_effect(effects.hearts, 500)
  79.                 LoveArray.append(Net_5)
  80.                 Stage += 1
  81.             if Stage == 3:
  82.                 Stage = 0
  83.                 Count += -1
  84.                 animation.stop_animation(animation.AnimationTypes.ALL, mySprite)
  85.                 mySprite.set_image(assets.image("""
  86.                     Cursor
  87.                     """))
  88.                 pause(500)
  89.                 Breed(LoveArray[0], LoveArray[1])
  90.                 music.play(music.melody_playable(music.power_up),
  91.                     music.PlaybackMode.IN_BACKGROUND)
  92.                 Round()
  93.                 if Count > 0:
  94.                     Stage = 1
  95.                 else:
  96.                     game.show_long_text("It's time to pick your final AI Fashion Frog!",
  97.                         DialogLayout.BOTTOM)
  98.                     Stage = -1
  99.                     animation.run_image_animation(mySprite,
  100.                         assets.animation("""
  101.                             Cursor_Select
  102.                             """),
  103.                         700,
  104.                         True)
  105.     elif mySprite.tile_kind_at(TileDirection.CENTER, assets.tile("""
  106.         Seat
  107.         """)) and Stage == -1:
  108.         if Frog_1.image.equals(assets.image("""
  109.             Frog_1
  110.             """)) and mySprite.overlaps_with(Frog_1):
  111.             Frog_1.set_image(assets.image("""
  112.                 Frog_1_Love
  113.                 """))
  114.             Frog_1.start_effect(effects.hearts, 500)
  115.             Stage = -1.1
  116.         if Frog_2.image.equals(assets.image("""
  117.             Frog_2
  118.             """)) and mySprite.overlaps_with(Frog_2):
  119.             Frog_2.set_image(assets.image("""
  120.                 Frog_2_Love
  121.                 """))
  122.             Frog_2.start_effect(effects.hearts, 500)
  123.             Stage = -1.2
  124.         if Frog_3.image.equals(assets.image("""
  125.             Frog_3
  126.             """)) and mySprite.overlaps_with(Frog_3):
  127.             Frog_3.set_image(assets.image("""
  128.                 Frog_3_Love
  129.                 """))
  130.             Frog_3.start_effect(effects.hearts, 500)
  131.             Stage = -1.3
  132.         if Frog_4.image.equals(assets.image("""
  133.             Frog_4
  134.             """)) and mySprite.overlaps_with(Frog_4):
  135.             Frog_4.set_image(assets.image("""
  136.                 Frog_4_Love
  137.                 """))
  138.             Frog_4.start_effect(effects.hearts, 500)
  139.             Stage = -1.4
  140.         if Frog_5.image.equals(assets.image("""
  141.             Frog_5
  142.             """)) and mySprite.overlaps_with(Frog_5):
  143.             Frog_5.set_image(assets.image("""
  144.                 Frog_5_Love
  145.                 """))
  146.             Frog_5.start_effect(effects.hearts, 500)
  147.             Stage = -1.5
  148.         if Stage < -1:
  149.             if Stage == -1.1:
  150.                 Net_3 = Net_1
  151.             elif Stage == -1.2:
  152.                 Net_3 = Net_2
  153.             elif Stage == -1.3:
  154.                 Net_3 = Net_3
  155.             elif Stage == -1.4:
  156.                 Net_3 = Net_4
  157.             elif Stage == -1.5:
  158.                 Net_3 = Net_5
  159.             sprites.destroy(Frog_1)
  160.             sprites.destroy(Frog_2)
  161.             sprites.destroy(Frog_4)
  162.             sprites.destroy(Frog_5)
  163.             effects.hearts.start_screen_effect(1000)
  164.             
  165.             def on_after():
  166.                 game.show_long_text("Congratulations finding your AI Fashion Frog!",
  167.                     DialogLayout.BOTTOM)
  168.                
  169.                 def on_after2():
  170.                     game.show_long_text("Here is what your frog thinks of your fashionable color tastes!",
  171.                         DialogLayout.BOTTOM)
  172.                     
  173.                     def on_after3():
  174.                         game.show_long_text("They think you " + str(Think(1, 1, 1, Net_3)) + " White!",
  175.                             DialogLayout.BOTTOM)
  176.                         game.show_long_text("They think you " + str(Think(0, 0, 0, Net_3)) + " Black!",
  177.                             DialogLayout.BOTTOM)
  178.                         game.show_long_text("They think you " + str(Think(1, 0, 0, Net_3)) + " Red!",
  179.                             DialogLayout.BOTTOM)
  180.                         game.show_long_text("They think you " + str(Think(1, 0.5, 0, Net_3)) + " Orange!",
  181.                             DialogLayout.BOTTOM)
  182.                         game.show_long_text("They think you " + str(Think(1, 1, 0, Net_3)) + " Yellow!",
  183.                             DialogLayout.BOTTOM)
  184.                         game.show_long_text("They think you " + str(Think(0, 1, 0, Net_3)) + " Green!",
  185.                             DialogLayout.BOTTOM)
  186.                         game.show_long_text("They think you " + str(Think(0, 1, 0, Net_3)) + " Green!",
  187.                             DialogLayout.BOTTOM)
  188.                         game.show_long_text("They think you " + str(Think(0, 1, 1, Net_3)) + " Cyan!",
  189.                             DialogLayout.BOTTOM)
  190.                         game.show_long_text("They think you " + str(Think(0, 0, 1, Net_3)) + " Blue!",
  191.                             DialogLayout.BOTTOM)
  192.                         game.show_long_text("They think you " + str(Think(0.5, 0, 1, Net_3)) + " Purple!",
  193.                             DialogLayout.BOTTOM)
  194.                         game.show_long_text("They think you " + str(Think(1, 0, 1, Net_3)) + " Magenta!",
  195.                             DialogLayout.BOTTOM)
  196.                         for index3 in range(3):
  197.                             for value in Net_3[index3]:
  198.                                 print(value[0])
  199.                                 print(value[1])
  200.                                 print(value[2])
  201.                         
  202.                         def on_after4():
  203.                             game.show_long_text("Thanks so much for playing around with my first neural network game. If you want more games like this, search for my games in the makecode arcade forum!",
  204.                                 DialogLayout.BOTTOM)
  205.                             game.set_game_over_message(True, "- Dragondoodle / Randomuser")
  206.                             game.game_over(True)
  207.                         timer.after(500, on_after4)
  208.                         
  209.                     timer.after(500, on_after3)
  210.                     
  211.                 timer.after(500, on_after2)
  212.                
  213.             timer.after(1000, on_after)
  214.             
  215. controller.A.on_event(ControllerButtonEvent.PRESSED, on_a_pressed)
  216. def Round():
  217.     global Stage, LoveArray
  218.     Stage = 0
  219.     pause(2000)
  220.     music.play(music.melody_playable(music.magic_wand),
  221.         music.PlaybackMode.IN_BACKGROUND)
  222.     Frog_1.say_text(Think(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, Net_1),
  223.         5000,
  224.         False)
  225.     Frog_2.say_text(Think(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, Net_2),
  226.         5000,
  227.         False)
  228.     Frog_3.say_text(Think(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, Net_3),
  229.         5000,
  230.         False)
  231.     Frog_4.say_text(Think(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, Net_4),
  232.         5000,
  233.         False)
  234.     Frog_5.say_text(Think(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, Net_5),
  235.         5000,
  236.         False)
  237.     Frog_1.set_image(assets.image("""
  238.         Frog_1_Speak
  239.         """))
  240.     Frog_2.set_image(assets.image("""
  241.         Frog_2_Speak
  242.         """))
  243.     Frog_3.set_image(assets.image("""
  244.         Frog_3_Speak
  245.         """))
  246.     Frog_4.set_image(assets.image("""
  247.         Frog_4_Speak
  248.         """))
  249.     Frog_5.set_image(assets.image("""
  250.         Frog_5_Speak
  251.         """))
  252.    
  253.     def on_after5():
  254.         Frog_1.set_image(assets.image("""
  255.             Frog_1
  256.             """))
  257.         Frog_2.set_image(assets.image("""
  258.             Frog_2
  259.             """))
  260.         Frog_3.set_image(assets.image("""
  261.             Frog_3
  262.             """))
  263.         Frog_4.set_image(assets.image("""
  264.             Frog_4
  265.             """))
  266.         Frog_5.set_image(assets.image("""
  267.             Frog_5
  268.             """))
  269.     timer.after(1000, on_after5)
  270.    
  271.     pause(4000)
  272.     game.show_long_text("Pick the right frogs!", DialogLayout.BOTTOM)
  273.     animation.run_image_animation(mySprite,
  274.         assets.animation("""
  275.             Cursor_Select
  276.             """),
  277.         700,
  278.         True)
  279.     LoveArray = []
  280. def Breed(One: List[List[List[number]]], Two: List[List[List[number]]]):
  281.     global Net_1, Net_2, Net_3, Net_4, Net_5
  282.     Net_1 = [[[randint(100 * One[0][0][0], 100 * Two[0][0][0]) / 100,
  283.                 randint(100 * One[0][0][1], 100 * Two[0][0][1]) / 100,
  284.                 randint(100 * One[0][0][2], 100 * Two[0][0][2]) / 100,
  285.                 randint(100 * One[0][0][3], 100 * Two[0][0][3]) / 100],
  286.             [randint(100 * One[0][1][0], 100 * Two[0][1][0]) / 100,
  287.                 randint(100 * One[0][1][1], 100 * Two[0][1][1]) / 100,
  288.                 randint(100 * One[0][1][2], 100 * Two[0][1][2]) / 100,
  289.                 randint(100 * One[0][1][3], 100 * Two[0][1][3]) / 100],
  290.             [randint(100 * One[0][2][0], 100 * Two[0][2][0]) / 100,
  291.                 randint(100 * One[0][2][1], 100 * Two[0][2][1]) / 100,
  292.                 randint(100 * One[0][2][2], 100 * Two[0][2][2]) / 100,
  293.                 randint(100 * One[0][2][3], 100 * Two[0][2][3]) / 100],
  294.             [randint(100 * One[0][3][0], 100 * Two[0][3][0]) / 100,
  295.                 randint(100 * One[0][3][1], 100 * Two[0][3][1]) / 100,
  296.                 randint(100 * One[0][3][2], 100 * Two[0][3][2]) / 100,
  297.                 randint(100 * One[0][3][3], 100 * Two[0][3][3]) / 100]],
  298.         [[randint(100 * One[1][0][0], 100 * Two[1][0][0]) / 100,
  299.                 randint(100 * One[1][0][1], 100 * Two[1][0][1]) / 100,
  300.                 randint(100 * One[1][0][2], 100 * Two[1][0][2]) / 100,
  301.                 randint(100 * One[1][0][3], 100 * Two[1][0][3]) / 100,
  302.                 randint(100 * One[1][0][4], 100 * Two[1][0][4]) / 100],
  303.             [randint(100 * One[1][1][0], 100 * Two[1][1][0]) / 100,
  304.                 randint(100 * One[1][1][1], 100 * Two[1][1][1]) / 100,
  305.                 randint(100 * One[1][1][2], 100 * Two[1][1][2]) / 100,
  306.                 randint(100 * One[1][1][3], 100 * Two[1][1][3]) / 100,
  307.                 randint(100 * One[1][1][4], 100 * Two[1][1][4]) / 100],
  308.             [randint(100 * One[1][2][0], 100 * Two[1][2][0]) / 100,
  309.                 randint(100 * One[1][2][1], 100 * Two[1][2][1]) / 100,
  310.                 randint(100 * One[1][2][2], 100 * Two[1][2][2]) / 100,
  311.                 randint(100 * One[1][2][3], 100 * Two[1][2][3]) / 100,
  312.                 randint(100 * One[1][2][4], 100 * Two[1][2][4]) / 100],
  313.             [randint(100 * One[1][3][0], 100 * Two[1][3][0]) / 100,
  314.                 randint(100 * One[1][3][1], 100 * Two[1][3][1]) / 100,
  315.                 randint(100 * One[1][3][2], 100 * Two[1][3][2]) / 100,
  316.                 randint(100 * One[1][3][3], 100 * Two[1][3][3]) / 100,
  317.                 randint(100 * One[1][3][4], 100 * Two[1][3][4]) / 100]],
  318.         [[randint(100 * One[2][0][0], 100 * Two[2][0][0]) / 100,
  319.                 randint(100 * One[2][0][1], 100 * Two[2][0][1]) / 100,
  320.                 randint(100 * One[2][0][2], 100 * Two[2][0][2]) / 100,
  321.                 randint(100 * One[2][0][3], 100 * Two[2][0][3]) / 100,
  322.                 randint(100 * One[2][0][4], 100 * Two[2][0][4]) / 100]]]
  323.     Net_2 = [[[randint(100 * One[0][0][0], 100 * Two[0][0][0]) / 100,
  324.                 randint(100 * One[0][0][1], 100 * Two[0][0][1]) / 100,
  325.                 randint(100 * One[0][0][2], 100 * Two[0][0][2]) / 100,
  326.                 randint(100 * One[0][0][3], 100 * Two[0][0][3]) / 100],
  327.             [randint(100 * One[0][1][0], 100 * Two[0][1][0]) / 100,
  328.                 randint(100 * One[0][1][1], 100 * Two[0][1][1]) / 100,
  329.                 randint(100 * One[0][1][2], 100 * Two[0][1][2]) / 100,
  330.                 randint(100 * One[0][1][3], 100 * Two[0][1][3]) / 100],
  331.             [randint(100 * One[0][2][0], 100 * Two[0][2][0]) / 100,
  332.                 randint(100 * One[0][2][1], 100 * Two[0][2][1]) / 100,
  333.                 randint(100 * One[0][2][2], 100 * Two[0][2][2]) / 100,
  334.                 randint(100 * One[0][2][3], 100 * Two[0][2][3]) / 100],
  335.             [randint(100 * One[0][3][0], 100 * Two[0][3][0]) / 100,
  336.                 randint(100 * One[0][3][1], 100 * Two[0][3][1]) / 100,
  337.                 randint(100 * One[0][3][2], 100 * Two[0][3][2]) / 100,
  338.                 randint(100 * One[0][3][3], 100 * Two[0][3][3]) / 100]],
  339.         [[randint(100 * One[1][0][0], 100 * Two[1][0][0]) / 100,
  340.                 randint(100 * One[1][0][1], 100 * Two[1][0][1]) / 100,
  341.                 randint(100 * One[1][0][2], 100 * Two[1][0][2]) / 100,
  342.                 randint(100 * One[1][0][3], 100 * Two[1][0][3]) / 100,
  343.                 randint(100 * One[1][0][4], 100 * Two[1][0][4]) / 100],
  344.             [randint(100 * One[1][1][0], 100 * Two[1][1][0]) / 100,
  345.                 randint(100 * One[1][1][1], 100 * Two[1][1][1]) / 100,
  346.                 randint(100 * One[1][1][2], 100 * Two[1][1][2]) / 100,
  347.                 randint(100 * One[1][1][3], 100 * Two[1][1][3]) / 100,
  348.                 randint(100 * One[1][1][4], 100 * Two[1][1][4]) / 100],
  349.             [randint(100 * One[1][2][0], 100 * Two[1][2][0]) / 100,
  350.                 randint(100 * One[1][2][1], 100 * Two[1][2][1]) / 100,
  351.                 randint(100 * One[1][2][2], 100 * Two[1][2][2]) / 100,
  352.                 randint(100 * One[1][2][3], 100 * Two[1][2][3]) / 100,
  353.                 randint(100 * One[1][2][4], 100 * Two[1][2][4]) / 100],
  354.             [randint(100 * One[1][3][0], 100 * Two[1][3][0]) / 100,
  355.                 randint(100 * One[1][3][1], 100 * Two[1][3][1]) / 100,
  356.                 randint(100 * One[1][3][2], 100 * Two[1][3][2]) / 100,
  357.                 randint(100 * One[1][3][3], 100 * Two[1][3][3]) / 100,
  358.                 randint(100 * One[1][3][4], 100 * Two[1][3][4]) / 100]],
  359.         [[randint(100 * One[2][0][0], 100 * Two[2][0][0]) / 100,
  360.                 randint(100 * One[2][0][1], 100 * Two[2][0][1]) / 100,
  361.                 randint(100 * One[2][0][2], 100 * Two[2][0][2]) / 100,
  362.                 randint(100 * One[2][0][3], 100 * Two[2][0][3]) / 100,
  363.                 randint(100 * One[2][0][4], 100 * Two[2][0][4]) / 100]]]
  364.     Net_3 = [[[randint(100 * One[0][0][0], 100 * Two[0][0][0]) / 100,
  365.                 randint(100 * One[0][0][1], 100 * Two[0][0][1]) / 100,
  366.                 randint(100 * One[0][0][2], 100 * Two[0][0][2]) / 100,
  367.                 randint(100 * One[0][0][3], 100 * Two[0][0][3]) / 100],
  368.             [randint(100 * One[0][1][0], 100 * Two[0][1][0]) / 100,
  369.                 randint(100 * One[0][1][1], 100 * Two[0][1][1]) / 100,
  370.                 randint(100 * One[0][1][2], 100 * Two[0][1][2]) / 100,
  371.                 randint(100 * One[0][1][3], 100 * Two[0][1][3]) / 100],
  372.             [randint(100 * One[0][2][0], 100 * Two[0][2][0]) / 100,
  373.                 randint(100 * One[0][2][1], 100 * Two[0][2][1]) / 100,
  374.                 randint(100 * One[0][2][2], 100 * Two[0][2][2]) / 100,
  375.                 randint(100 * One[0][2][3], 100 * Two[0][2][3]) / 100],
  376.             [randint(100 * One[0][3][0], 100 * Two[0][3][0]) / 100,
  377.                 randint(100 * One[0][3][1], 100 * Two[0][3][1]) / 100,
  378.                 randint(100 * One[0][3][2], 100 * Two[0][3][2]) / 100,
  379.                 randint(100 * One[0][3][3], 100 * Two[0][3][3]) / 100]],
  380.         [[randint(100 * One[1][0][0], 100 * Two[1][0][0]) / 100,
  381.                 randint(100 * One[1][0][1], 100 * Two[1][0][1]) / 100,
  382.                 randint(100 * One[1][0][2], 100 * Two[1][0][2]) / 100,
  383.                 randint(100 * One[1][0][3], 100 * Two[1][0][3]) / 100,
  384.                 randint(100 * One[1][0][4], 100 * Two[1][0][4]) / 100],
  385.             [randint(100 * One[1][1][0], 100 * Two[1][1][0]) / 100,
  386.                 randint(100 * One[1][1][1], 100 * Two[1][1][1]) / 100,
  387.                 randint(100 * One[1][1][2], 100 * Two[1][1][2]) / 100,
  388.                 randint(100 * One[1][1][3], 100 * Two[1][1][3]) / 100,
  389.                 randint(100 * One[1][1][4], 100 * Two[1][1][4]) / 100],
  390.             [randint(100 * One[1][2][0], 100 * Two[1][2][0]) / 100,
  391.                 randint(100 * One[1][2][1], 100 * Two[1][2][1]) / 100,
  392.                 randint(100 * One[1][2][2], 100 * Two[1][2][2]) / 100,
  393.                 randint(100 * One[1][2][3], 100 * Two[1][2][3]) / 100,
  394.                 randint(100 * One[1][2][4], 100 * Two[1][2][4]) / 100],
  395.             [randint(100 * One[1][3][0], 100 * Two[1][3][0]) / 100,
  396.                 randint(100 * One[1][3][1], 100 * Two[1][3][1]) / 100,
  397.                 randint(100 * One[1][3][2], 100 * Two[1][3][2]) / 100,
  398.                 randint(100 * One[1][3][3], 100 * Two[1][3][3]) / 100,
  399.                 randint(100 * One[1][3][4], 100 * Two[1][3][4]) / 100]],
  400.         [[randint(100 * One[2][0][0], 100 * Two[2][0][0]) / 100,
  401.                 randint(100 * One[2][0][1], 100 * Two[2][0][1]) / 100,
  402.                 randint(100 * One[2][0][2], 100 * Two[2][0][2]) / 100,
  403.                 randint(100 * One[2][0][3], 100 * Two[2][0][3]) / 100,
  404.                 randint(100 * One[2][0][4], 100 * Two[2][0][4]) / 100]]]
  405.     Net_4 = [[[randint(100 * One[0][0][0], 100 * Two[0][0][0]) / 100,
  406.                 randint(100 * One[0][0][1], 100 * Two[0][0][1]) / 100,
  407.                 randint(100 * One[0][0][2], 100 * Two[0][0][2]) / 100,
  408.                 randint(100 * One[0][0][3], 100 * Two[0][0][3]) / 100],
  409.             [randint(100 * One[0][1][0], 100 * Two[0][1][0]) / 100,
  410.                 randint(100 * One[0][1][1], 100 * Two[0][1][1]) / 100,
  411.                 randint(100 * One[0][1][2], 100 * Two[0][1][2]) / 100,
  412.                 randint(100 * One[0][1][3], 100 * Two[0][1][3]) / 100],
  413.             [randint(100 * One[0][2][0], 100 * Two[0][2][0]) / 100,
  414.                 randint(100 * One[0][2][1], 100 * Two[0][2][1]) / 100,
  415.                 randint(100 * One[0][2][2], 100 * Two[0][2][2]) / 100,
  416.                 randint(100 * One[0][2][3], 100 * Two[0][2][3]) / 100],
  417.             [randint(100 * One[0][3][0], 100 * Two[0][3][0]) / 100,
  418.                 randint(100 * One[0][3][1], 100 * Two[0][3][1]) / 100,
  419.                 randint(100 * One[0][3][2], 100 * Two[0][3][2]) / 100,
  420.                 randint(100 * One[0][3][3], 100 * Two[0][3][3]) / 100]],
  421.         [[randint(100 * One[1][0][0], 100 * Two[1][0][0]) / 100,
  422.                 randint(100 * One[1][0][1], 100 * Two[1][0][1]) / 100,
  423.                 randint(100 * One[1][0][2], 100 * Two[1][0][2]) / 100,
  424.                 randint(100 * One[1][0][3], 100 * Two[1][0][3]) / 100,
  425.                 randint(100 * One[1][0][4], 100 * Two[1][0][4]) / 100],
  426.             [randint(100 * One[1][1][0], 100 * Two[1][1][0]) / 100,
  427.                 randint(100 * One[1][1][1], 100 * Two[1][1][1]) / 100,
  428.                 randint(100 * One[1][1][2], 100 * Two[1][1][2]) / 100,
  429.                 randint(100 * One[1][1][3], 100 * Two[1][1][3]) / 100,
  430.                 randint(100 * One[1][1][4], 100 * Two[1][1][4]) / 100],
  431.             [randint(100 * One[1][2][0], 100 * Two[1][2][0]) / 100,
  432.                 randint(100 * One[1][2][1], 100 * Two[1][2][1]) / 100,
  433.                 randint(100 * One[1][2][2], 100 * Two[1][2][2]) / 100,
  434.                 randint(100 * One[1][2][3], 100 * Two[1][2][3]) / 100,
  435.                 randint(100 * One[1][2][4], 100 * Two[1][2][4]) / 100],
  436.             [randint(100 * One[1][3][0], 100 * Two[1][3][0]) / 100,
  437.                 randint(100 * One[1][3][1], 100 * Two[1][3][1]) / 100,
  438.                 randint(100 * One[1][3][2], 100 * Two[1][3][2]) / 100,
  439.                 randint(100 * One[1][3][3], 100 * Two[1][3][3]) / 100,
  440.                 randint(100 * One[1][3][4], 100 * Two[1][3][4]) / 100]],
  441.         [[randint(100 * One[2][0][0], 100 * Two[2][0][0]) / 100,
  442.                 randint(100 * One[2][0][1], 100 * Two[2][0][1]) / 100,
  443.                 randint(100 * One[2][0][2], 100 * Two[2][0][2]) / 100,
  444.                 randint(100 * One[2][0][3], 100 * Two[2][0][3]) / 100,
  445.                 randint(100 * One[2][0][4], 100 * Two[2][0][4]) / 100]]]
  446.     Net_5 = [[[randint(100 * One[0][0][0], 100 * Two[0][0][0]) / 100,
  447.                 randint(100 * One[0][0][1], 100 * Two[0][0][1]) / 100,
  448.                 randint(100 * One[0][0][2], 100 * Two[0][0][2]) / 100,
  449.                 randint(100 * One[0][0][3], 100 * Two[0][0][3]) / 100],
  450.             [randint(100 * One[0][1][0], 100 * Two[0][1][0]) / 100,
  451.                 randint(100 * One[0][1][1], 100 * Two[0][1][1]) / 100,
  452.                 randint(100 * One[0][1][2], 100 * Two[0][1][2]) / 100,
  453.                 randint(100 * One[0][1][3], 100 * Two[0][1][3]) / 100],
  454.             [randint(100 * One[0][2][0], 100 * Two[0][2][0]) / 100,
  455.                 randint(100 * One[0][2][1], 100 * Two[0][2][1]) / 100,
  456.                 randint(100 * One[0][2][2], 100 * Two[0][2][2]) / 100,
  457.                 randint(100 * One[0][2][3], 100 * Two[0][2][3]) / 100],
  458.             [randint(100 * One[0][3][0], 100 * Two[0][3][0]) / 100,
  459.                 randint(100 * One[0][3][1], 100 * Two[0][3][1]) / 100,
  460.                 randint(100 * One[0][3][2], 100 * Two[0][3][2]) / 100,
  461.                 randint(100 * One[0][3][3], 100 * Two[0][3][3]) / 100]],
  462.         [[randint(100 * One[1][0][0], 100 * Two[1][0][0]) / 100,
  463.                 randint(100 * One[1][0][1], 100 * Two[1][0][1]) / 100,
  464.                 randint(100 * One[1][0][2], 100 * Two[1][0][2]) / 100,
  465.                 randint(100 * One[1][0][3], 100 * Two[1][0][3]) / 100,
  466.                 randint(100 * One[1][0][4], 100 * Two[1][0][4]) / 100],
  467.             [randint(100 * One[1][1][0], 100 * Two[1][1][0]) / 100,
  468.                 randint(100 * One[1][1][1], 100 * Two[1][1][1]) / 100,
  469.                 randint(100 * One[1][1][2], 100 * Two[1][1][2]) / 100,
  470.                 randint(100 * One[1][1][3], 100 * Two[1][1][3]) / 100,
  471.                 randint(100 * One[1][1][4], 100 * Two[1][1][4]) / 100],
  472.             [randint(100 * One[1][2][0], 100 * Two[1][2][0]) / 100,
  473.                 randint(100 * One[1][2][1], 100 * Two[1][2][1]) / 100,
  474.                 randint(100 * One[1][2][2], 100 * Two[1][2][2]) / 100,
  475.                 randint(100 * One[1][2][3], 100 * Two[1][2][3]) / 100,
  476.                 randint(100 * One[1][2][4], 100 * Two[1][2][4]) / 100],
  477.             [randint(100 * One[1][3][0], 100 * Two[1][3][0]) / 100,
  478.                 randint(100 * One[1][3][1], 100 * Two[1][3][1]) / 100,
  479.                 randint(100 * One[1][3][2], 100 * Two[1][3][2]) / 100,
  480.                 randint(100 * One[1][3][3], 100 * Two[1][3][3]) / 100,
  481.                 randint(100 * One[1][3][4], 100 * Two[1][3][4]) / 100]],
  482.         [[randint(100 * One[2][0][0], 100 * Two[2][0][0]) / 100,
  483.                 randint(100 * One[2][0][1], 100 * Two[2][0][1]) / 100,
  484.                 randint(100 * One[2][0][2], 100 * Two[2][0][2]) / 100,
  485.                 randint(100 * One[2][0][3], 100 * Two[2][0][3]) / 100,
  486.                 randint(100 * One[2][0][4], 100 * Two[2][0][4]) / 100]]]
  487.     for index4 in range(2):
  488.         Mutate(Net_1)
  489.         Mutate(Net_2)
  490.         Mutate(Net_3)
  491.         Mutate(Net_4)
  492.         Mutate(Net_5)
  493.     ColorRandom()
  494. def ColorRandom():
  495.     global RGB
  496.     for index5 in range(5):
  497.         color.set_color(index5 + 2,
  498.             color.rgb(randint(50, 200), randint(50, 200), randint(50, 200)))
  499.     RGB = [randint(0, 255), randint(0, 255), randint(0, 255)]
  500.     color.set_color(7, color.rgb(RGB[0], RGB[1], RGB[2]))
  501. def Mutate(Net2: List[List[List[number]]]):
  502.     global MutationArray
  503.     MutationArray = []
  504.     MutationArray.append(randint(0, 2))
  505.     if MutationArray[0] == 2:
  506.         MutationArray.append(0)
  507.     else:
  508.         MutationArray.append(randint(0, 3))
  509.     if MutationArray[0] == 1:
  510.         MutationArray.append(randint(0, 3))
  511.     else:
  512.         MutationArray.append(randint(0, 4))
  513.     Net2[MutationArray[0]][MutationArray[1]][MutationArray[2]] = randint(-100, 100) / 100
  514. def Randomize(_2: number):
  515.     global Net_1, Net_2, Net_3, Net_4, Net_5
  516.     if _2 == 1:
  517.         Net_1 = [[[randint(-100, 100) / 100,
  518.                     randint(-100, 100) / 100,
  519.                     randint(-100, 100) / 100,
  520.                     randint(-100, 100) / 100],
  521.                 [randint(-100, 100) / 100,
  522.                     randint(-100, 100) / 100,
  523.                     randint(-100, 100) / 100,
  524.                     randint(-100, 100) / 100],
  525.                 [randint(-100, 100) / 100,
  526.                     randint(-100, 100) / 100,
  527.                     randint(-100, 100) / 100,
  528.                     randint(-100, 100) / 100],
  529.                 [randint(-100, 100) / 100,
  530.                     randint(-100, 100) / 100,
  531.                     randint(-100, 100) / 100,
  532.                     randint(-100, 100) / 100]],
  533.             [[randint(-100, 100) / 100,
  534.                     randint(-100, 100) / 100,
  535.                     randint(-100, 100) / 100,
  536.                     randint(-100, 100) / 100,
  537.                     randint(-100, 100) / 100],
  538.                 [randint(-100, 100) / 100,
  539.                     randint(-100, 100) / 100,
  540.                     randint(-100, 100) / 100,
  541.                     randint(-100, 100) / 100,
  542.                     randint(-100, 100) / 100],
  543.                 [randint(-100, 100) / 100,
  544.                     randint(-100, 100) / 100,
  545.                     randint(-100, 100) / 100,
  546.                     randint(-100, 100) / 100,
  547.                     randint(-100, 100) / 100],
  548.                 [randint(-100, 100) / 100,
  549.                     randint(-100, 100) / 100,
  550.                     randint(-100, 100) / 100,
  551.                     randint(-100, 100) / 100,
  552.                     randint(-100, 100) / 100]],
  553.             [[randint(-100, 100) / 100,
  554.                     randint(-100, 100) / 100,
  555.                     randint(-100, 100) / 100,
  556.                     randint(-100, 100) / 100,
  557.                     randint(-100, 100) / 100]]]
  558.     elif _2 == 2:
  559.         Net_2 = [[[randint(-100, 100) / 100,
  560.                     randint(-100, 100) / 100,
  561.                     randint(-100, 100) / 100,
  562.                     randint(-100, 100) / 100],
  563.                 [randint(-100, 100) / 100,
  564.                     randint(-100, 100) / 100,
  565.                     randint(-100, 100) / 100,
  566.                     randint(-100, 100) / 100],
  567.                 [randint(-100, 100) / 100,
  568.                     randint(-100, 100) / 100,
  569.                     randint(-100, 100) / 100,
  570.                     randint(-100, 100) / 100],
  571.                 [randint(-100, 100) / 100,
  572.                     randint(-100, 100) / 100,
  573.                     randint(-100, 100) / 100,
  574.                     randint(-100, 100) / 100]],
  575.             [[randint(-100, 100) / 100,
  576.                     randint(-100, 100) / 100,
  577.                     randint(-100, 100) / 100,
  578.                     randint(-100, 100) / 100,
  579.                     randint(-100, 100) / 100],
  580.                 [randint(-100, 100) / 100,
  581.                     randint(-100, 100) / 100,
  582.                     randint(-100, 100) / 100,
  583.                     randint(-100, 100) / 100,
  584.                     randint(-100, 100) / 100],
  585.                 [randint(-100, 100) / 100,
  586.                     randint(-100, 100) / 100,
  587.                     randint(-100, 100) / 100,
  588.                     randint(-100, 100) / 100,
  589.                     randint(-100, 100) / 100],
  590.                 [randint(-100, 100) / 100,
  591.                     randint(-100, 100) / 100,
  592.                     randint(-100, 100) / 100,
  593.                     randint(-100, 100) / 100,
  594.                     randint(-100, 100) / 100]],
  595.             [[randint(-100, 100) / 100,
  596.                     randint(-100, 100) / 100,
  597.                     randint(-100, 100) / 100,
  598.                     randint(-100, 100) / 100,
  599.                     randint(-100, 100) / 100]]]
  600.     elif _2 == 3:
  601.         Net_3 = [[[randint(-100, 100) / 100,
  602.                     randint(-100, 100) / 100,
  603.                     randint(-100, 100) / 100,
  604.                     randint(-100, 100) / 100],
  605.                 [randint(-100, 100) / 100,
  606.                     randint(-100, 100) / 100,
  607.                     randint(-100, 100) / 100,
  608.                     randint(-100, 100) / 100],
  609.                 [randint(-100, 100) / 100,
  610.                     randint(-100, 100) / 100,
  611.                     randint(-100, 100) / 100,
  612.                     randint(-100, 100) / 100],
  613.                 [randint(-100, 100) / 100,
  614.                     randint(-100, 100) / 100,
  615.                     randint(-100, 100) / 100,
  616.                     randint(-100, 100) / 100]],
  617.             [[randint(-100, 100) / 100,
  618.                     randint(-100, 100) / 100,
  619.                     randint(-100, 100) / 100,
  620.                     randint(-100, 100) / 100,
  621.                     randint(-100, 100) / 100],
  622.                 [randint(-100, 100) / 100,
  623.                     randint(-100, 100) / 100,
  624.                     randint(-100, 100) / 100,
  625.                     randint(-100, 100) / 100,
  626.                     randint(-100, 100) / 100],
  627.                 [randint(-100, 100) / 100,
  628.                     randint(-100, 100) / 100,
  629.                     randint(-100, 100) / 100,
  630.                     randint(-100, 100) / 100,
  631.                     randint(-100, 100) / 100],
  632.                 [randint(-100, 100) / 100,
  633.                     randint(-100, 100) / 100,
  634.                     randint(-100, 100) / 100,
  635.                     randint(-100, 100) / 100,
  636.                     randint(-100, 100) / 100]],
  637.             [[randint(-100, 100) / 100,
  638.                     randint(-100, 100) / 100,
  639.                     randint(-100, 100) / 100,
  640.                     randint(-100, 100) / 100,
  641.                     randint(-100, 100) / 100]]]
  642.     elif _2 == 4:
  643.         Net_4 = [[[randint(-100, 100) / 100,
  644.                     randint(-100, 100) / 100,
  645.                     randint(-100, 100) / 100,
  646.                     randint(-100, 100) / 100],
  647.                 [randint(-100, 100) / 100,
  648.                     randint(-100, 100) / 100,
  649.                     randint(-100, 100) / 100,
  650.                     randint(-100, 100) / 100],
  651.                 [randint(-100, 100) / 100,
  652.                     randint(-100, 100) / 100,
  653.                     randint(-100, 100) / 100,
  654.                     randint(-100, 100) / 100],
  655.                 [randint(-100, 100) / 100,
  656.                     randint(-100, 100) / 100,
  657.                     randint(-100, 100) / 100,
  658.                     randint(-100, 100) / 100]],
  659.             [[randint(-100, 100) / 100,
  660.                     randint(-100, 100) / 100,
  661.                     randint(-100, 100) / 100,
  662.                     randint(-100, 100) / 100,
  663.                     randint(-100, 100) / 100],
  664.                 [randint(-100, 100) / 100,
  665.                     randint(-100, 100) / 100,
  666.                     randint(-100, 100) / 100,
  667.                     randint(-100, 100) / 100,
  668.                     randint(-100, 100) / 100],
  669.                 [randint(-100, 100) / 100,
  670.                     randint(-100, 100) / 100,
  671.                     randint(-100, 100) / 100,
  672.                     randint(-100, 100) / 100,
  673.                     randint(-100, 100) / 100],
  674.                 [randint(-100, 100) / 100,
  675.                     randint(-100, 100) / 100,
  676.                     randint(-100, 100) / 100,
  677.                     randint(-100, 100) / 100,
  678.                     randint(-100, 100) / 100]],
  679.             [[randint(-100, 100) / 100,
  680.                     randint(-100, 100) / 100,
  681.                     randint(-100, 100) / 100,
  682.                     randint(-100, 100) / 100,
  683.                     randint(-100, 100) / 100]]]
  684.     elif _2 == 5:
  685.         Net_5 = [[[randint(-100, 100) / 100,
  686.                     randint(-100, 100) / 100,
  687.                     randint(-100, 100) / 100,
  688.                     randint(-100, 100) / 100],
  689.                 [randint(-100, 100) / 100,
  690.                     randint(-100, 100) / 100,
  691.                     randint(-100, 100) / 100,
  692.                     randint(-100, 100) / 100],
  693.                 [randint(-100, 100) / 100,
  694.                     randint(-100, 100) / 100,
  695.                     randint(-100, 100) / 100,
  696.                     randint(-100, 100) / 100],
  697.                 [randint(-100, 100) / 100,
  698.                     randint(-100, 100) / 100,
  699.                     randint(-100, 100) / 100,
  700.                     randint(-100, 100) / 100]],
  701.             [[randint(-100, 100) / 100,
  702.                     randint(-100, 100) / 100,
  703.                     randint(-100, 100) / 100,
  704.                     randint(-100, 100) / 100,
  705.                     randint(-100, 100) / 100],
  706.                 [randint(-100, 100) / 100,
  707.                     randint(-100, 100) / 100,
  708.                     randint(-100, 100) / 100,
  709.                     randint(-100, 100) / 100,
  710.                     randint(-100, 100) / 100],
  711.                 [randint(-100, 100) / 100,
  712.                     randint(-100, 100) / 100,
  713.                     randint(-100, 100) / 100,
  714.                     randint(-100, 100) / 100,
  715.                     randint(-100, 100) / 100],
  716.                 [randint(-100, 100) / 100,
  717.                     randint(-100, 100) / 100,
  718.                     randint(-100, 100) / 100,
  719.                     randint(-100, 100) / 100,
  720.                     randint(-100, 100) / 100]],
  721.             [[randint(-100, 100) / 100,
  722.                     randint(-100, 100) / 100,
  723.                     randint(-100, 100) / 100,
  724.                     randint(-100, 100) / 100,
  725.                     randint(-100, 100) / 100]]]
  726. MutationArray: List[number] = []
  727. RGB: List[number] = []
  728. LoveArray: List[List[List[List[number]]]] = []
  729. OutputArray2: List[number] = []
  730. OutputArray: List[number] = []
  731. Stage = 0
  732. mySprite: Sprite = None
  733. Count = 0
  734. Net_5: List[List[List[number]]] = []
  735. Net_4: List[List[List[number]]] = []
  736. Net_3: List[List[List[number]]] = []
  737. Net_2: List[List[List[number]]] = []
  738. Net_1: List[List[List[number]]] = []
  739. Frog_5: Sprite = None
  740. Frog_4: Sprite = None
  741. Frog_3: Sprite = None
  742. Frog_2: Sprite = None
  743. Frog_1: Sprite = None
  744. ColorRandom()
  745. scene.center_camera_at(88, 60)
  746. tiles.set_current_tilemap(tilemap("""
  747.     Level
  748.     """))
  749. ColorShow = sprites.create(assets.image("""
  750.     Show
  751.     """), SpriteKind.Menu)
  752. Frog_1 = sprites.create(assets.image("""
  753.     Frog_1
  754.     """), SpriteKind.Frog)
  755. Frog_2 = sprites.create(assets.image("""
  756.     Frog_2
  757.     """), SpriteKind.Frog)
  758. Frog_3 = sprites.create(assets.image("""
  759.     Frog_3
  760.     """), SpriteKind.Frog)
  761. Frog_4 = sprites.create(assets.image("""
  762.     Frog_4
  763.     """), SpriteKind.Frog)
  764. Frog_5 = sprites.create(assets.image("""
  765.     Frog_5
  766.     """), SpriteKind.Frog)
  767. tiles.place_on_tile(Frog_1, tiles.get_tile_location(2, 4))
  768. tiles.place_on_tile(Frog_2, tiles.get_tile_location(3, 2))
  769. tiles.place_on_tile(Frog_3, tiles.get_tile_location(5, 3))
  770. tiles.place_on_tile(Frog_4, tiles.get_tile_location(7, 1))
  771. tiles.place_on_tile(Frog_5, tiles.get_tile_location(8, 5))
  772. ColorShow.set_position(88, 25)
  773. Net_1 = [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
  774.     [[0, 0, 0, 0, 0],
  775.         [0, 0, 0, 0, 0],
  776.         [0, 0, 0, 0, 0],
  777.         [0, 0, 0, 0, 0]],
  778.     [[0, 0, 0, 0, 0]]]
  779. Net_2 = [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
  780.     [[0, 0, 0, 0, 0],
  781.         [0, 0, 0, 0, 0],
  782.         [0, 0, 0, 0, 0],
  783.         [0, 0, 0, 0, 0]],
  784.     [[0, 0, 0, 0, 0]]]
  785. Net_3 = [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
  786.     [[0, 0, 0, 0, 0],
  787.         [0, 0, 0, 0, 0],
  788.         [0, 0, 0, 0, 0],
  789.         [0, 0, 0, 0, 0]],
  790.     [[0, 0, 0, 0, 0]]]
  791. Net_4 = [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
  792.     [[0, 0, 0, 0, 0],
  793.         [0, 0, 0, 0, 0],
  794.         [0, 0, 0, 0, 0],
  795.         [0, 0, 0, 0, 0]],
  796.     [[0, 0, 0, 0, 0]]]
  797. Net_5 = [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
  798.     [[0, 0, 0, 0, 0],
  799.         [0, 0, 0, 0, 0],
  800.         [0, 0, 0, 0, 0],
  801.         [0, 0, 0, 0, 0]],
  802.     [[0, 0, 0, 0, 0]]]
  803. def on_after6():
  804.     global Count, mySprite, Stage
  805.     game.show_long_text("Welcome to AI Fashion Frogs #1, Color Guessing!",
  806.         DialogLayout.BOTTOM)
  807.     game.show_long_text("This AI relies on supervised deep learning to mimic how the human brain learns.",
  808.         DialogLayout.BOTTOM)
  809.     game.show_long_text("With your help, you can train these AI frogs to know your individual color tastes.",
  810.         DialogLayout.BOTTOM)
  811.     game.show_long_text("Simply pick the two frogs that have the most correct answers and the code will do the rest!",
  812.         DialogLayout.BOTTOM)
  813.     Count = game.ask_for_number("How many practice guesses do you want?", 2)
  814.     mySprite = sprites.create(assets.image("""
  815.         Cursor
  816.         """), SpriteKind.player)
  817.     grid.snap(mySprite)
  818.     grid.move_with_buttons(mySprite)
  819.     Randomize(1)
  820.     Randomize(2)
  821.     Randomize(3)
  822.     Randomize(4)
  823.     Randomize(5)
  824.     ColorRandom()
  825.     Round()
  826.     Stage = 1
  827. timer.after(500, on_after6)
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 2 小时前

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏

这是一个基于MakeCode Arcade平台的"AI Fashion Frogs"(AI时尚青蛙)游戏代码。

游戏概述
这是一个通过神经网络模拟AI学习的游戏,玩家需要训练青蛙AI来识别自己对颜色的喜好偏好。

核心组件

1. 神经网络结构
python
  1. def Think(R: number, G: number, B: number, Net: List[List[List[number]]]):
复制代码

这是一个3层神经网络:
输入层:RGB颜色值(3个输入)
隐藏层1:4个神经元
隐藏层2:4个神经元
输出层:1个神经元

2. 神经网络工作原理
前向传播计算:输入 → 隐藏层1 → 隐藏层2 → 输出
使用权重矩阵进行线性变换
输出值映射到情感标签:LOVE, Like, OK, Dislike, HATE

3. 游戏流程
初始化阶段:
创建5只青蛙,每只都有随机的初始神经网络权重
显示随机颜色供青蛙"评价"

训练阶段:
青蛙对颜色给出评价(通过神经网络计算)
玩家选择两只评价最准确的青蛙
系统通过Breed()函数进行"繁殖"(神经网络交叉和变异)
生成新一代的5只青蛙
重复直到训练次数用完

最终选择:
玩家选择最终的AI青蛙
测试该青蛙对各种颜色的偏好

关键技术点
遗传算法实现
python
  1. def Breed(One, Two):
复制代码

交叉繁殖:从两只父代青蛙的权重中随机选择值
变异:通过Mutate()函数随机改变某些权重
模拟自然选择过程

权重管理
权重值范围:-1.0 到 1.0
使用小数精度(除以100)
通过随机化和选择优化网络性能

游戏特色
教育性:直观展示神经网络和遗传算法的工作原理
交互性:玩家参与训练过程,影响AI进化方向
可视化:通过青蛙图像和特效增强用户体验
个性化:最终AI会反映玩家的颜色偏好

技术架构
前端:MakeCode Arcade游戏引擎
AI核心:自定义实现的简单神经网络
算法:遗传算法优化神经网络权重
交互:网格移动和选择机制
这个项目巧妙地将机器学习概念游戏化,让玩家在娱乐中理解AI训练的基本原理。

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 2 小时前

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏

通过模拟器,调试与模拟运行

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图4

实验场景记录

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图1

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图5

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图3

【花雕动手做】基于Kitronik可编程开发板之时尚青蛙游戏图2




回复

使用道具 举报

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

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail