1. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.

Programming Pokemon Online replay player

Discussion in 'Technical Projects' started by Zarel, Aug 16, 2011.

Thread Status:
Not open for further replies.
  1. Zarel

    Zarel Not a Yuyuko fan
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Pokemon Researcheris an Administrator
    Creator of PS

    Joined:
    Aug 16, 2011
    Messages:
    1,854
    Have you ever wanted to watch a Pokemon Online replay instead of just reading it?

    I have, and I spent the last week developing an app that does just that:

    http://pokemon.aesoft.org/

    To-do:
    - More sound effects
    - Show HP, status, and species of pokemon in pokeballs
    - Saving settings
    - Pausing idle animations when pausing everything else
    - Redesigned start and end screens

    Recent updates (earliest to latest):
    - Better move animations for punching, biting, and kicking moves
    - "Recent replays" list is now newest-to-oldest, and only shows newest 200ish replays (there's a separate "all" button for all of them)
    - Move animations for Night Slash, Shadow Claw; placeholder animations for many other moves
    - A background
    - Perspective "3D-like" effects
    - Lots more animated back sprites
    - Move animations for Wild Charge, Thunder Fang, Bug Buzz, Sucker Punch
    - Color scheme chooser
    - Basic background music support
    - Support for IE7 and IE8
    - Fix for a few crashes on IE9 and some old versions of Firefox
    - Aqua Ring is now supported
    - Move animations for Safeguard, Seed Flare, Air Slash, Air Cutter
    - Redesigned replay footer
    - More support for PO's newest replay format
    It looks something like this:

    [​IMG]

    It's not completely done yet, but it works perfectly or near-perfectly on around 90% of the replays I've tested it on. It tends to work better on ladder/tournament replays than Challenge Cup replays, since the pool of competitively viable moves is much smaller than the complete pool of moves.

    Here's an example replay: http://pokemon.aesoft.org/replay-Ethereal-Sol-vs-Serei--2011-08-13

    It shows off weather and Bounce animations. It doesn't show off my Substitute animations, but I assure you those are also pretty awesome.

    FAQ

    Q: Some pokemon don't have animated back-sprites.

    A: Only around 80% of pokemon have animated back-sprites at the moment. For the ones that don't, there's nothing I can do about that. Go rip the GIF yourself or something. :/
    Q: Pain Split, Wish, Life Orb, Stealth Rock, Leech Seed, Shell Bell, recoil, or draining damage/healing is being calculated incorrectly, and/or, Regenerator and Natural Cure healing aren't working!

    A: You're using a replay from an old a buggy version of Pokemon Online, which doesn't contain this information. The replayer tries to guess the best it can, but it can sometimes be off by a bit. Please update to the latest version of Pokemon Online. complain to Pokemon Online about why they haven't fixed it yet.

    In particular, if Life Orb isn't showing up or Stealth Rock is being calculated incorrectly, you're using a very, very old version of Pokemon Online and should really upgrade.
    Q: Sometimes, when a pokemon uses Roar, Whirlwind, Dragon Tail, or Circle Throw, the sprite for an opposing nicknamed pokemon doesn't appear.

    A: You're using a replay from an old version of Pokemon Online, which doesn't contain this information. The replayer tries to guess the best it can, but if the replay doesn't contain this information, there's nothing it can do. Please update to the latest version of Pokemon Online.
    Q: I'm getting the error "This does not appear to be a valid Pokemon Online replay". What's wrong?

    A: It's not a valid PO replay. Most likely, you're copy-and-pasting a battle log into a file. You can't do that.

    You must use a replay file saved using the "save log" feature of PO. Here's a video guide: http://www.youtube.com/watch?v=SITN1X7dNFU
    Q: What about Pokemon Showdown replays?

    A: That's planned for the future revamp! Stay tuned, but don't hold your breath, since I have a lot of other things I want to do first.
    Q: I have a feature request!

    A: Cool! If it's not on the list of feature requests I'll never implement, post it to this thread! I might not implement it, but I'll explain why I will and won't. :)

    Here's a list of feature requests I will never implement:

    - Better calculation of Pain Split, recoil, Wish, Stealth Rock, or Leech Seed damage/healing on old Pokemon Online replays, or detection of Regenerator/Natural Cure/Life Orb.
    -- I know this can be improved, but the guessing algorithms are pretty good already, and since it works perfectly with the latest version of Pokemon Online, it's a lot of work just to slightly improve support for an outdated replay format.

    - Stat boosts in the form of "+3 Atk"
    -- There are a lot of people arguing both sides. BlueKirby, coyotte508, and I all think the "2.5x Atk" format is better, so that's the format I'm using for now. Having an option for something this minor really isn't feasible. Sorry. :(
    Q: I found a bug, now what?

    A: Make sure it's not discussed earlier in the FAQ. If it isn't, report it to this thread, and remember: If you are reporting a bug, please give a link to a relevant replay.
  2. JaySee

    JaySee

    Joined:
    Jun 28, 2010
    Messages:
    13
    It's a cool idea, but the flaws you've pointed out certainly hinder it from being too useful.

    Perhaps it could be used as a teaching tool in its current state, showing examples of scouting, prediction, risk & reward, etc etc.

    Very cool though! Definitely keep working on it. Maybe you could have Regenerator and Natural Cure be automatic on the pokemon that use them, as the pokemon that do always use them. (No more Own Tempo Slowbro or Serene Grace Blissey running around :P)
  3. toshimelonhead

    toshimelonhead Raising Whitney's Miltank

    Joined:
    Nov 24, 2009
    Messages:
    1,114
    I think this is a great tool. The only thing I would like to see is some type of complete status update for the rest of the team. I don't know how easy this is to program but this would make it easier to point out past mistakes instead of looking at a log.
  4. Crafty Scrafty

    Crafty Scrafty

    Joined:
    Jul 21, 2011
    Messages:
    53
    Looks great. However, whenever I try one of my logs, it starts out with my opponent sending out both of our leads on their side of the field and then it freezes. Know what the problem might be?

    The problem might be that these are Gen 3 games.
  5. Hawkstar

    Hawkstar Unplug me from this fantasy
    is a Contributor to Smogonis a SPL Winner

    Joined:
    May 23, 2010
    Messages:
    796
    It seems to act weird with weather starters switching in, regardless of if their weather is up or not. Every replay I've uploaded so far craps out around Turn 3, and they all seem to have the weather issue in common. Oddly, I can't fin any other replay that duplicates the problem. Besides that, I really like this thing. I have trouble visualizing stuff when reading logs, so I hope people start using this stuff for warstories.

    Edit: I also noticed that if a Pokemon behind a sub faints, it's faded silhouette stays for the remainder of the match.
  6. Chispy

    Chispy

    Joined:
    Jun 3, 2009
    Messages:
    199
    I think the best way to move it forward, simply, is to post it in the Developer's Den on Pokemon Online forums.

    You'll definitely get a lot of help and support there.
  7. Zarel

    Zarel Not a Yuyuko fan
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Pokemon Researcheris an Administrator
    Creator of PS

    Joined:
    Aug 16, 2011
    Messages:
    1,854
    Are you sure the flaws are that great? They haven't been a problem in any of the replays I've shown so far.

    I've implemented Regenerator for Mienfoo/Mienshao and Natural Cure for Staryu/Starmie; I'll wait for a better detection system before implementing it for other gens.

    Could you clarify what you mean by "complete status update"?

    Secure, as in private? Not so far. I'll eventually introduce a private replay option, but as for now I don't have one.

    Gen 3 is supported fine.

    PO replays don't tell you who's on which side, so I had to manually write detection code. It turns out my detection code didn't work well with spaces in your name. I've fixed that; your replays work now.

    http://aesoft.org/pokemon/replay-Tamaaa-vs-Crafty-Scrafty--2011-08-13
    http://aesoft.org/pokemon/replay-mark-all-vs-Crafty-Scrafty--2011-08-13
    http://aesoft.org/pokemon/replay-Crafty-Scrafty-vs-Treiner-Orenge--2011-08-14

    Was that the naming issue? I accidentally broke nicknamed pokemon while implementing the "number of pokemon left" indicator today.

    Are these the replays you're talking about?

    http://aesoft.org/pokemon/replay-jrrrrrrr-vs-Hawkstarr--2011-08-11
    http://aesoft.org/pokemon/replay-iconic-vs-Hawkstar--2011-05-14

    They seem to work fine after all the fixes I did today. Try refreshing it?

    Fixed.
  8. AfroThunderRule

    AfroThunderRule *yawn* ez
    is a Tiering Contributor Alumnus

    Joined:
    May 25, 2009
    Messages:
    1,143
    Seems cool, keep up the good work.
  9. Super

    Super This space for rent
    is a Battle Server Admin Alumnusis a Programmer Alumnusis a Forum Moderator Alumnus

    Joined:
    Jun 21, 2007
    Messages:
    1,148
    Dude, this is amazing. Mad props to you. I can tell you worked your ass off on this.

    Shame about what it can't do though.
  10. Hawkstar

    Hawkstar Unplug me from this fantasy
    is a Contributor to Smogonis a SPL Winner

    Joined:
    May 23, 2010
    Messages:
    796
    Yep! Works like a charm now. I didn't even pay attention to the fact they were all named as well.

    I haven't noticed anything else wrong with those two replays, so it looks really good! No more boring logs.
  11. Birkal

    Birkal woops, butter fingers :>
    is a member of the Site Staffis a Battle Server Administratoris an Artistis a Super Moderatoris a Community Contributoris a CAP Contributoris a Smogon Media Contributor
    CAP Head Mod

    Joined:
    Oct 12, 2010
    Messages:
    3,777
    What I could see being quite useful is the ability to speed up / slow down the matches! Then you could watch at your own pace. In the same vein, if you could "search" through different turns, that would be pretty spiffy. Just input that you want to start playing on Turn 20 and work from there.

    This is super cool and keep up the good work!
  12. Hipmonlee

    Hipmonlee Have a rice day
    is a Smogon IRC AOp Alumnusis a Super Moderator Alumnusis a Contributor Alumnusis a Battle Server Moderator Alumnusis a Past WCoP Winner

    Joined:
    Dec 19, 2004
    Messages:
    7,336
  13. Pidge

    Pidge

    Joined:
    Aug 26, 2005
    Messages:
    2,255
    This is great. I'll definitely be using this instead of reading a log next time.
  14. Pocket

    Pocket Apo, the astronaut's best friend >:3
    is a Site Staff Alumnusis a Team Rater Alumnusis a Forum Moderator Alumnusis a Community Contributor Alumnusis a Tiering Contributor Alumnusis a Contributor Alumnus

    Joined:
    Dec 22, 2004
    Messages:
    8,580
    Awesome work, aeo; this is amazing
  15. No Luck Involved

    No Luck Involved

    Joined:
    May 8, 2011
    Messages:
    1,788
    This is great stuff, I gave it a spin and I have to say it was really impressive and very fun to watch. Fantastic work!

    I put in one of my battles and here are some mistakes I observed:

    - Entei took way too much damage on turn 29/30, reducing its health to 0 when it should have been around 40%. I'm not sure what happened here...
    - It can't represent Leech Seed recovery very well (it must be nearly impossible to implement)
    - Scyther takes normal damage from Stealth Rock.

    This is a link to it for your reference: http://aesoft.org/pokemon/replay-MMF-test1-vs-No-Luck-Involved--2011-07-30

    I hope you will find this useful and I am really looking forward to this getting better and better because it is one of the most exciting things I have seen in a while. Hats off to you aeo!
  16. Zarel

    Zarel Not a Yuyuko fan
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Pokemon Researcheris an Administrator
    Creator of PS

    Joined:
    Aug 16, 2011
    Messages:
    1,854
    I just introduced a checkbox for uploading private replays!

    It will make your replays not show up on the replay list, and give the replay a URL that can't be guessed. It's not something ridiculously secure, though, so I wouldn't recommend uploading replays in which you talk about your plans to commit murder or anything like that.

    Yeah, that's been on the to-do list from the beginning. I'll do it eventually, but I can't promise anything anytime soon. :(
  17. Pocket

    Pocket Apo, the astronaut's best friend >:3
    is a Site Staff Alumnusis a Team Rater Alumnusis a Forum Moderator Alumnusis a Community Contributor Alumnusis a Tiering Contributor Alumnusis a Contributor Alumnus

    Joined:
    Dec 22, 2004
    Messages:
    8,580
    Yea, I also just uploaded a battle where I embarrassingly lost to a Bulk Up Toxicroak, but Stealth Rock damage did 13% for both Gyarados and Thundurus.

    http://aesoft.org/pokemon/replay-Thousand-Sunny-2nd-vs-Crametrain--2011-08-16

    Also, my opponent started out with 5 Pokeballs - is this because I did not saw the 6th monster of his team?

    And occasionally when I lose my mons, an extra Pokeball shows up on my side. I ended up with like 9 Pokeballs on my side lol.
  18. Zarel

    Zarel Not a Yuyuko fan
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Pokemon Researcheris an Administrator
    Creator of PS

    Joined:
    Aug 16, 2011
    Messages:
    1,854
    A pokemon's HP is set to 0 at the point the replayer believes is the last time it took damage before fainting - this is to deal with rounding errors.

    I forgot to include Flare Blitz recoil and Spikes as possible damage sources - this has been fixed.

    It currently estimates Leech Seed recovery by assuming both pokemon have the same HP stat. I can see it being off if you seed a Chansey or have Leech Seed lasting for tons of turns. Nothing I can do about that. :(

    Yeah. The replayer itself currently has no type chart, nor any idea what types pokemon are. Fixing that's on the to-do list, but I don't know if it'll be done anytime soon.

    ^_^

    Yeah, as mentioned, this is on the to-do list (it's been on the to-do list on the first post of this thread ever since it was first posted, incidentally).

    Yep. And because PO doesn't log any pokemon that doesn't get sent out.

    Yeah, it happens when something happens to your pokemon after they faint:

    Oceanborn fainted!
    Oceanborn had its energy drained!

    The replay viewer assumes it happened to a different still-alive pokemon named Oceanborn, and adds it to your team. I just fixed it.
  19. firecape

    firecape This is the end...
    is a Forum Moderator Alumnusis a Contributor Alumnus

    Joined:
    Mar 17, 2010
    Messages:
    1,048
    this is really cool, I can't even imagine all the work you put into it. Hopefully we can reward you with a small token of our gratitude soon enough.

    I wonder what this will do to warstories
  20. Oglemi

    Oglemi berlin,,, pls
    is a Tournament Directoris a member of the Site Staffis a Community Contributoris a Pokemon Researcheris a Contributor to Smogonis a Smogon Media Contributoris an Administratoris a Tiering Contributor Alumnus
    C&C Leader

    Joined:
    Oct 13, 2009
    Messages:
    8,786
    fucking brilliant aeo
  21. DanLite

    DanLite

    Joined:
    Jul 25, 2007
    Messages:
    85
    This is pretty sweet; it's impressive you've even added attack animations (simple yet effective!). They definitely help to visualize the flow of the battle.
  22. Pocket

    Pocket Apo, the astronaut's best friend >:3
    is a Site Staff Alumnusis a Team Rater Alumnusis a Forum Moderator Alumnusis a Community Contributor Alumnusis a Tiering Contributor Alumnusis a Contributor Alumnus

    Joined:
    Dec 22, 2004
    Messages:
    8,580
  23. Zarel

    Zarel Not a Yuyuko fan
    is a member of the Site Staffis a Battle Server Administratoris a Programmeris a Pokemon Researcheris an Administrator
    Creator of PS

    Joined:
    Aug 16, 2011
    Messages:
    1,854
  24. Darkaxis

    Darkaxis

    Joined:
    Jun 11, 2011
    Messages:
    710
    This is fucking awesome you a genious son Can you upload battle to youtube and such? becausethat would be pure epicness
  25. symphonyx64

    symphonyx64 Private messages are the best way to reach me
    is a Community Contributor Alumnusis a Smogon Media Contributor Alumnusis a Battle Server Moderator Alumnusis a Past WCoP Winner

    Joined:
    Sep 20, 2008
    Messages:
    1,131
    You can screen record it then upload it to Youtube. Although, I'm sure aeo has an export to video feature planned in the pipeline :P. If you could implement something along those lines, that would be super slick!
Thread Status:
Not open for further replies.

Users Viewing Thread (Users: 0, Guests: 0)