RELEASED: Player AI

A place to post your add ons and ideas for them

Moderator: Moderator

Message
Author
Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

RELEASED: Player AI

#1 Post by Charidan »

TE-4 ADDON LINK: http://te4.org/games/addons/tome/player-ai
STEAM WORKSHOP LINK: http://steamcommunity.com/sharedfiles/f ... =523638132
GITHUB LINK: https://github.com/Charidan/Tales-of-Maj-Eyal-Player-AI

Version 1.7.0 has gone live. Credit to Doctus and jnday for contributing to and indirectly causing this release.

The Player AI is intended as a lazy way to clear easy dungeon floors, not a competent combatant who will win the game for you. I might make that AI later, or just keep improving this one until it's actually good at the game.

Have fun, and tell me what you think. I accept comments, criticisms, pull requests, and bug reports.

Current Status: This addon is not currently under development.

-------------

Adds a keybind to activate the new player AI. Set to Alt+F1 by default.
This player AI rests, auto-explores, and attacks enemies (using most talents when possible).
It will clear an entire floor or stop when it hits a configurable health threshold (default 25%) in the presence of enemies.
Configurable rank stop to cancel the AI in the presence of a sufficiently high rank enemy (such as a boss).

Check the Game Options menu: there is a Player AI tab for settings specific to this AI.

This AI has not been tested in the Sandworm Lair; use it there at your own risk.
The AI doesn't know not to use menu-opening abilities (e.g. command staff) so it's probably unhelpful to use with classes that have those abilities enabled. I've also gotten reports of gamebreaking problems with Chronomancer, which should surprise nobody.

Compatibility note: This addon superwrites Player:act(), so if your addon also touches Player:act() change the load order so that the Player AI addon loads last.

CURRENT FEATURES:
  • Rests!
  • Autoexplores!
  • Attacks enemies!
  • Uses talents randomly!
    • No exceptions yet for talents like Meditation or Phase Door to use them intelligently.
  • Options tab in the Game Options menu!
CURRENT BUGS:
  • It can get stuck in infinite explore loops, so I added a setting for max turns it can run in a row (default 1000) so it will eventually cede control back to you.
  • The AI still has trouble understanding water. It doesn't know about waterbreathing, and it doesn't recognize "bubbles" as air. So it's going to complain about suffocation constantly while it's underwater, but paradoxically seems to always move in the intelligent direction while doing so.
  • The AI sometimes falls through to its "wait a turn" case when it doesn't seem necessary. This will be awful to debug.
v.1.7.0 PATCH NOTES:
  • Added Rank Stop! Credit to jnday.
    • The AI can be configured to exit if it detects an enemy of certain rank or higher, e.g. bosses.
  • Fixed a typo preventing Hunt mode from working at all. Credit to Doctus.
v.1.6.2 PATCH NOTES:
  • Added configuration to disable the Hunt state, since it often is less smart than not having it. Default disabled.
v1.6.1 PATCH NOTES:
  • Added configuration for the AI runtime timeout. You can now adjust to match your patience with the AI getting stuck in loops.
v1.6.0 PATCH NOTES:
  • Added framework support for configurations!
    • There is a new tab in the Game Options menu for "Player AI" settings.
    • Configurable percentage health thresholds for disabling the AI or fleeing in "hunt" state.
    • Configurable timeout on "hunt" state.
    • Just three settings for now, will definitely be more later.
  • Added a primitive "hunting" mode.
    • If out-of-combat and attacked by an enemy it cannot see (including when it is blinded; the AI is dumb), it will check if the enemy position is known and rush them.
    • If the attacker's position is unknown, the AI will randomwalk instead of standing still.
    • Configurable health threshold to instead avoid the engagement and lose its pursuers so it can rest safely.
Stuff that probably should be implemented but hasn't been:
  • Smarter "hunting" state.
  • Assay practicality of per-talent settings to control usage.
  • Improve understanding of talent types (such as which talents heal/defend you and should be used while resting/hunting).
Last edited by Charidan on Tue Mar 01, 2022 10:22 am, edited 23 times in total.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Pierre'70
Low Yeek
Posts: 6
Joined: Mon Mar 23, 2015 10:26 am

Re: RELEASED: Player AI

#2 Post by Pierre'70 »

My character seems to be tinkering with her sustains, it'd probably be best if only active skills were used.

An error log:
error = "Lua Error: /mod/class/Actor.lua:1556: stack overflow\
At [C]:-1 \
At /mod/class/Actor.lua:1556 reactionToward\
At /mod/class/Actor.lua:1571 reactionToward\
At /mod/addons/player-ai/superload/mod/class/Player.lua:88 \
At [C]:-1 calc_circle\
At /mod/addons/player-ai/superload/mod/class/Player.lua:86 spotHostiles\
At /mod/addons/player-ai/superload/mod/class/Player.lua:219 player_ai_act\
At /mod/addons/player-ai/superload/mod/class/Player.lua:274 player_ai_act\ (repeated thousands of times)
At /mod/addons/player-ai/superload/mod/class/Player.lua:339 act\
At /engine/GameEnergyBased.lua:126 tickLevel\
At /engine/GameEnergyBased.lua:62 tick\
At /engine/GameTurnBased.lua:46 tick\
At /mod/class/Game.lua:1259 "
Hope this helps!

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#3 Post by Charidan »

EDIT: It looks like the steam version of the addon is out of date. I will bargain with the steam gods to try and get that fixed.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#4 Post by Charidan »

I properly uploaded version 1.2 to steam, so it should be fixed now.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#5 Post by Charidan »

