Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"IVs are Predictible" Tweet / How in Capture Sight? #60

Closed
Th3Alic3 opened this issue Nov 8, 2020 · 8 comments
Closed

"IVs are Predictible" Tweet / How in Capture Sight? #60

Th3Alic3 opened this issue Nov 8, 2020 · 8 comments
Labels
discussion There's an idea up for discussion enhancement New feature or request

Comments

@Th3Alic3
Copy link

Th3Alic3 commented Nov 8, 2020

Hey Zak'sBeast!!

A few weeks ago you posted this tweet on Twitter:
https://twitter.com/zaksabeast/status/1320413720892276736

You mentioned "things like IVs are RNGable" which was then later clarified to "we can predict the outcome". You stated this is all able to be determined "right when the adventure starts": this implies once a Dynamax Adventure begins that all the predictible aspects should be able to be seen in the app for all 10 non-Boss encounters as well as the Boss encounter immediately.

However, Capture Sight currently is only able to display stats for the CURRENT Raid of the Adventure.

Is willthis impossible?
Will this feature be coming down the road?
(It just would be nice when you are trying to get a Legendary with specific Nature or ideal placement of the 4 force 31 IVs to be able to determine in Round 1 then reset without having to do all 4 Rounds for the reset. The menu would ideally should have a "DMax Boss Pokémon" listing if that's the case.)

(The new features are a fantastic addition! Keep up the AMAZING WORK!!)

@zaksabeast
Copy link
Owner

First, thanks for your support! I'm glad you enjoy the latest features.

It sounds like there are a few questions here, and I'll throw in one more:

  • Is it possible to show the stats for every Pokemon in a dmax adventure?
  • Why is this not currently in CaptureSight?
  • Will this feature be coming down the road?

The answers to the first two questions can be found in this response to your other issue.

The last question is an interesting one. I'm not opposed to adding it if there are enough people who want it. However as of right now, you're the only one who has shown much interest in it.

I'll keep this issue open as a discussion. If other people would like this feature, please comment!

If anyone would like to contribute this and has the ability to reverse engineer, I'd be happy to provide guidance and tell you the relevant locations in the game binary.

@zaksabeast zaksabeast added discussion There's an idea up for discussion enhancement New feature or request labels Nov 9, 2020
@Th3Alic3
Copy link
Author

Th3Alic3 commented Nov 9, 2020

I needed to put on my thinking cap... I just want to skim a few of the important points of this response.

There are two main points I will respond to:

  1. Non-Boss Pokémon
    The main point that I am touching upon here is that the "save-seeded xoroshiro" (PKHeX Block Data no: 0D74AA40) single-handly determines the list of Rental Pokémon & all 10 non-Boss Pokémon.

To further this statement, I would like to state that have used PKHeX to edit the "save-seeded xoroshiro" (PKHeX Block Data no: 0D74AA40) to re-produce previously visited pathways:
Kantonian Weezing in Round 3 (SEED value): 2289309487228189993
Porygon in Round 3 (SEED value): 17592585201234812322

The game will preserve the "save-seeded xoroshiro" in the event the host player terminates the Sword/Shield session prior to the game recording the Adventure as a Success or Failure. The NPC which you talk to enter Dynamax Adventures will make a small comment about your Adventure error then you can continue with that same "save-seeded xoroshiro" value.

This means that it is possible to RNG Manipulate to an extent the non-Boss Pokémon.

It's not the easiest RNG Manipulation to set-up but it is possible and I imagine some players would appreciate this option. Especially for Porygon/Regional Evolutions.

  1. Predictive IVs/Natures
    I am a competitive player. I absolutely understand that I am not the target audience but if there was a way in which by repetitive solo (aka 3 NPC Adventures) that I could set up a combination of IVs/Nature for the Boss Pokémon... I would love that. It's the only way of achieving "Perfect" Pokémon.

Thanks for listening!!

@zaksabeast
Copy link
Owner

Finding seeds for Pokemon

It sounds like the first ask is for a way to find specific seeds that can be edited into the save with PKHeX. This falls a bit outside the scope of CaptureSight, and would fall more in line with something like RaidFinder or Lean's web tool.

CaptureSight shows the current and future in-game state (what Pokemon is currently being battled? how many advances until a shiny den?), and rng desktop software has traditionally found potential possibilities (which seed will bring a 6IV legend in gen 4?). Searching for seeds the game can't currently reach based on specific criteria is less about the current/future state and more of potential possibilities.

Most people in Pokemon raid and rng communities don't see editing the save file as true rng manipulation (yes, arguably it is - people different contexts, such as outside the Pokemon community, would agree), which might be why a seed searcher hasn't been added to any of the gen 8 tools yet.

However if you are interested in this, I'd suggest opening issues on those other tools to see if anyone is open to adding it.

Repetitive IVs/natures

Sadly IVs/natures aren't repetitive. One of the main reasons crypto secure prngs exist is to prevent knowing past and future random numbers. Since the non-csprng used to generate Pokemon is seeded with a csprng when the adventure starts, it's not possible to manipulate the IVs/natures, nor is it possible to know what the IVs/natures will be until after the adventure has started. However once the non-csprng is seeded, we can know what the stats are for the current dmax adventure Pokemon.

It is possible to selectively reset the adventure after seeing the IVs/natures and get new IVs/natures on the next adventure. This is how Gen 7 RNG worked before I figured out seed rng with Citra: use the rng mechanics with the current seed to predict results, then get a new seed if the upcoming results aren't desirable.

However most people probably don't see it that way for dmax adventures since there's little control after the prngs are seeded.
The exception is manipulating species with NPC counts, but that doesn't help with the IVs/natures.

Thanks for the questions!

@Th3Alic3
Copy link
Author

Th3Alic3 commented Nov 9, 2020

  • Finding "Seeds"
    I was more using this to demonstrate the Rental Pokémon/10 non-Boss Pokémon are 100% determined by the "save-seeded xoroshiro". You choice in wording of the response made it sound to the contrary.

  • Repetitive IVs/natures
    Noted

  • Start of the Raid
    There's been a lot discused here which due to it being tied into the other inquires has obsured this topic's inquiry and I am unsure if this specific post's inquiry was answered. The response directing to the mechanics spoke to every point but my actual inquiry in this thread.

I asked specifically in this thread about the timing of the SEED of the randomizers. I was asking if it IS specifically between the Start of the Adventure and the start of the 1st Round of Raids? Essentially, should it be possible with the right tools to know the stats of all the Pokémon you would encounter in the Dynamax Adventure (obviously excluding Shiny-status.)

If so, I am asking if one day we could have an option added to Capture Sight called something like "Current Adventure", which just shows the "at that point" fixed stats (IVs/Natures/Gender... Ability is less relevant with the new Ability Patch) for all the Dynamax Adventure Pokémon.

This would potentially influence some routing a CFW party would take when navigating Dynamax Adventures with Capture Sight.

There are only two possibilities here and both would provide a huge benefit to Capture Sight if added to the app down the road:

  1. The game determines stats for 4 Pokémon which it assigns in some order to the 4 you encounter you would encounter (assuming you make it to the Boss.)
    OR
  2. The game determines stats for all 11 Pokémon (including the Boss.)

Regardless of how the game actually works here, when you are playing with other CFW players also using Capture Sight OR solo with Capture Sight it would potentially influence your path. You may intentionally go out of your way for that Round 2 Pokémon with six 31's!!!

(I am not even concerned with the Next Adventure. I am just speaking from the current Adventure and current Adventure alone since a lot of encounters in an Adventure's path are impossible after you choose the mon in Round 1 between Slot 1 & Slot 2.)

@zaksabeast
Copy link
Owner

I was more using this to demonstrate the Rental Pokémon/10 non-Boss Pokémon are 100% determined by the "save-seeded xoroshiro". You choice in wording of the response made it sound to the contrary.

Gotcha. Yep, the Pokemon templates (species, moves, etc.) are determined by the save seed. This is the reason CaptureSight can show the next dmax adventure before it begins.

There's been a lot discused here which due to it being tied into the other inquires has obsured this topic's inquiry and I am unsure if this specific post's inquiry was answered. The response directing to the mechanics spoke to every point but my actual inquiry in this thread.

I asked specifically in this thread about the timing of the SEED of the randomizers. I was asking if it IS specifically between the Start of the Adventure and the start of the 1st Round of Raids? Essentially, should it be possible with the right tools to know the stats of all the Pokémon you would encounter in the Dynamax Adventure (obviously excluding Shiny-status.)

If so, I am asking if one day we could have an option added to Capture Sight called something like "Current Adventure", which just shows the "at that point" fixed stats (IVs/Natures/Gender... Ability is less relevant with the new Ability Patch) for all the Dynamax Adventure Pokémon.

Correct me if I'm wrong, but I'm reading this as, "Will CaptureSight be able to show IVs for Dmax Adventure Pokemon at some point in the future?" This is the question I was answering in my first comment.

I'm not opposed to adding it if there are enough people who want it, but there haven't been many people who have asked for it so far. I'm going to keep this issue open as a discussion for a while to see if anyone else comments about wanting this to be added. Alternatively, I'm 100% open to a PR if someone else would like to add it.

@Sotam
Copy link

Sotam commented Mar 24, 2021

Hi all, especially @zaksabeast. So I've reading some of these issues regarding IVs and Max Lair/Advanture and I was wondering if there are any offsets know to calculate/read the IVs?

If I understand correct: the CSRNG at the start of the adventure seeds a non-CSRNG and that is used to generate more mons. But it's not used like it's been used with the dens (not repetitive). There is a higher level non-CSRNG that generates a mon, right? Some psuedo code could be:

// Unpredictable CSRNG
var csrng = new CryptoRNG();

var rng = new xoroshiro(csrng);

var mon1 = new xoroshiro(rng);
..
var legendary = new xoroshiro(rng);

But this feels to good to be true (and probably is). So I was wondering if there is any documentation or offsets about this subject, that can be used to create a PR :-)

I was also thinking about getting the seed of the first 'mon and then do some backwards calculation (if possible), but that would only work (I think) if the above psuedo code is somehow correct.

@zaksabeast
Copy link
Owner

Hey @Sotam, sorry for the late response, and thank you for your interest in contributing!

The IVs are generated when the Pokemon is, so the IVs can't be read until the player is in a battle with the Pokemon.

As far as calculating the IVs ahead of time, you seem to have the right idea. A csprng rand seeds a xoroshiro, and the rands from the xoroshiro seed other rngs that actually generate the Pokemon.

The first xoroshiro seeds rngs that generate the rental Pokemon as well. You might be able to go backwards to get the seeds for each Pokemon and use those to get the csprng rand that seeded the first xoroshiro, but there's an easier way.

All rngs have an internal state that is used to calculate random numbers: a xoroshiro has two u64s for its internal state. If someone knows the two u64s that make up the state of a xoroshiro, they can predict all upcoming rands.

We don't need to work backwards to get the first xoroshiro's initial seed - we only need its current state. Having the initial seed would allow us to get the IVs of any Pokemon that has already been generated, but we already know those values. If we have the xoroshiro's state, we can predict upcoming IVs without needing to go backwards.

The first xoroshiro's state moves around in memory (the offset relative to the heap is different every time the game starts), so you'd need to find a pointer to the xoroshiro's state, then read the state.

I only looked into this briefly because there wasn't a huge amount of interest, so I didn't spend much time trying to find a stable pointer.

@zaksabeast
Copy link
Owner

Closing due to discussion inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's an idea up for discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants