# Auto-evolve issue

**URL:** <https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843>\
**Category:** Bug Reports\
**Created:** [May 20, 2022, 2:37pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843 "2022-05-20T14:37:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![suppressor666](https://thrivecommunity-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@suppressor666](https://community.revolutionarygamesstudio.com/u/suppressor666)\
**Post date:** [May 20, 2022, 2:37pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/1 "2022-05-20T14:37:22Z")

</div>

the auto evolve stop the game from loading in the last devbuild

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [May 20, 2022, 2:42pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/2 "2022-05-20T14:42:09Z")

</div>

Even today’s build (7b398a0fb2edda7af163146e521453f44ca2ab5c)? If it’s still happening then there is another getting stuck issue I need to fix, which I haven’t been able to trigger myself. I’d appreciate any save files people might have that has a relatively high chance to get stuck within a few generations.

---

<div class="post-metadata">

**Author:** ![suppressor666](https://thrivecommunity-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@suppressor666](https://community.revolutionarygamesstudio.com/u/suppressor666)\
**Post date:** [May 20, 2022, 3:58pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/3 "2022-05-20T15:58:45Z")

</div>

it is for today’s build, I played for about 30 min and then the game was stuck in the auto evo loading

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [May 20, 2022, 7:42pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/4 "2022-05-20T19:42:24Z")

</div>

I guess I need to look into it more. I can’t do much if starting new freebuild games and running them for a few generations each doesn’t cause the problem. So unless someone provides a save, at least a basic auto-evo exploring tool needs to be made to make automating running auto-evo until it gets stuck easy.

---

<div class="post-metadata">

**Author:** ![suppressor666](https://thrivecommunity-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@suppressor666](https://community.revolutionarygamesstudio.com/u/suppressor666)\
**Post date:** [May 20, 2022, 7:51pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/5 "2022-05-20T19:51:24Z")

</div>

how can I provide a save ?

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [May 20, 2022, 8:07pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/6 "2022-05-20T20:07:05Z")

</div>

Make a save. And then check that loading it and playing a few generations has a chance to get the game stuck. Once you have that save, upload it to any of the billions of file hosting sites out there for downloading.

---

<div class="post-metadata">

**Author:** ![Leinourdian](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/leinourdian/32/7656_2.png) [@Leinourdian](https://community.revolutionarygamesstudio.com/u/Leinourdian)\
**Post date:** [May 27, 2022, 6:47pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/7 "2022-05-27T18:47:34Z")

</div>

I don’t have a save but I found another way to reproduce this. If you go to Constants.cs and set `MUTATION_BACTERIA_TO_EUKARYOTE = 0.5f` and `MUTATION_DELETION_RATE = 0.5f`, then auto-evo gets stuck very often and it only takes one to three tries of auto-evo to get stuck. I also tried printing miscellaneous things into the console and found the following about the while loop (lines 256 – 303) in [Thrive/Mutations.cs at master · Revolutionary-Games/Thrive · GitHub](https://github.com/Revolutionary-Games/Thrive/blob/master/src/general/Mutations.cs)

- minDistance (the smallest distance between main hexes and island hexes I think) can sometimes be 1. This seemed to always lead to minSubHex of (0, 0) and an infinite loop even with Hhyyrylainen’s fix.

- minDistance of 2 can sometimes lead to minSubHex of (0, 0). I think this happens if minSubHex is (1, 1) or (-1, -1) before line 285. I don’t know if this can get auto-evo stuck.

- Island hexes can move in one direction in an infinite loop but the minDistance stays as 1

- Main hexes can move with the island hexes

- Main hexes can be next to island hexes before and after moving

- Hhyyrylainen’s fix does prevent the infinite loop in some cases

I don’t really have any idea why these things happen. It seems that you can prevent the infinite loop by exiting the while loop if minDistance = 1 or if the loop has gone through too many iterations. That would be simple quick fix if no one knows how to fix the weird issues themselves. I don’t know if there are other ways to get stuck, though. It’s hard to prove a negative.

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [May 27, 2022, 7:06pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/8 "2022-05-27T19:06:01Z")

</div>

> [@Leinourdian](#):
>
> I don’t really have any idea why these things happen. It seems that you can prevent the infinite loop by exiting the while loop if minDistance = 1 or if the loop has gone through too many iterations. That would be simple quick fix if no one knows how to fix the weird issues themselves.

Yeah, I guess we’d still be better off than before the new islands avoiding mutations code. We can just go back to the old approach where after some number of iterations the mutation is just reset entirely.

Now that I’m thinking about it, would it be possible to calculate the direction to move _per hex_ so that there isn’t a symmetry problem? PR / code fix suggestions welcome.

---

<div class="post-metadata">

**Author:** ![Leinourdian](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/leinourdian/32/7656_2.png) [@Leinourdian](https://community.revolutionarygamesstudio.com/u/Leinourdian)\
**Post date:** [May 27, 2022, 8:57pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/9 "2022-05-27T20:57:07Z")

</div>

> Yeah, I guess we’d still be better off than before the new islands avoiding mutations code. We can just go back to the old approach where after some number of iterations the mutation is just reset entirely.

Yeah, you could use both together. Auto-evo only gets stuck a small portion of the time, usually the island fixing code works. So you could run the new island code and if that takes too many iterations, then reset.

I’m sure there are ways to solve the symmetry problem etc. I don’t really understand this stuff well enough to know how to do it. I’ll let you know if I come up with something.

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [May 28, 2022, 7:22am UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/10 "2022-05-28T07:22:47Z")

</div>

> [@Leinourdian](#):
>
> I’m sure there are ways to solve the symmetry problem etc. I don’t really understand this stuff well enough to know how to do it. I’ll let you know if I come up with something.

What about my suggestion that the code just doesn’t calculate all of the hexes to move at once? Instead just calculating the move direction for each island organelle separately and move that in the needed direction.

Edit: opened an issue:

> <https://github.com/Revolutionary-Games/Thrive/issues/3373>
>
> Seems like my fix to the islands fixing code can still get stuck in some cases.
> …
> 
> My guess as to how this could be fixed: what if the code just doesn’t calculate all of the hexes to move at once? Instead just calculating the move direction for each island organelle separately and move that in the needed direction. That way the symmetry related not knowing how to move code shouldn't be able to happen.
> 
> https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/7?u=hhyyrylainen

---

<div class="post-metadata">

**Author:** ![Leinourdian](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/leinourdian/32/7656_2.png) [@Leinourdian](https://community.revolutionarygamesstudio.com/u/Leinourdian)\
**Post date:** [June 3, 2022, 5:31pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/11 "2022-06-03T17:31:57Z")

</div>

> [@hhyyrylainen](#):
>
> What about my suggestion that the code just doesn’t calculate all of the hexes to move at once? Instead just calculating the move direction for each island organelle separately and move that in the needed direction.

I tested that and still got the same problems. This doesn’t appear to be caused by symmetrical islands.

I found another way to fix the issue and made a PR:

> <https://github.com/Revolutionary-Games/Thrive/pull/3378>
>
> \*\*Brief Description of What This PR Does\*\*
> 
> I found two problems that caused t…he issue. First, the code didn't always recognize island hexes correctly meaning that they could be next to main hexes. Second, the code could calculate the movement path incorrectly if \`minSubHex.Q == minSubHex.R\`. This PR fixes both of them. I tested this quite a bit and think that auto-evo should now never get stuck.
> 
> \*\*Related Issues\*\*
> 
> Fixes #3373
> 
> \<!-- List all issues this PR closes here with the closes syntax: 
> https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
> If this is not related to an issue, it should be described in more detail why this PR is needed here instead.
> \--\>
> 
> \*\*Progress Checklist\*\*
> 
> Note: before starting this checklist the PR should be marked as non-draft.
> 
> \- \[x\] PR author has checked that this PR works as intended and doesn't
> break existing features:
> https://wiki.revolutionarygamesstudio.com/wiki/Testing\_Checklist
> (this is important as to not waste the time of Thrive team
> members reviewing this PR)
> \- \[x\] Initial code review passed (this and further items should not be checked by the PR author)
> \- \[x\] Functionality is confirmed working by another person (see above checklist link)
> \- \[x\] Final code review is passed and code conforms to the 
> \[styleguide\](https://github.com/Revolutionary-Games/Thrive/blob/master/doc/style\_guide.md).
> 
> Before merging all CI jobs should finish on this PR without errors, if
> there are automatically detected style issues they should be fixed by
> the PR author. Merging must follow our
> \[styleguide\](https://github.com/Revolutionary-Games/Thrive/blob/master/doc/style\_guide.md#git).

By the way, it seems that auto-evo is about twice as slow as in 5.8.1. on my computer. This is the case with and without my changes. I’m wondering if some PR between now and 5.8.1. release made auto-evo slower.

---

<div class="post-metadata">

**Author:** ![hhyyrylainen](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/hhyyrylainen/32/32_2.png) [@hhyyrylainen](https://community.revolutionarygamesstudio.com/u/hhyyrylainen)\
**Post date:** [June 3, 2022, 6:26pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/12 "2022-06-03T18:26:26Z")

</div>

> [@Leinourdian](#):
>
> By the way, it seems that auto-evo is about twice as slow as in 5.8.1. on my computer. This is the case with and without my changes. I’m wondering if some PR between now and 5.8.1. release made auto-evo slower.

The only thing that really changed auto-evo was that islands PR, and then a slight math change was done to the organelle efficiencies, but that latter one shouldn’t really affect the overall amount of math that much. Have you changed the background thread counts or something like that in the options menu?

If you are up for it, you could do a git bisect to find the merge commit that introduces the problem, it shouldn’t be more than like 10 commits you need to test in that case.

---

<div class="post-metadata">

**Author:** ![Leinourdian](https://thrivecommunity-cdn.b-cdn.net/user_avatar/community.revolutionarygamesstudio.com/leinourdian/32/7656_2.png) [@Leinourdian](https://community.revolutionarygamesstudio.com/u/Leinourdian)\
**Post date:** [June 3, 2022, 8:19pm UTC](https://community.revolutionarygamesstudio.com/t/auto-evolve-issue/4843/13 "2022-06-03T20:19:04Z")

</div>

My settings were exactly the same, so that’s not the cause. Would be interesting to know if others get the same issue. I can try to do a git bisect.
