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

Improve farming #119

Merged
merged 7 commits into from
Aug 6, 2023
Merged

Improve farming #119

merged 7 commits into from
Aug 6, 2023

Conversation

JoshdanG
Copy link
Collaborator

Improve Farming Desire Calculation

  1. Check for damage from enemy players instead of any player damage
  • Fixes issue with (incorrectly) detecting self damage interrupting farming
  1. Removed unhelpful conditions
  • Check for channeling removed
  • Check if current action is "idle" removed

Improve Farming Behavior

  1. Fix stacking location
  • Fixes runtime error
  1. Fix stacking without creeps
  2. Mostly fixes leaving tree-heavy camps uncleared (while still farming)
  3. Fixes leaving baby mud golems behind
  4. Farming now uses 4 states: travelling, near, farming, stacking

Misc Cleanup

  1. Remove commented out and debugging / obsolete code
  2. Add comments
  3. Use more constants
  4. Consolidate conditions required for farming
  5. Move rattletrap specific farming code to separate function
  6. Refactor / tweak camp refresh
  • Move refresh to before ancient check so it always runs when it should
  • Simplify 0:30 time check
  • Change starting value of numCamp and add clarifying comment
  1. New general use functions
  • Unit.WasRecentlyDamagedByEnemy in MiraDota.lua
  • utility.GetUnitsTowardsLocationGeneric in utility.lua

1. Remove commented out code
2. Remove debugging code for faceless void
3. Remove obsolete shrine / is T3 destroyed code
Will add again in another commit; this makes the diff more readable
1. Move refresh to before ancient check so it always runs when it should
2. Simplify 0:30 time check
3. Change starting value of numCamp and add clarifying comment
4. Remove unused variables, including "minute"
1. Consolidate conditions required for farming
2. New function Unit.WasRecentlyDamagedByEnemy in MiraDota.lua
- Checks if unit was damaged by enemy team
- Fixes issue with (incorrectly) detecting self damage interrupting farming
3. Removed unhelpful conditions
- check for channeling
- check if current action is "idle"
4. Remove setting preferredCamp = nil in GetDesire, this is handled in OnEnd
5. Add comments
6. Use constant BOT_MODE_DESIRE_NONE instead of "0.0"
1. Replace obsolete manual stack points with simple calculation
- Fixes running off and tp'ing instead of stacking
- Fixes runtime error for camp index > 18
2. Uses new function utility.GetUnitsTowardsLocationGeneric that works on raw locations
- Update GetUnitsTowardsLocation to work based on GetUnitsTowardsLocationGeneric
Fixes:
1. Mostly fixes leaving tree-heavy camps uncleared (while still farming)
2. Fixes leaving baby mud golems behind
3. Fixes stacking issues

Code Changes:
1. Instead of farmState = 0 or 1, now there are four statuses:
- FARM_STATE_TRAVELLING: beyond 800 range, standard move
- FARM_STATE_NEAR: Between 800 and 400 range, attack move in case creeps are outside camp
- FARM_STATE_FARMING: Attack creeps using FindFarmedTarget
- FARM_STATE_STACKING: Run to stack location so camp will stack
2. Moved camp clear/update check earlier so that it's easier to understand
3. Have to be within 200 range of camp to clear because trees often block visibility of creeps even when the camp location is visible
- Fixes leaving tree-heavy camps uncleared
4. Checking camp clear now requires #neutralCreeps == 0
- Fixes baby mud golem issue
5. To support #neutralCreeps == 0 check and other edge cases, if camp not clear, but no available target, keep moving toward camp
6. Going into stacking state requires a recent attack
- Fixes "stacking" without creeps
@JoshdanG
Copy link
Collaborator Author

Reviewing

  • Be sure to split up commits when reviewing. The first 4 commits are refactoring and especially the rattletrap code move does not diff well.
  • Hiding whitespace is also helpful for reviewing the GetDesire() changes.

Feature Status

  • Farming is currently only enabled for Alchemist and Bloodseeker -- the heroes that farming was previously enabled for.
  • Based on the previously configured desire levels, bots spend most of the time farming. This is probably not optimal, but is an interesting difference from typical bot behavior.
  • Really doesn't work for ranged heroes
  • There are plenty of improvements possible - like camp selection and balancing farming with other activities (especially pushing lanes)
  • The camp clear detection is pretty dumb; it basically runs into each camp to be sure it is clear.

@adamqqqplay
Copy link
Owner

Thank you very much for your continued contribution.
I am a little busy at work recently, and code review will be slower. I'll find time to finish it though, thanks.

@ArcherWayne
Copy link
Collaborator

Thanks for your contribution. Farming has been a problem for this bot.

I reviewed the code and I think the code are functional and logical. Can you try to test the GPM improvements for these bots?

If the bots can farm as fast as human players do, then they would be more challenging to play against.

@JoshdanG
Copy link
Collaborator Author

Thank you very much for your continued contribution. I am a little busy at work recently, and code review will be slower. I'll find time to finish it though, thanks.

No worries. Definitely no urgency from my end.

@JoshdanG
Copy link
Collaborator Author

I reviewed the code and I think the code are functional and logical. Can you try to test the GPM improvements for these bots?

If the bots can farm as fast as human players do, then they would be more challenging to play against.

It's definitely not (good) human level, but it's pretty consistently higher than non-farming heroes. Some sample game scoreboards below (Alchemist: 690gpm, Bloodseeker: 632gpm, Bloodseeker: 775 gpm). These games happen to all be wins, but the farming hero generally does not carry the game.

Alchemist
Alchemist_farm

Bloodseeker (bad game)
Bloodseeker_farm

Bloodseeker (good game)
Bloodseeker_farm2

if not (bot:IsAlive()
and campUtils.IsStrongJungler(bot)
and bot:GetLevel() >=6 and bot:GetLevel() < 30)
or IsHumanPlayerInTeam()
Copy link
Owner

Choose a reason for hiding this comment

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

Is this condition necessary? I don't quite understand the difference when human players are present.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That logic was already there and I assume working as intended. I'm guessing the intent is that the human player may want to farm, and the bot farming as well could interfere with that. That check can be removed if unwanted; nothing else depends on it.

Copy link
Owner

Choose a reason for hiding this comment

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

@JoshdanG Now we only have 2 heroes with farming mode enabled? If so, it is indeed possible to remove this condition, it affects human players less.

--
-- Currently works by just going a fixed distance away from camp location
-- in the bot's current dirction.
function X.GetCampMoveToStack(bot, camp)
Copy link
Owner

Choose a reason for hiding this comment

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

This function is really helpful, thanks!

@adamqqqplay adamqqqplay merged commit 67767a7 into adamqqqplay:master Aug 6, 2023
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.

3 participants