--BOT開始後のフレーム数 local frame = 0 --ステージクリアフラグ local stage_clear_flag = false --サンダービーム切り替え後フラグ local thunder_beam_flag = true --サンダービームショットフラグ local thunder_beam_shot_flag = true --開始後このフレームまでにサンダービームに切り替え local max_thunder_beam_change_frame = 30 --このフレームにサンダービームに切り替え local thunder_beam_change_frame = false --サンダービームに切り替え後このフレームまでに必ずサンダービームを撃つ local max_thunder_beam_shot_frame = 30 --サンダービームを撃つフレーム local thunder_beam_shot_frame = false --着地しているときのY座標 local land_y = 180 --着地中にジャンプする1/確率 local jump_probability = 50 --最大何フレームジャンプボタンを押すか local max_jump_frame = 40 --ジャンプボタンを押すフレーム数 local jump_frame = false --移動可能な最大左端 local max_left_end = 95 --移動可能な最大右端 local max_right_end = 119 --開始から数えた終端フレーム数 local end_frame = 50 --ロックマンのX座標 local X --ロックマンのXスピード local XSpeed --ロックマンのY座標 local Y --ロックマンが左右どっちを向いているか(0x00左 0x40右) local LeftRight --入力 local tas_input = {} --ロードカウント local reload_count = 0 --敵座標 local EnemyAddress = 0 --リセットフラグ local reset_flag = false math.randomseed(os.time()) random = math.random(1,10) --やりなおし用のステートファイル作成 local state = savestate.create() savestate.save(state) --スピードを最大に emu.speedmode("maximum") --左右移動算出 local function left_right_check() tas_input.left = math.random(0,1) tas_input.right= math.random(0,1) end --ジャンプ算出 local function jump_check() if(Y <= land_y)then --ジャンプするかどうか local jump_attempt = math.random(0,jump_probability) --ジャンプすることになったらジャンプの大きさを決める if(jump_attempt == 0)then if(memory.readbyte(0x602) == 0xF8 or memory.readbyte(0x603) == 0xF8)then jump_frame = 1 else jump_frame = math.random(0,max_jump_frame) end end end if(jump_frame~=false and jump_frame > 0)then --ジャンプボタンを押す tas_input.A = 1 --あと何フレームジャンプボタンを押すか jump_frame = jump_frame - 1 if(jump_frame == 0)then jump_frame = false end else tas_input.A = 0 end end --サンダービームショット算出 local function thunder_beam_check() if(memory.readbyte(0x602) == 0xF8)then if(memory.readbyte(0x600)==0x50)then tas_input.B = 1 end end if(memory.readbyte(0x602) ~= 0xF8 and memory.readbyte(0x603) == 0xF8)then if(memory.readbyte(0x600)==0x4D)then tas_input.B = 1 end end if(memory.readbyte(0x602) ~= 0xF8 and memory.readbyte(0x603) ~= 0xF8)then if(math.random(0,20) == 1)then tas_input.B = 1 end end end --サンダービームに切り替え local function change_thunder_beam() --サンダービームに変化させるフレームを決定 if(thunder_beam_change_frame == false)then thunder_beam_change_frame = math.random(0,max_thunder_beam_change_frame) end --該当フレームなら切り替え開始 if(frame == thunder_beam_change_frame)then joypad.set(1,{ start = 1 }) emu.frameadvance() if(emu.lagged())then joypad.set(1,{ start = 1 }) emu.frameadvance() end for a=1,16,1 do emu.frameadvance() end joypad.set(1,{ down = 1 }) emu.frameadvance() emu.frameadvance() joypad.set(1,{ start = 1 }) emu.frameadvance() for a=1,30,1 do emu.frameadvance() end thunder_beam_flag = true end end --入力整流 local function tas_input_filter() output_tas_input = {} for key,value in pairs(tas_input) do if value == 1 then output_tas_input[key] = value end end tas_input = output_tas_input end --ロード前に各種値初期化 local function value_reset() reset_flag = false frame = 0 thunder_beam_change_frame = false thunder_beam_shot_frame = false jump_frame = false end_frame = 250 end --GUI Function gui.register( function() end ) memory.registerexec( 0xC008, 0x5, function() local pc = memory.getregister("pc") local b1 = memory.readbyte(pc) if pc == 0xC008 and b1==0x78 then reset_flag = true end end ) --Memory Function memory.registerexec( 0xd8f0, 0x100, function() local pc = memory.getregister("pc") local b1 = memory.readbyte(pc) --オブジェクト出現を検出 --SpawnObject_TypeIsFF --if pc == 0xd9b5 then -- fp = io.open ("object/object_bomb7.log","a+") -- fp:write(string.format("[%d]->%X \n",reload_count,0xFF)) -- fp:close() -- gui.text(10,25,string.format("[%d]->%X",reload_count,0xff)) -- stage_clear_flag = true --end if (pc == 0xd8f0 or pc == 0xd94d) and b1 == 0xb1 then local current_room = memory.readbyte(0x07)*256 + memory.readbyte(0x06) local RegisterY = memory.getregister("y") EnemyAddress = current_room + RegisterY --SpawnObject elseif pc == 0xd9e5 then local ObjectType = memory.readbyte(0x02) local SlotNumber = 0x6e0 + memory.getregister("x") if(ObjectType ~= 0x02 and ObjectType ~= 0x03 and ObjectType ~= 0x14)then fp = io.open ("object/object_55attempt.log","a+") fp:write(string.format("[%d][%X]->%X :%X \n",reload_count,SlotNumber,ObjectType,EnemyAddress)) fp:close() end gui.text(10,25,string.format("[%d]->%X",reload_count,ObjectType)) --if(ObjectType==0xD5 or ObjectType==0x55 or EnemyAddress == 0x23)then if(ObjectType==0x55 and SlotNumber == 0x6F4)then stage_clear_flag = true end end end ) --メインループ開始 while true do --map_number = memory.readbyte(0x1B) --if(map_number == 0x0a)then -- break --end --weponowned = memory.readbyte(0x5D) --if(weponowned ~= 0x00)then -- fp = io.open ("object_42-2.log","a+") -- fp:write(string.format("[%d]->%X \n",reload_count,weponowned)) -- fp:close() --2フレーム進めて様子見る -- emu.frameadvance() -- emu.frameadvance() -- weponowned = memory.readbyte(0x5D) -- if(weponowned ~= 0x00)then -- savestate.save(savestate.create(1)) -- break -- end --end --クリアしていたら抜ける frame_count = movie.framecount() if(stage_clear_flag==true)then savestate.save(savestate.create(1)) break end --終端フレームに達したらロード if(frame >= end_frame or memory.readbyte(0x23) >= 0x57)then value_reset() reload_count = reload_count + 1 savestate.load(state) end --座標/スピード取得 X = math.floor((memory.readbyte(0x480)*256+memory.readbyte(0x4A0))/256.0 * 1000)/1000 XSpeed = math.floor((memory.readbytesigned(0x4C0)*256+memory.readbyte(0x4E0))/256.0 * 1000)/1000 Y = math.floor((memory.readbyte(0x600)*256+memory.readbyte(0x620))/256.0 * 1000)/1000 LeftRight = memory.readbyte(0x9b) --リロードカウント出力 gui.text(10,15,reload_count) --入力初期化 tas_input = {} --左右移動 left_right_check() --ジャンプ jump_check() --サンダービームショット thunder_beam_check() --入力調整 tas_input_filter() --入力 joypad.set(1,tas_input) emu.frameadvance() frame = frame + 1 end