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

autoGodzamok, autoSL & autoRigidel #45

Merged
merged 14 commits into from
Oct 22, 2020
Merged

autoGodzamok, autoSL & autoRigidel #45

merged 14 commits into from
Oct 22, 2020

Conversation

Mtarnuhal
Copy link
Owner

Fix #18 autoSL + autoRigidel bug where sugar lumps were collected to quickly
autoGodzamok Sane & Insane options Restored

Seems Auto harvest, and auto rigidel+harvest attempt to harvest a sugar lump just a teensy bit before it's actually ripe, therefore botching the harvest in half the cases. Game.timetoRipe returns a float number in some cases, so adding Math.ceil to the Game.timeToRipe in the equations should give it just enough leeway to make sure it computes the correct millisecond. (It's my theory anyway. The math seemed to have come out ok when I paper tested).
With thnx to @Darkroman
Attempt to restore the autoGodzamok Sane and Insane options.
Has to be tested to make sure everything behaves as it should.
Second try
And some minor changes to make it more efficient.
safeBuy instead of visually change the buy-sell option.
Changing the variable should be enough.
Third try
Preventing the sell of cursors and farms while Devastation is active.
finalizing autoGodzamok
Copy link
Collaborator

@adavidw adavidw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, with autoGodz, your intent is that nothing will be rebought unless you have it in insane mode, correct?

Here's the three behaviors as coded in this PR:

  1. Sell the cursors and farms. Don't buy any more. If more cursors and farms appear during the devastation buff (like from user purchases or auto buy) sell those too.
  2. Sell the cursors and farms. Don't buy any more. Don't do anything else during the devastation buff. If more cursors and farms appear during the devastation buff (like from user purchases or auto buy) nothing will happen to those.
  3. Sell the cursors and farms. Rebuy the amount that was sold. Repeat continuously during the buff.

Is that the intent for all?

As an aside, I actually completely rewrote AutoGodz in my dev branch to auto calculate whether there would be a positive payoff based on the current click rate, then to auto-cycle buying and selling just cursors in smaller amounts (1/10 of the actual initial sale) to jack up the buff before buying them all back at the end.

It's not quite ready for a PR, though, because I'm still tweaking to get the right balance between wanting it to be net positive all the time and making sure it's getting the highest buff. Take a look, though, if you want to see what I'm doing.

@Mtarnuhal
Copy link
Owner Author

The Intent of autoGodz is to trigger on Clickfrenzies or Dragonflight.
Selling all of the cursors and farms.
Normal mode it will keep selling them no matter what. which is not ideal.
Sane mode stops selling them if devastation is active. It will sell again if Clickfrenzie or Dragonflight is still active.
Insane mode will quickly sell and buy the sold amount. Which is ridiculous and should not be used.

I think Sane mode is what should be kept in the code.

I've just checked and selling the farms doesn't increase the percentages on the buff.
Selling 500 cursors and 500 farms gives me a 500% buff and selling only 500 cursors also gives me a 500% buff.

As of your rewrite autoGodz looks promising I'm looking forward to a finished version.
I think it's best to wait till you finished then with the rewrite of the autoGodz.

Maybe we should setup a discord to discuss certain behaviors of the game and the intended code of Frozencookies

@adavidw
Copy link
Collaborator

adavidw commented Oct 21, 2020

Yeah, I'm up for a Discord or something. In terms of intended behavior, I don't see much need for the three modes. For the moment, let's ignore my experiments in maximizing gain. If I wasn't doing that, here's how I think I would do it (to keep it as simple as possible:

  • AutoGodz has one mode, and it's either off or on
  • If AutoGodz is on and a click buff is active, but Devastation is NOT active:
    • sell the cursors and farms
    • then, if autoBuy is turned on, the user has already signaled their intent to have things purchased for them, so rebuy what you sold (up to the limit if any limit is set). Otherwise, don't rebuy anything.

And are you sure about the farms not adding to the bonus? The graphic on screen won't update, but when you call Game.buffs["Devastation"].multClick after selling some more buildings, the value is added.