I'm going to start cataloging old patch notes in posts so people can find them.

v1.2 PATCH NOTES:
  • Complete backend rewrite of the action and decision code
  • Addition of AI states so it stops trying to rest and autoexplore in combat
  • Implemented Talents
v1.3 PATCH NOTES:
  • The AI now responds to suffocation
  • If air is less than 75, it seeks tiles with air
  • If it can't see air and air is less than 75, it exits with a suffocation warning
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#6 Post by Charidan »

v1.4 PATCH NOTES:
  • AI will no longer attempt to cast 0% of a turn talents or talents that fail twice in a turn
  • This fixes some infinite loops with talents like Cauterize Spirit with 0 cast time and 0 cooldown.
  • Talents don't universally "fail" properly in the code, so Rush can still cause infinite loops in bad terrain
  • Credit to steam user Elana for suggesting the change
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#7 Post by Charidan »

v1.5 PATCH NOTES:
  • Updated the cast tracking system to check the cooldowns and energy (time) cost of talents
    • If a talent with a cooldown fails to go on cooldown, it is assumed the talent cannot be used
    • If a talent with an energy cost fails to expend energy, it is assumed the talent cannot be used
    • If a talent has no cooldown and no energy cost, it is limited to a maximum number of uses per turn, currently 5
  • Fixed a bug with "waiting" where the AI called the wrong function to wait and ended up hanging.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Elkan
Archmage
Posts: 336
Joined: Wed Aug 08, 2007 12:23 pm

Re: RELEASED: Player AI

#8 Post by Elkan »

I'm using a lot of addons, so difficult to see if one is affecting it, but the latest version sees to have entirely disabled talent use for me

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#9 Post by Charidan »

My first advice is gonna be to try again, because I just posted a patch to the previous version that cleans it up. If that doesn't work, then it's probably an addon conflict since it works fine for me. There's a few tests only you can run if you want to diagnose further.
  1. Clarify if AI-used talents aren't working or all talents, even user-initiated casts
  2. Distinguish whether talents don't work ever or work for a bit and then stop working
  3. GOLD STAR BONUS: Try disabling addons in the main menu to see if that makes it work, so we know that the problem is:
    1. an addon conflict, and
    2. which addon(s) it's conflicting with
-----------------

And for everyone else, the patch notes.

v1.5.1 PATCH NOTES:
  • Replaced the cast tracking system with a fail catching system
    • Grayswandir pointed out that there is a function which tells me if a talent failed, so I now mark talents as failed if they fail, as opposed to the complicated stuff I'd been doing.
    • This mostly just makes my code look cleaner without effecting gameplay, although it removes some weird edge cases.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

Elkan
Archmage
Posts: 336
Joined: Wed Aug 08, 2007 12:23 pm

Re: RELEASED: Player AI

#10 Post by Elkan »

Seems to be working now, with the updated version.

For reference, in the last version I found that talents on auto-use were activating at appropriate times, but were not targeting opponents, and would otherwise ignore talent use and bump attack everything to do death.

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#11 Post by Charidan »

I think I understand why. While I was rewriting everything for the patch I found a bug in the old version where an if statement had one of its conditions reversed. Still, if the patch fixed it, then it's fixed.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: RELEASED: Player AI

#12 Post by jenx »

some suggestions:

(a) 1/4 health is way too low for most characters - either let user set it, so it can be adjusted according to level and character, or set it to 1/3 or 1/2
(b) please get it to stop when you level up. atm, it just keeps running
(c) get it to stop when you encounter boss, or at least, make this an option for the user
(d) when a zone is completely cleared, and you run this, you can't stop it, it goes forever. so please make it so ESC stops the ai running.

enjoying seeing how this works, but it needs some basic refining still :-)
MADNESS rocks

Charidan
Higher
Posts: 64
Joined: Wed Jul 22, 2015 8:12 pm

Re: RELEASED: Player AI

#13 Post by Charidan »

Configurations are scheduled for the patch after next, because that will be a completely new feature.

The current setup for the AI doesn't allow for button presses while it's running, not consistently. The short explanation is that ToME doesn't accept input while it is executing a turn, and the AI is always taking a turn. If it gets in a loop between exits try and hit an arrow key a lot of wait for it to time out. Once timeout is configurable it'll be less bad.

Hadn't considered stopping on level up or on boss sighting. I think it's possible.

The bad news is I'm in the process of getting a job, so my work on the addon is going to be delayed a bit.
Currently developing the Player AI addon. You can get it from the T-Engine Addon Hub or Steam
You can also view the source code.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: RELEASED: Player AI

#14 Post by jenx »

Charidan wrote:Configurations are scheduled for the patch after next, because that will be a completely new feature.

The current setup for the AI doesn't allow for button presses while it's running, not consistently. The short explanation is that ToME doesn't accept input while it is executing a turn, and the AI is always taking a turn. If it gets in a loop between exits try and hit an arrow key a lot of wait for it to time out. Once timeout is configurable it'll be less bad.

Hadn't considered stopping on level up or on boss sighting. I think it's possible.

The bad news is I'm in the process of getting a job, so my work on the addon is going to be delayed a bit.
i hope you can still fnid some time for this.

I am trying with solipsist and with thought forms, rather than put one on and leave it on, it changes them as soon as possible. This is not good at all. I imagine it might do the same thing with mind slayer shields and auras. So it needs to understand sustained talents better.
MADNESS rocks

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: RELEASED: Player AI

#15 Post by jenx »

It is also not using runes that do damage.
MADNESS rocks

Post Reply