# Friend Safari calculator for XY?

## Recommended Posts

I wanted to try and figure out how X & Y determine Friend Safaris based off of friend codes. I've tried looking for this in a variety of places online (and even in a couple of different languages). A couple of people have suggested that they figured it out, but there's no proof anywhere that I could find. Most threads around this died a few years ago, but I figure some people might still be interested so I thought I'd ask about it here.

Here's what I have found out:

• Friend codes seem to be saved within the save file as a truncated 32-bit integer. In other words, the friend code is treated as a 12-digit base-10 integer & then stored in a 32-bit value. This is alongside some other data (like whether or not the 3rd slot is unlocked, or if you've unlocked hidden abilities).
• I did find the area in memory that lists the Pokemon in the Friend Safari in order. It's simply a list of 216 Pokemon (any Pokemon with a 50% chance of appearing for a given slot appears twice in the list). I uploaded the list as a text file, for anyone who's interested. It's split into sections, with each line representing one slot & the Pokemon are in the same order as in the game's memory. With the ROM I was looking at, the list starts at address 0x65EDEA, if you want to look for yourself.

I've tried a few different things using friend codes:

1) Using the friend codes directly (like XORing the high and low words, or XORing all of the bytes & then looking at the result mod 18)

2) Using the friend codes as a seed for the PRNG, and then doing more math on that result (more XORs & mod 18 math)

I haven't had any luck discerning any kind of pattern just using math & logical operators. Also, some people have suggested that the Friend Safari is based on additional factors (like region and/or birth date), although I'm not certain about that ... but if it's true, then it would be even more difficult to work it out this way.

The other approach, of course, is to look at the code's disassembly & try to figure it out from that side. Unfortunately, I'm not very good with disassembly, so my attempts there haven't met with any success.

Any thoughts?

##### Share on other sites
4 hours ago, iriomote said:

1) Using the friend codes directly (like XORing the high and low words, or XORing all of the bytes & then looking at the result mod 18)

2) Using the friend codes as a seed for the PRNG, and then doing more math on that result (more XORs & mod 18 math)

If it's anything like Mirage Spots (long thread with research and documentation),
It could have used friend codes to seed the Mersenne twister or something...
Probably too complicated IMO.

Barely relevant information:
We do have a Friend Safari Editor (Well, not exactly an editor, but an unlocker)

I think it only unlocks the third slot, if you already have friends on that device.

##### Share on other sites
13 hours ago, theSLAYER said:

If it's anything like Mirage Spots (long thread with research and documentation),
It could have used friend codes to seed the Mersenne twister or something...
Probably too complicated IMO.

Barely relevant information:
We do have a Friend Safari Editor (Well, not exactly an editor, but an unlocker)

I think it only unlocks the third slot, if you already have friends on that device.

Yeah - I actually found the relevant bits concerning the third slot & hidden abilities when I was playing around with save files a while back.

Anyway, this was purely a matter of curiosity - I haven't really touched Gen 6 for a while, and I've already collected all of the Friend Safaris that I really care about. It just seemed like an interesting problem.

• 1