@Mtarnuhal
Copy link
Owner Author

Ok i'll setup a discord for the development of this addon. ill update it on readme.md when ready.

I totally agree with you to keep it as simple as possible.
annoying that it doesn't update the graphics.
with Game.buffs["Devastation"].multClick I was seeing an increase when selling more buildings.
6 for 500 cursors and 11 for 500 cursors and 500 farms.

I'll make the necessary changes.

@Mtarnuhal
Copy link
Owner Author

Just to clarify further.

  • If AutoGodz is on and a click buff is active, but Devastation is NOT active:
    • sell the cursors and farms
    • then, if autoBuy is turned on, the user has already signaled their intent to have things purchased for them, so rebuy what you sold (up to the limit if any limit is set). Otherwise, don't rebuy anything.

Should the bought buildings be sold because Devastation is active? to gain more as seen in Game.buffs["Devastation"].multClick
OR
Should the bought buildings not be sold because Devastation is active?

@adavidw
Copy link
Collaborator

adavidw commented Oct 21, 2020

For the duration of that one devastation buff, there should be no more further selling of buildings.

If buildings were sold (triggering a buff), then rebought, everything just sits there for the duration of the ten seconds. When that's expired, if there's still a dragon flight or click frenzy active, the cycle might repeat.

This mimics the "sane" mode of the previous implementation as far as I know just with the added bit of buying the buildings back in one bunch if auto buy is already on, rather than waiting for auto buy to buy them back one at a time (as would happen if the autogodz function didn't do the buying.

simplified autoGodzamok.
- If AutoGodz is on and a click buff is active, but Devastation is NOT active:
   - sell the cursors and farms
   - if autoBuy is turned on, the user has already signaled their intent to have things purchased for them, so rebuy what you sold (up to the limit if any limit is set). 
   - Otherwise, don't rebuy anything.
Removed Sane and Insane mode from autoGodzamok cause they were removed.
Reversed the variables of buy back
Copy link
Collaborator

@adavidw adavidw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you left 1 farm behind when selling the farms. buying farmMax farms in line 2200 will end up with one farm over the limit. Should probably be
safeBuy( Game.Objects['Farm'], FrozenCookies.farmMax - 1 );

@Mtarnuhal
Copy link
Owner Author

Since you left 1 farm behind when selling the farms. buying farmMax farms in line 2200 will end up with one farm over the limit. Should probably be
safeBuy( Game.Objects['Farm'], FrozenCookies.farmMax - 1 );

Yeah true but this way you get the full 500% potential instead of the 490% you would get if you sold 499 farms

Used the wrong parameter
@Mtarnuhal
Copy link
Owner Author

We should also take a look at the recommendation list cause it is getting out of wack due to the limit on the cursors, farms, and wizard towers.
image

Copy link
Collaborator

@adavidw adavidw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to look at the limit that's set because otherwise you'll way overbuy. If I have 300 cursors when AutoGodz kicks in, but a limit of 500 cursors, this way it will try to buy 500 cursors after selling.

Should probably check both things though, because I think you might be able to have a limit number set, but have the ability to use the limit turned off. Here's what I was using before:

            if ( FrozenCookies.autoBuy == 1 ) {
                if (Game.Objects.Cursor.amount < 10) {
                    if ((FrozenCookies.cursorLimit) && countC > FrozenCookies.cursorMax) {
                        safeBuy(Game.Objects['Cursor'], FrozenCookies.cursorMax);
                        logEvent("AutoGodzamok", "Bought " + FrozenCookies.cursorMax + " cursors");
                    } else {
                        safeBuy(Game.Objects['Cursor'], countC);
                        logEvent("AutoGodzamok", "Bought " + countC + " cursors");
                    }
                }

                if (Game.Objects.Farm.amount < 10) {
                    if ((FrozenCookies.farmLimit) && countF > (FrozenCookies.farmMax - 1)) {
                        safeBuy(Game.Objects['Farm'], FrozenCookies.farmMax - 1);
                        logEvent("AutoGodzamok", "Bought " + (FrozenCookies.farmMax - 1) + " farms");
                    } else {
                        safeBuy(Game.Objects['Farm'], countF);
                        logEvent("AutoGodzamok", "Bought " + countF + " farms");
                    }
                }
            }

And to your other point, the buff multiplier is set when the buildings are sold, so buying an extra one would only help on the next buff, not the current one. And each building is only +1%, so buying the extra one would give you +500% instead of +499%, which translates to a multClick value on the buff of 6 instead of 5.99. Not a significant difference, and it would look to the user to be an error if they started the click frenzy/dragonflight with 500 farms and ended with 501.

@Mtarnuhal
Copy link
Owner Author

For some reason, I was thinking about every 10 buildings = 1%.
Also, I don't think you need to check if the building is under 10.
This just makes it an extra unnecessary step.

Extra check if the limit doesn't exceed the current buildings.
@adavidw
Copy link
Collaborator

adavidw commented Oct 21, 2020

That <10 thing was in the code before, so I left it as an extra check in case the sell failed and the cursors/farms didn't actually get down that low. If the sell failed, you'd essentially double your existing cursors/farms.

I don't know if it's possible for the sell to fail, though. Sure, a buy can fail if you don't have cookies in the bank, but is there any scenario where a sell can fail? I can't think of one, so you're probably right that it's pointless.

Forgot to add -1 to the buyback of farms
@Mtarnuhal Mtarnuhal merged commit b1c8477 into master Oct 22, 2020
@Mtarnuhal Mtarnuhal deleted the dev-1 branch October 22, 2020 09:26
adavidw added a commit to adavidw/FrozenCookies that referenced this pull request Oct 23, 2020
* autoGodzamok, autoSL & autoRigidel (Mtarnuhal#45)

* Fix Mtarnuhal#18 autoSL + autoRigidel

Seems Auto harvest, and auto rigidel+harvest attempt to harvest a sugar lump just a teensy bit before it's actually ripe, therefore botching the harvest in half the cases. Game.timetoRipe returns a float number in some cases, so adding Math.ceil to the Game.timeToRipe in the equations should give it just enough leeway to make sure it computes the correct millisecond. (It's my theory anyway. The math seemed to have come out ok when I paper tested).
With thnx to @Darkroman

* autoGodzamok Sane & Insane option restored

Attempt to restore the autoGodzamok Sane and Insane options.
Has to be tested to make sure everything behaves as it should.

* Update frozen_cookies.js

* Attempt fix autoGodzamok Sane and Insane

Second try
And some minor changes to make it more efficient.

* safeBuy

safeBuy instead of visually change the buy-sell option.
Changing the variable should be enough.

* Attempt fix autoGodzamok Sane and Insane

Third try
Preventing the sell of cursors and farms while Devastation is active.

* Finalizing autoGodzamok

finalizing autoGodzamok

* Update Version 1.8.1

* Simplifying autoGodzamok

simplified autoGodzamok.
- If AutoGodz is on and a click buff is active, but Devastation is NOT active:
   - sell the cursors and farms
   - if autoBuy is turned on, the user has already signaled their intent to have things purchased for them, so rebuy what you sold (up to the limit if any limit is set). 
   - Otherwise, don't rebuy anything.

* Remove unnecessary autoGodzamok preference 

Removed Sane and Insane mode from autoGodzamok cause they were removed.

* autoGodzamok Reversed variables 

Reversed the variables of buy back

* autoGodzamok wrong parameter

Used the wrong parameter

* autoGodzamok extra check

Extra check if the limit doesn't exceed the current buildings.

* autoGodzamok 

Forgot to add -1 to the buyback of farms

* show current buff value on Devastation tooltip (Mtarnuhal#46)

Co-authored-by: Mtarnuhal <[email protected]>
@Mtarnuhal Mtarnuhal mentioned this pull request Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sugar Lump Harvesting
2 participants