Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. math.randomseed(os.time())
  2. memory.usememorydomain("RAM")
  3. local Count = 0
  4. local CreatureCount = 0
  5. local Read1 = 0x006D
  6. local Read2 = 0x0086
  7. local Inputs = joypad.get(1)
  8. local Scores = {}
  9. local NSI = {}
  10. while Count < 99 do
  11. NSI[Count] = {}
  12. Count = Count + 1
  13. end
  14. Count = 0
  15. local Generation = 1
  16. local Genome = 0
  17. local ClnInputs = 0
  18. local Frame = 0
  19. savestate.load("SMB.state");
  20. while true do
  21. Count = (Generation - 1) * 10
  22. print(table.getn(NSI[3]))
  23. print((Generation * 10) - 1)
  24. while table.getn(NSI[3]) <= (Generation * 10) - 1 do
  25. if CreatureCount == 4 then
  26. break
  27. else
  28. NSI[CreatureCount][Count] = math.random(0, 255)
  29. Count = Count + 1
  30. if Count == (Generation * 10) then
  31. CreatureCount = CreatureCount + 1
  32. Count = (Generation - 1) * 10
  33. end
  34. end
  35. end
  36. Count = 0
  37. ClnInputs = NSI[Genome][Frame]
  38. if ClnInputs >= 128 then
  39. Inputs["P1 A"] = true
  40. ClnInputs = ClnInputs - 128
  41. else
  42. Inputs["P1 A"] = false
  43. end
  44. if ClnInputs >= 64 then
  45. Inputs["P1 B"] = true
  46. ClnInputs = ClnInputs - 64
  47. else
  48. Inputs["P1 B"] = false
  49. end
  50. if ClnInputs >= 32 then
  51. Inputs["P1 Select"] = true
  52. ClnInputs = ClnInputs - 32
  53. else
  54. Inputs["P1 Select"] = false
  55. end
  56. if ClnInputs >= 16 then
  57. Inputs["P1 Start"] = true
  58. ClnInputs = ClnInputs - 16
  59. else
  60. Inputs["P1 Start"] = false
  61. end
  62. if ClnInputs >= 8 then
  63. Inputs["P1 Up"] = true
  64. ClnInputs = ClnInputs - 8
  65. else
  66. Inputs["P1 Up"] = false
  67. end
  68. if ClnInputs >= 4 then
  69. Inputs["P1 Down"] = true
  70. ClnInputs = ClnInputs - 4
  71. else
  72. Inputs["P1 Down"] = false
  73. end
  74. if ClnInputs >= 2 then
  75. Inputs["P1 Left"] = true
  76. ClnInputs = ClnInputs - 2
  77. else
  78. Inputs["P1 Left"] = false
  79. end
  80. if ClnInputs >= 1 then
  81. Inputs["P1 Right"] = true
  82. ClnInputs = ClnInputs - 1
  83. else
  84. Inputs["P1 Right"] = false
  85. end
  86. joypad.set(Inputs);
  87. Frame = Frame + 1
  88. if Frame > (Generation * 10) - 1 then
  89. Frame = 0
  90. Scores[Genome] = (memory.readbyte(Read1) * 256) + memory.readbyte(Read2)
  91. Genome = Genome + 1
  92. savestate.load("SMB.state");
  93. end
  94. if Genome >= 4 then
  95. Genome = 0
  96. Generation = Generation + 1
  97. end
  98. emu.frameadvance()
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement