So.. did you figure out the Criticals thing? Your last post before this was asking for help on that matter, but now it seems like you got it figured out.
Either way, great. Ch. 1 in less than 10 minutes sounds sweet.
Emulator Coder, Site Developer, Site Owner, Expert player
(3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
well, sort of. there are still some things that don't make sense.
what I have is a systematic method of button presses that gives me 14 chances to get desired action (critcal, dodge, etc) on the 1st possible frames, 28 for the 2nd, 42 for the 3rd, 56 for the 4th and so on.
Even very unlikely events are going to likely happen in the 1st 10 frames with this formula (thats 770 combinations!)
The standard seems to be 1/64. In the first 5 frames I have 210 combinations which is a 210/64 chance; which is pretty good odds.
Unfortunately this doesn't work for the 1st action in the round. This is because it would require manipulating during the frames that the attack order is determined. But still, depending on the complexity of the order I need I can usually find 2-3 button combinations that yield the desired result. That will cut the delay in half or a third for 1st actions. Of course I can further manipulate this by making sure a "more likely" event happens at the beginning (like alena's attacks)
If anybody is curious about my methods Ill try to post an explanation, but It will be difficult to describe.
Right now I'm at the chamelion fight in chp2. Here I have the biggest task ahead. I have to get 2 critcals out of a lv 1 alena (1/256 chance for each hit). My method is much more time consuming (but well worth it!), so it might be awhile before I get past this point.
So far, I found 2 unnecessary steps on my way to the fight! (thats about 40 frames saved).
I'll let you guys know when I post the new sub 10min - chp1 .fcm file.
Actually I have a headache just reading that, so I doubt I'd understand the more complicated version, I'll just take your word for it. ;)
However you're doing it, improvements are good.
Emulator Coder, Site Developer, Site Owner, Expert player
(3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
Unfortunately no progress, but not from lack of effort.
I'm stuck trying to get a critical with alena on the chameleon fight.
there's only a 1/256 chance of success and I have to do 2 of them!
I got the 1st one and the 2nd one just doesn't want to happen.
I've done approx 1300-1400 re-records on this one spot and still nothing. Either that's really rotten luck or something doesn't work the way I think it does so I will need to look into it.
Anybody who follows this thread who hasn't read bisqwits post in the megaman 1 thread should do so immediately. He has created his "bisqbot" to play portions of his run. The code is posted. This has very BIG potential for RPG runs, especially DW4. If anyone knows how to program in C and is interested in seeing this run completed, they should look into adapting this code for finding critical hits for DW4.
The required ram address is already known as well as the values needed. I will post them for anyone who would be interested in doing this.
If no one else can do this I will attempt to do so. Having said that, I know NOTHING about c! (any help would be greatly appreciated) So it may be awhile before I am able to do it myself.
I just watched both your version 1 and version 2-to-chapter-1 runs, having actually just played through DW4 for the first time (really), and all I have to say is wow. Seriously. Personally, had you submitted the version 1 in its current state I definitely would have voted yes. Hell, now you've got me wanting to try DW2 or 3 (2 for a run, 3 for both a run and first-time playthrough). I hope you get this critical hit thing worked out, but I'm not much help; while I'm generally good at figuring these things out, I haven't done C in forever (and even then only very simple stuff) so I doubt I could figure this out, but if I look and something stands out I'll be sure to point it out. A sub-2-hr run on this game would be amazing. Anyway, the only piece of advice I can part with is to post your most current fcm (having just scored one critical hit on the chameleon); that would be the best for someone to try to figure out how to get #2 working.
I appreciate the effort you've put into this, adelikat. I admit, I once posted that a speedrun of DW4 would be nearly impossible. This is a huge game with multiple chapters, a lot of playable characters, and tons of weapons and armor. I think I said that someone would have to be very brave to even attempt it, and I stand by that. Your "up to Ragnar" run is better than I expected a DW4 run could be. I really hope to see a complete run someday.
TASing or playing back a DOS game? Make sure your files match the archive at RGB Classic Games.
I could help with or do the programming if needed (if you say you already got the ram offset and values, I think it would be pretty easy to do).
What do you actually need? Something to play the game until a critical hit or two is done (bisqbot) or something that will tell you which button to press and when to get a critical (easier to do)?
Emulator Coder, Site Developer, Site Owner, Expert player
(3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
YYEESS!! please do
either method will be fine, all I need is for it to a) play the game until 1 critical hit happens or tell me which buttons to push to get the critical
This is some info someone emailed me:
For my terrific blows GG code, the offset in the ROM is $0457DB, which is CPU address $97CB. If you've used the debugger for FCEU and want to see what's happening, you might want to put an execution breakpoint at address $97C8. This is inside the code for player critical hits only (monsters sold separately.. er, wait a minute :). What my code does is force the game to accept any random number as "good enough" to trigger a critical. It does that by diverting a "failure" result into the critical-hit code, instead of skipping over it.
The actual game code goes back further, but unfortunately this game uses the BRK (opcode 00) instructions, which seems pretty unusual [none of the other DW games uses them, as far as I know, nor does FF1]. I read once somewhere that the 6502 generally doesn't like them. :) It's a software interrupt, usually used for debugging, or so I understand. In this game, BRK instructions are used as general-purpose functions for very common tasks, usually accessing data or calling code that's in a different bank (handles all of the mapper / bank-switching messiness). So, if you trace through these calls, you'll notice that it takes a long time because there's alot of overhead before and after the actual function, which can be quite confusing. I've tried traced through some of it before, but due to the complexity, I haven't mapped it all out. The BRK calls used by the critical-hit code were unknown to me, but through further tracing, I've gotten a better understanding of these ones. I can't be certain I've got it all figured out, but I'm pretty confident.
I'll try to give a summary here of that particular code. The first things it does are to check for special modifiers for critical hit probabilities. The first modifier it checks for is if critical hits for the attacker are disabled.. that would happen if certain weapons like the poison needle are equipped, which cannot critical. Also, a character under the influence of the BiKill spell cannot critical, I believe. In this case, it skips the critical-hit code altogether. The other modifier it checks is if the auto-critical flag is set, wich means all hits are guaranteed to be critical. The Chance spell's "morale boost" will trigger this.. not sure if anything else will. This causes the game to go directly to the critical hit code, bypassing all randomness checking, etc.
Once past those checks, it will set the threshold for a critical hit. The default is 4 (out of 256).. pretty slim. It will then find out the identity of who's turn it is.. it seems more complex than it needs to be, but I trust the programmers had good reason. :) It does all of this to find out if it's Alena's turn.. if so, it calls a function to get her level, which then replaces the default threshold. That translates to just under 0.4% chance per level. At level 99, her chances would be 99/256, which is a little over 38.5%.. pretty nice, of course that's out of the question for a time attack. =} It may be there are exceptions to her threshold being equal to her level (haven't tested enough), but it really doesn't seem like it.
Once the critical-chance threshold is finalized, it calls a function to get a "random" number. This seems to be similar to what DW2 uses for randomness. As far as I can tell, it's based on a CRC16 checksum (usually used to verify that saved games haven't been corrupted by battery failure). Each time it's called, it uses the previous output. The randomness uses only 1 of the 2 bytes generated (the low-byte) and adds a modifier that's increased by 1 each time through.. this final result is the actual "random" number that's returned. If this number is the same as, or higher, than the threshold it will not be a critical hit.. that will happen only if it's less than the threshold value.
(If you want to trace through the random-number making process, set a breakpoint at $C891.. by the time it reaches $C8AC, the value in the A register will be the "random" value used. It's recommended to set a breakpoint at $97C5 first. Once that gets triggered, set the $C891 breakpoint... that way, you'll be sure that it's related to the critical-hit randomness checking instead of other randomness.)
Now, this is only called when needed. However, the low part of the crc value is modified seemingly every frame, so that's where the frame-level of randomness comes through as a result. It seems to be increased by 1 each time and is limited to 8 bits (which means it rolls over to 0 after 255 and doesn't affect anything else). The CRC values are in locations $12 and $13, with the CRC modifier at $050D, which you'll see if you decide to trace through it.
97A4: AD E7 72 LDA $72E7 ; Some battle flags.. (bit-wise)
97A7: 29 08 AND #$08 ; Check if critical hits allowed.
97A9: F0 2C BEQ $97D7 ; If not, skip critical-hit code. ("BiKill", poison needle, etc.)
97AB: AD E4 72 LDA $72E4 ; More battle flags.. (bit-wise)
97AE: 29 08 AND #$08 ; Check if always critical. (Chance spell effect "Morale boosted")
97B0: D0 1A BNE $97CC ; If so, bypass critical-hit probability tests.
97B2: A9 04 LDA #$04 ; The following part is used in determining the random chance of critical.
97B4: 85 00 STA $00 ; Start with value $04 into location $00. Base chance = 4/256 (= 1/64)
97B6: 00 06 BRK $06 ; A black-box function call.. seems to lookup the index of which character's turn it is.
97B8: 1F .DB $1F ; (extra data for the BRK instruction)
97B9: 00 2B BRK $2B ; Use index to lookup character data.. in this case, gets their character number.
97BB: 53 .DB $53 ; (extra BRK data)
97BC: C9 07 CMP #$07 ; Is it Alena? (is character number a match for Alena's number?)
97BE: D0 05 BNE $97C5 ; if not, skip over Alena's special handling.
97C0: 00 0F BRK $0F ; Get Alena's level.
97C2: 53 .DB $53 ; (extra BRK data)
97C3: 85 00 STA $00 ; Set the critical chance threshold.
97C5: 00 1B BRK $1B ; Get random value that will be critical chance.
97C7: 0F .DB $0F ; (extra BRK data)
97C8: C5 00 CMP $00 ; Compare it to threshold.
97CA: B0 0B BCS $97D7 ; Is it at least as high? If so, no critical hit (skip next part). (My GG code changed branch destination to next instruction)
97CC: 20 16 99 JSR $9916 ; Critical-hit related code follows.
97CF: 20 2E BF JSR $BF2E
97D2: 88 DEY
97D3: 00 F2 BRK $F2
97D5: D3 .DB $D3
97D6: 04 .DB $04
97D7: 20 8B A7 JSR $A78B ; Regular hits skip to here.
Emulator Coder, Site Developer, Site Owner, Expert player
(3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
Making a luckbot wouldn't be that hard, heres specifically what I would need
from the current point in the movie (or particular savestate), the bot would need to systematically check every combinations of button pushes of all the buttons for 5 frames. After each combination it would check to see if a critical occured, if so then stop (and hopefully display which button combo it used). If after checking all possible all possible combination and still no critical it would notify that it was done and failed, that way I could advance 1 frame and re-run the luckbot.
the combination of button would need to be all button except start. and only 1 button pushes at a time. The 1st frame should always be a button push, but the remaining frames could be null
The advantage of the bot over a battle simulator is that all it needs to do is check the ram address that tells when a critical hit has occured rather than trying to reconstruct the process.
Also in the future, changing the ram address that it checks, The bot could be changed to find treasure drops.
Ok, perhaps the bot will be the best if I don't have to analyse all this nes code.
I'll have to get a couple of things before working on this (mostly getting the latest bot's code and a lot of testing on my side). Still, Bisqwit's code is easy to follow and with the fceu's functions, it'll be better than what I wanted to do first.
At first, I wanted to build an external program which peeks in the emulator's memory and gives results depending of the frame. I've already did this for a lot of games for me to get values.
Edit:
I could also try to build an external "player" that peeks the game and pushes the buttons. Good part, it could be customizable for other games / emulators, bad part, it would be slower to run than from the emulator. (that's unless bisqwit's bot is external to fceu and that I'm clueless about it...)
Emulator Coder, Site Developer, Site Owner, Expert player
(3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
well I finally got over the hudle and completed the chamelon fight. I successfully killed off brey and cristo which saved my about 30 seconds in level ups (and about another 30-60 seconds later on). I don't plan on updating my WIP until it is finished though. But I will post progress reports from time to time
I haven't found the code for the fceu yet for the luckbot, so I guess I'll try to make an external one to begin with.
I haven't forgotten or given up on you adelikat...
All right! Nice going on the critical madness. I started messing around with DW2 using massive saving and reloading (not actively trying to timeattack, just seeing what I can get away with at low level) and have made it to the two-goblin fight (to get the ship) with all characters at Level 1. Fun times. Will start a new thread in a bit once I figure out a few more things. But I'm glad to hear you got past your hurdle and I look forward to the finished product.
Ah, yes, I found one waaay back in the history, last post was a while ago. I just managed (with enormous difficulty) to kill the 2 gremlins to get the ship with my party at level 1, but I'll post more about it there.