24 bytes per object -> 16 bytes
2,624 objects are made for legality checking; reduces from 73KB to 41KB
removing unnecessary clone recreation -> count from 2624 -> 414 (41KB to
6.6KB)
yay 10x reduction; not huge in the big picture but a fun exercise
remove linq for characteristic calc (get max IV) and others
remove some reliance on new[] for iv/ev
pk5 replace bitmagic with property get->set copy for cleanliness
the ereader mons are nature/gender locked too, so unroll a little prior
to rechecking the overall team (with ereader mon included). Have to do
it this way as a lock can pop if the ereader data matches a prior spread
before the prior teammate can be generated.
Unused after assignment, but if I rework the validation check to return the teamlock result instead of a bool I can spit out the Species-PID generated list as extra info. Helps identify the as-generated conditions if there are multiple teamlocks possible for an encounter (multiple shadow mons, seen vs unseen).
Now accounts for the shiny locks & associated restrictions, abusing the
recursion by setting & unsetting the required CPU Trainer's shiny value.
Repoint all test methods to use the new obj methods
A lot of internal information is nice to have saved; create a copy of
the static class's logic and pepper in some state variables (Required
CPU Shiny Value) to account for the weird edge cases.
Code is essentially the same as the static methods, except for more
fleshed out logic in the AllLock interrupt checking and the eventual
Trainer checks.
Now gets count=2 tests working
yield return new SeedFrame { FrameID = ctr + (l.Seen ? 5 : 7), PID = pid
};
used to be ctr + 6, needs to alternate even-odd
all 2 lock cases pass, but didn't make lock3's pass. Something else is
still amiss :)
break out some classes for the solidified lock objects
Check max case for level first, then iterate upwards (eliminates inner
if)
change wc* nature to sbyte (update comparisons, 0xFF too magic-y)
use Rand.Next(x) instead of (0, x)
commented out test calls = not working
will have to debug in more detail later; the first lock is always
working at least.
data sourced from
https://github.com/ijuintekka/Eligor/blob/master/Eligor/Spread.cs , not
sure if it's perfect.
can't cleanly condense deviating team appearances as double-shadow leads
can't be selectively encountered. didn't feel like modding lockfinder's
recursive algo to be smarter.
Store 4g giratina held item for enc->pkm legality
revise usages of GetSaneGender
Rearrange some logic
Better handle impossible version encounters (gen4)
gen 1-5 done, stuck on 659 - bunnelby egg...?
Fixes Krabby / etc.
Fix genderless encounterstatic gender set (Voltorb)
Now at 103, Exeggutor
pretty cool that over 100 species can have every single encounter
generate a legal pkm ;)
might be useful to add metrics to count how many encounters are
generated in a session
Fix/add missing gameversion references (BU instead of BW,
pokewalker=HGSS)
increase reuse of pidgenerator & add more generating methods.
seems like it's generating pkm fine besides the PID edge cases, which is
nice
Gen5 does not follow the same convention, 0 = non, 1 = rnd, 2 = always;
not gonna bother updating for just that one
bool? occupies 2 bytes; enum:byte is 1 byte.
should probably move validity checking logic into the IEncounterable
objects instead...
tested for 2 locks, later commits with legality check implementation
will feature more lengthy lock checks (test case automation).
https://pastebin.com/VdbjWaqL
(species doesn't matter since most are 50/50 ratio)
arbitrary access for RNG frame results, only generating frames when the
frame is unavailable. all calculated frames are cached.
to be used in RNG searching where caching seeds is necessary (repeat
checks)
dynamic level -> calc level
no sweet scent -> proc available (rock smash/fish)
change frame checking in encountergenerator to save which frame it was
found on (unused but possibly later can capture this for output)
Turns out there was no documentation anywhere on encounterslot numbers
for the individual forms; some sites had overall rates.
Assuming a human filled out the encounter slots, forms would repeat left
to right until a new form takes over. Below slot numbers match the rates
when summed up.
https://pastebin.com/raw/bQt3ZMbq
since there's 300 calls to rand to shuffle, I wouldn't be surprised if
there are vblanks messing up the frames
judging from my data 6 years ago (wow, still wrong, just look at the
frame offsets)
http://www.smogon.com/forums/threads/past-gen-rng-research.61090/page-35#post-4021415
looks like it happens quite erratically. may have to just override this
to return true for all gen3 safari mons as it's entirely unpredictable.
via pret/pokeemerald (and pokeruby); rate is set at 50%
swarm pokemon have the ability to have 4 fixed moves, so derive from
EncounterSlot to have moves, and remove special handling from
VerifyCurrentMoves (now picked up by IMoveset pattern
allows hgss safari mons regardless of frame call (table is currently all
Slot=0).
may need separate handling down the road:
* switch slot number to an enum for slot codes (>0 = slot number, less
than -> do something else).
not something im interested in right now
fix roamer3 not setting IVs
fix usum z items rightmost pixel getting chopped off
use Gen* instead of GenNumber for specific cases (faster)
add WasGiftEgg location case for Gen7
remove some unnecessary array allocations
force colo starters to be male only
use some c# lang features for EncounterType flags
add edge case PIDIV detection for starter gender/shiny lock scenario
adds a little documentation for those unfamiliar with the NPC PKM
generation quirks.
Colosseum Starters will now be recognized with a different PIDIV type
which is specific to them & them only.
check the middle bits for signs of pokewalker origins
can either be regular or adjusted underflow style
saves a little bit of computation time by not computing compatibility
for obvious non-matches
refer to stackexchange links, makes XDRNG PID/IV search so quick (2^3
instead of 2^8 or 2^16; as fast as a gen3 shiny pokemon (2^13=8192 times
as fast as last release)
throw in some auto-inlining to eliminate some overhead in repetitive
search calls
Only usable for searching Method 4 IV spreads -> seeds;
1,3's search uses the same approach as the 1,2 search
I took the 1,2 search derivation to iterate for the next step, which
allows us to not know anything about the middle rand bits.
optimize a little bit more, move the pre-loop add to the initialization
stage; moving to the precomputed section pays off after 256 calls to the
method
Meet in the middle attack trades some RAM (2^16 flag/byte array) to
reduce future searches by a factor of 1:2^8
profiling yielded >100x speed improvements, even a 2x would have been
impressive ;)
knocks the biggest cpu hog (when searching db) out of the race!
shifts encounter data from Legal's split tables to individual files for
easier maintenance and initialization. Legal Core's init is so much
simpler now.
fix resource name typo
fixes 10ANIV pikachu having Thunderbolt twice
un-duplicates CHANNEL event data
adds seed->PIDIV generator template for M1/2/4, CXD, Channel, and BACD
improve pkm converter to update nickname of hatched eggs. isn't perfect
(farfetch'd) but works better than before
Not allow cutecharm pid iv method for swarm pokemon
Fix loading time encounter for generation 2 and mark crystal location slots in any gen 2 tables
Typos in tree areas comments
Add special ribbon detection (for wc3),
speed up seeds from IVs calc (flip top bit of seed to get the result for
other iteration)
Add a bunch of gen3 event data
Detect channel, only detect Channel PIDIV for RS origin (only really
care about method1/2/4 being used when it shouldn't)
Channel does this weird thing called not setting the met level.
Refactor set suggested met location to a method that can suppress
popups.
encounterinvalid isegg no longer throws exceptions when parsing moves
dropping invalid file paths to main window are now ignored (downloads
from chrome can be manually deleted but still dragged from the downloads
bar)
add pidiv case for manaphy gift
More elegant handling for PKM without nicknames that have another
language species name; use that language ID instead of the pkm's
language ID. Since ToLower is not called, Ho-Oh from 3/4->6 now
transfers correctly.
fix gen3 encounterstatic eggs while still on gen3 games; only check the
egg location if still an egg
tighten up gen3 PIDIV compatibility checks, roamer glitch is fixed on
Emerald, and static encounters can't get method 2, and can only have
method 4 if under software emulation (RS Box) since the emu speed is
faaaaast 🚤 /s
Fixes HGSS egg moves, and improves encounter detail detection.
example: togepi from FRLG transferred up, old detection couldn't
differentiate the gift egg from a regular egg; however, PIDIVs can lend
a hand -- eggs don't have a PIDIV!
fixed shiny BACD spread detection (in regards to antishiny rerolls).
Shiny WISHMKR now detected correctly.
re-letter for clearer order of RNG results, don't unroll 3x to roll
forward 2x (just unroll 1,1 then 1).
Put origin seed in RNG Reporter => frame 1 result
Closes#1169