Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This script is designed to work with Bizhawk
- --This script assumes a pre-made state on Quicksave Slot 0
- --define variables here
- ap_addr = 0x0DBE8C --AP1
- trials = 20000
- file_prefix = "Fate_"
- --program variables
- ap_value = 0
- ap_previous = 0
- ap_t = {}
- total = 0
- save_state_slot = 0 -- which quickload slot to load from
- --Prints a Table with a format of (x,y)
- function tprint (t)
- for k, v in pairs(t) do
- io.write(k..', '..v..'\n')
- end
- end
- --Wait function for advancing 1 frame and displaying results on the screen
- function Wait(number)
- for i=0,number-1 do
- emu.frameadvance()
- gui.text(30,170,'Total: '..total)
- gui.text(30,190,'Last AP: '..ap_previous)
- end
- end
- --read the value of the address, if it doesnt exist in the Table, add it, otherwise increment
- function TableRecord(addr, t)
- v = t[memory.readbyte(addr)]
- if v == nil then
- t[memory.readbyte(addr)] = 1
- else
- t[memory.readbyte(addr)] = v + 1
- end
- end
- --the main loop, this runs until the total number of trials are reached
- while true do
- savestate.loadslot(save_state_slot);
- --wait 2 frames (30fps game) and save the state, for changing the RNG for the next cycle
- Wait(2);
- savestate.saveslot(save_state_slot);
- --wait until the enemy AP updates to a good value
- while ((ap_value == 33) or (ap_value == 0)) do
- --press X and R2(in-game fast forward)
- joypad.set({R2=true}, 1)
- joypad.set({Cross=true}, 1)
- Wait(2);
- ap_value = memory.readbyte(ap_addr);
- end
- --Record Values for this run
- TableRecord(ap_addr, ap_t);
- ap_previous = ap_value;
- ap_value = 0;
- total = total + 1;
- --check if we are finished, and print out the data to a file in CSV format
- if(total == trials) then
- file = io.open(file_prefix .. tostring(emu.framecount()) .. '.csv', "a")
- io.output(file)
- io.write('Total, ', total, '\n')
- io.write('\nAP, Count\n')
- tprint(ap_t)
- io.close(file)
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement