Refactoring AI
Moderator: Moderators
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Refactoring AI
Suggestion: reorganize main AI the same way as homunculus AI was reorganized. There's already some steps in such a direction in svn, just to show how it can be done. That's also for a possible reduce of copy-pasted code all over the slave AI.
Last edited by EternalHarvest on 07 Jul 2010, 00:41, edited 1 time in total.
-
- Administrator
- Posts: 1301
- Joined: 24 Apr 2008, 12:02
Re: Refactoring AI
Nice Idea.EternalHarvest wrote:Suggestion: reorganize main AI the same way as homunculus AI was reorganized. There's already some steps in such a direction in svn, just to show how it can be done. That's also for a possible reduce of copy-pasted code all over the slave AI.
AI::Slave → AI::Actor::Slave extending Actor::Slave and AI::Actor
AI stuff from Globals, AI.pm, AI::CoreLogic, AI::Attack → AI::Actor::You extending Actor::You and AI::Actor
I think, It should be Implemented till OpenKore 2.2 Release.
But, PLEASE Do not touch the OpenKore 2.1 AI Yet.
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: Refactoring AI
Inspected code, but haven't tested results at all (and there are some pseudo-code things that won't compile).
Added Actor support to tasks.
Merged ai_route, slave_route into Actor->route;
processRoute, Slave::processRouteAI into Task::Route;
processMove into Task::Move.
http://openkore.pastebin.com/3bx6Nc6E
Added Actor support to tasks.
Merged ai_route, slave_route into Actor->route;
processRoute, Slave::processRouteAI into Task::Route;
processMove into Task::Move.
http://openkore.pastebin.com/3bx6Nc6E
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: Refactoring AI
Examples of entities wanted:
1. Base Actor classes (abstract)
BaseActor (examples of class members: nameString) - top-level abstract class with minimal stuff for actors
BaseActor::You - abstract class for main user-controlled (or AI controlled) object
2. Real Actor classes with custom roles, properties and network bindings
RagnarokActor (implementing roles for "object in 2D world", "object with statuses" etc - these are needed too)
RagnarokActor::You (inventory, cart, network bindings)
RagnarokActor::Homunculus (custom properties, network bindings)
3. AI classes
ActorAI (queue, task manager, iterate, queue_attack/queue_route) - top-level abstract class with stuff for AI
ActorAI::You (queue_sit/queue_stand) - main user-controlled object AI, linked with Actor::You kind of object
ActorAI::Homunculus (queue_feed) - custom AI for custom object
1. Base Actor classes (abstract)
BaseActor (examples of class members: nameString) - top-level abstract class with minimal stuff for actors
BaseActor::You - abstract class for main user-controlled (or AI controlled) object
2. Real Actor classes with custom roles, properties and network bindings
RagnarokActor (implementing roles for "object in 2D world", "object with statuses" etc - these are needed too)
RagnarokActor::You (inventory, cart, network bindings)
RagnarokActor::Homunculus (custom properties, network bindings)
3. AI classes
ActorAI (queue, task manager, iterate, queue_attack/queue_route) - top-level abstract class with stuff for AI
ActorAI::You (queue_sit/queue_stand) - main user-controlled object AI, linked with Actor::You kind of object
ActorAI::Homunculus (queue_feed) - custom AI for custom object
-
- Administrator
- Posts: 1301
- Joined: 24 Apr 2008, 12:02
Re: Refactoring AI
Why Do we need ActorAI Classes???EternalHarvest wrote:Examples of entities wanted:
3. AI classes
ActorAI (queue, task manager, iterate, queue_attack/queue_route) - top-level abstract class with stuff for AI
ActorAI::You (queue_sit/queue_stand) - main user-controlled object AI, linked with Actor::You kind of object
ActorAI::Homunculus (queue_feed) - custom AI for custom object
As we want to get loose of AI Queue, we will not need em anymore.
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: Refactoring AI
Functions to launch tasks, task manager.kLabMouse wrote:Why Do we need ActorAI Classes???
As we want to get loose of AI Queue, we will not need em anymore.
And until AI queue is gone, it's still here.
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: Refactoring AI
Common things in tasks:
Waiting for Network::IN_GAME
- can this be done with mutexes?
Arguments handling and validating
- can be handled in base class
- can be handled in base class with unified method of storing timeouts in tasks
Waiting for Network::IN_GAME
- can this be done with mutexes?
Arguments handling and validating
- can be handled in base class
Code: Select all
sub interrupt { $self->{interruptionTime} = time }
sub resume { $self->{giveup}{time} += time - $self->{interruptionTime} }
-
- Administrator
- Posts: 1301
- Joined: 24 Apr 2008, 12:02
Re: Refactoring AI
Better use EventsEternalHarvest wrote: Waiting for Network::IN_GAME
- can this be done with mutexes?
Agree.EternalHarvest wrote: Arguments handling and validating
- can be handled in base class
- can be handled in base class with unified method of storing timeouts in tasksCode: Select all
sub interrupt { $self->{interruptionTime} = time } sub resume { $self->{giveup}{time} += time - $self->{interruptionTime} }
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: Refactoring AI
Give an example?kLabMouse wrote:Better use Events
-
- Administrator
- Posts: 1301
- Joined: 24 Apr 2008, 12:02
Re: Refactoring AI
Network push Event "IN_GAME" to AI, and unlock it's functioning.EternalHarvest wrote:Give an example?kLabMouse wrote:Better use Events
the Event System is Native, and you do not need constantly check for that Var.