Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 23:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Mini Project: Companions/Bots

Discussion on Mini Project: Companions/Bots within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Mini Project: Companions/Bots

<REVAMP: October 26>

So I'm gaining an interest in artificial intelligence again. With hellmouth slowly being rebuilt, this is something I'd like to PROPERLY add (not the simple test versions I've coded before) this for the open beta stage of the server (month or so away minimum)

My thoughts.... If you can limit the FUNCTION of AI and limit the SCOPE of AI then it shouldn't be very difficult to create a near player like experience.

As far as function and scope goes we really only need to look at 1 thing...

Function: Provide a pvp experience which rivals that of a human opponent
Scope: Pvp ONLY

By focusing on what exactly it is we want to create it will allow us to avoid issues entirely which would otherwise ruin the goal of the project (bots which recreate reasonably 'inteligence' pvp gameplay). We will NOT be worrying about chat logic or anything outside the realm of "kill enemies, protect and help allies"

My current idea for coding this is to use a separate logic server. The logic server will be updated with entity variables (internal and external) and the logic will translate this (through the filter of desires, short term and long term memory) into a decision. The logic server then will send the resulting 'choice' to the game server and enter what could be considered a 'listening mode' in which it will use information being returned to modify short term memory (which hopefully in some cases can be translated into more abstract rules for long term memory... that's a bit more advanced though).

Eg: Jump to X1/Y1 and FB X2/Y2. Server then returns that you have killed player Y, this would serve to reinforce the factors used to make this decision... but if it resulted in the bot being killed or taking large amounts of damage, there should be a negative feedback to the decision making processes.

Anyways, once I get some time I'll start working on turning it into a working model vs simple theory I'm hoping to be able to break down the function of every single thing required before I actually code the server though.. with this size of a project, if you lose focus of what a system is responsible for, you can get screwed over with surprising speed.


<Update: June 15>

Not done anything more on this. Got LOADS to do before a AI/Bot system becomes remotely applicable (working on a proxy for latest version of co so I can log packets and then work on a fully custom 5250+ source... so yah... gonna be a while lol)

I did get bored thismorning though and started again on the Logic Server. Wrote the communication for GameServer<->LogicServer as well as some of the structure for how to actually handle the data transfer. Should make the final version go much quicker when it's needed.




Ooh: I'm also thinking that once I'm done logging packets with the proxy, I may hook it up to the logic server and have it be a proxy for botting on real co. That would allow for some serious AI for the autohunt/loot and make it much more fluid.


<Updated: May 27>

Released the crappy test source I had this version of the bot in. Feel free to muck around with it and test the duelist bot.



Note: Very poorly coded version. it was just me testing out how to best go about features and I'm re-coding and organizing everything much nicer in the new version. This was just a testbed.

<Updated: May 24>




Video of the test version of the duelist




Finished getting basic version working. I'm re-writing everything from scratch though. Making it far more streamlined and self contained so that I can transfer it between sources (and eventually release) easier.

Temporarily using Hellmouth as my test source simply because there are less bugs I don't know about as compared to ElitecoEmu (such as the gear calculations). This will just make things alot easier for the time being.

Main Challenge Atm:
I need to find a logical/scalable way to build my AI system. My current plan is to build a connectionalist network to handle the bots motivations and choices. That will allow for a real AI system to be put in place in the future and allow for simple adaptation for now. Basically I wanna do 3 layers to the network.

External Stimulus:
All world environments that the bot should know about including but not limited to...
- Number of monsters in the area (screen)
- Health of monsters in that area
- Closest monster to bot/distance to it
- Distance to 'master'


Internal Conditions:
All internal variables that the bot has including but not limited to
- Jump Variables (last jump time, last jump try, last jump distance/time before next, can bot jump, etc)
- Walk Variables (last walk time, last walk direction, time between steps, walk target (x/y), can bot walk
- Attack Variables (current target, attack type, last skill used, last skill time, last attack time, etc)
- Statistics Variables (health, mana, stamina, defense and all that good stuff)

Actions Layer:
Will take all input and determine what action should take place

- Jump (type of jump, where to)
- Walk (where to)
- Attack (what type/skill/atk what)
- Wait (Do nothing)


The way neural networks work means that you feed in data and they 'trickle down' through nodes in the network eventually resulting in a decision. The resulting decision is compared with what "should" happen (learning) and the weights given to different nodes/connections is altered changing future outcomes.

The way I see it is that if I do something along those lines, you can set default values for nodes/connections to fit approximately with how you want the bot to behave. Then add in a training mode which causes the bot to ask if its decision was correct after each action. The weights are then fixed in place when training is completed and little/no changes in behavior occurs after that.

Add in a bit of random chance and you will have a very 'intelligent' bot that can provide alot of uses ingame.

I still am working on structure for the network before I actually do any coding but if anyone wants to look at it and criticize my ideas... I really do welcome it.

here's a link about neural networks in C#. Mine would be a similar concept but not quite the same (wouldn't have a solution to compare it to, rather would choose 1-2 actions from the result and act on them.)



PROGRESS ON ACTUAL BOT:

- Skills now work: So far all I've tested is fastblade. (linear attack function works though so that covers all of those skills. Also means I can convert all the existing skill functions EASILY)
- Damage now works (Player>Bot and Bot>Player both deal proper damage(ish))
- Behavior types added. This allows for different types of bots not to be running the same damn checks and wasting cpu power. I split it off into duelist and companion bots for now but I have a few more types planned including PVE, Boss and Team Pvp types. Just makes adding stuff in the future easier
- Added more functionality to the walk/jump functions making them more fluid
- Added Duelist jump type (doesn't follow the player like the other one)
- Transferred over large amounts to hellmouth source and re-wrote it as I went making it FAR more streamlined.


So as we are right now... we have duelist bots working rather nicely (they jump around, attack you, take damage, die, revive themselves and keep going)

Companion bots are very basic. They have walk and jump functionality to follow the player and that works very well. I need to modify it some so when the player goes through close spaces the bot doesn't freak out and stop following.. that's due to the random coords it generates being turned down by the dmap handler (although I have fixed most of that). They also have a nice command structure to enable/disable jumping and walking, attack a specified player with fb (only does it once as it is right now. Easy to change though), remove bot from world, re-do the bots equipped gears and some other basic stuff...

</Update>

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

So I've made some progress. It's actually far easier than I thought so you can disregard most of my speculation in this post although I still welcome better ways of doing things. Right now I'm not aiming for efficiency as much as I am getting something out there that's WORKING. I'll end up re-writing a streamlined version if I ever intend it for deployment or release.

Progress:

- Linked the companion to the clientsocket (not required, I can easily create a separate one. It was just easier for testing AND allows for a true companion system later down the road)
- Re-wrote some packets and game systems to accommodate BASIC functionality such as displaying the loaded bots to clients in range and some movement (Jump and view gears work)
- Added structure to store all loaded bots on the server
- Added new thread system to run through all loaded bots to perform any future actions and AI.
- Added/adding new calculations dealing with bots (jump distance, walking, etc) to allow for future implementation
- Tested threading system. It all works! Bots now follow their owner around like lil puppies lol.
- Linked Bots with their "owner" (NOT required! Still able to have bots without owners... it just makes features easier in the future)
- Posted SOME BASIC info on how to add them to your own server. It's not a release, you still need to know what you are doing to add them successfully! If you want it, it's a few posts down.

For the record I'm using CoEmu as I'm damn familiar with it. I'll probably convert it to impulses if I ever get it to a completely working state.


The idea is this... I was originally wanting to try to create a bot/clone character for use in pvp or to test server loads (it's alot easier to load up a hundred fake clients all doing some simple pre-programmed things than it is to try to get a bunch of people on at the same time when I don't have internet lol) After starting a little on that I realized you could do ALOT more with them than just that... You could actually completely change the game if you chose to and make them alot more intelligent and useful than guards.

Use 1: Sidekicks. You could give it out a ton of different ways to players... something for 3rd/4th reborn... donation... super hard quest... or however you wanted. Basically it would create a permanent entity that would have some basic artificial intelligence coded into it that would follow you around and could perform a wide range of tasks such as

Companion system Features:

- Looting
- Killing monsters (using skills/xp skills as well in a somewhat intelligent manner
- Summon/dismiss the companion with a custom skill
- Intelligent movement from the companion including walking and jumping (Not ontop of you instantly like many guards do now but rather random delay between actions and using some AI to determine where it should go as well as random chance)
- Customizable gear (I'm thinking I'll use a separate warehouse to control the inventory for the companion and use the AI to determine what the companion chooses to wear from its inventory. I've already done a separate warehouse before when I did hellmouth)

Other uses for the same system

- Pvp drones (think Acids fb bots)
- Testing server loads
- Filling out server (Think about it.. somewhat intelligent players running around playing the game... would make some maps feel alot less empty)
- Intelligent teamates for quests: Have quests that require a full team and fill in any missing slots with bots.
- Custom events/quests where bosses are bots and actually display some real intelligence and fight back properly using skills/movement

Again.. high hopes that I'm sure I probably won't actually finish but I do wanna see how far I can go with the idea as it's not something anyone has ever really released or gone far with before.


Ooh and before I get asked: Yes, if I get the system to a semi working state I will most likely release it. Most likely not with all of the features but if it works I'll post some version of it for ppl to mess around with. Hell if someone wanted to give me a hand I definitely wouldn't mind either lol.


So far I got very little functionality done. Re-wrote the view equipment so that it would also apply to bots.. Pot calculates off cause I was using eliteCoEmu to test it out and I don't think it calculates it properly.

pro4never is offline  
Thanks
12 Users
Old 05/24/2010, 00:35   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 630
Received Thanks: 130
Goodluck on this project
hope it gets success
.Summer is offline  
Old 05/24/2010, 00:43   #3
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
That will be amazing. I would LOVE to see something like this.
Santa is offline  
Old 05/24/2010, 01:24   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Ok wow... so this is FAR easier than I originally thought (at least the base part is. I'm sure once I get into actual AI or anything useful it will get tricky)

So I'll post a few snippets for people looking to work on this on their own (again.. if you have any idea what you are doing and are interested, lemme know... I'm sure I'll be needing some help along the way)

Basically for simplicity sake and to save time. Copy the entire Entities>Character.cs to a new .cs for your new type of entity. Personally mine is Bot.cs. Then go to your ClientSocket.cs file (in elite coemu it's Networking>Client.cs) and under public Character Client; put public Bot Companion;. This will allow you to configure your characters companion however you want just as you would your normal character.
Generally through CSocket.Companion.Whatever.

Now you will need to assign it on login (if not you will get all sorts of problems because it hasn't actually been assigned.)

Personally I chose to do it right on logging when the main character is retrieved but you could do it later if you wanted (maybe when the actual summon is used would be wiser in the long run? No sense assigning all those variables if you have no intention of using them)

Anways, I just did

Bot Companion = new Bot();
CSocket.Companion = Companion;

in login.cs under Database.GetCharacter(User.Account);


as for actually summoning and seeing the character... just copy and re-write your existing spawn packets to focus on the companion instead... exact same thing with all the packets (took me a shockingly long time to realize that)


I then made a dictionary to hold all bots added to the server
public static Dictionary<int, Entities.Bot> Bots = new Dictionary<int, Entities.Bot>();

The actual summon I have is this...

Code:
case "bottest":
                            {
                                foreach (KeyValuePair<int, Struct.ItemInfo> Item in CSocket.Client.Equipment)
                                {
                                    CSocket.Companion.Equipment.Add(Item.Value.UID, Item.Value);
                                }
                                 CSocket.Companion.Name = CSocket.Client.Name + "[Bot]";
                                 CSocket.Companion.Model = CSocket.Client.Model;
                                int ID = World.Rand.Next(100020, 199920);
                                 CSocket.Companion.ID = ID * 10;
                                World.Bots.Add(CSocket.Companion.ID,  CSocket.Companion);
                                Entities.Spawn.All(CSocket);
                                break;
                            }
Note: you will need to go offscreen and back on to see in this version (I should have kept the original Spawn entity packet I had in there but I changed it when I was messing around with stuff)

To see it using the spawn all section.. I just copied the existing section focusing on Characters and switched everything in there to World.Bots and it works just fine.


As for packets, it's shockingly simple. Just copy the existing ones and change everything concerning Csocket.Client to CSocket.Companion and you can simply use your own client to send the packet if you wish.

I wrote jump so far and it works just fine...

Handler.CompanionJump(CSocket.Client.X, CSocket.Client.Y, CSocket);



It's messy but it works. I didn't feel like re-writing everything.


Anyways: That's all I'm releasing for now. That's really all you should need to get started although it's a LONG way from being an actually useful feature.

I'll prob make a real release eventually but this is FAR from ready for release yet... Still totally cool having things start to work and be so much easier than I first thought.

pro4never is offline  
Old 05/24/2010, 01:41   #5
 
GRASSHOPPA's Avatar
 
elite*gold: 0
Join Date: Jun 2008
Posts: 113
Received Thanks: 19
ty so much for releasing this..
ive been thinkin about something like this for a little while now..
could be perfect for testing stability and such
GRASSHOPPA is offline  
Old 05/24/2010, 01:46   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
keep in mind it's FAR from perfect and in it's current version does not spawn any new connections or anything that would help test some of the main problems in coemu (mainly the threading system... I'm not spawning a thread per bot)


Speaking of threading...

Just finished adding the base structure for threading. Gonna test it out now by having it control some very basic movement of the bot (namely jumping around in a small radius of random coords)

After that I can focus on the real work.

Thanks to how nicely organized the Elite source is, it's making this really easy as I can just copy/paste almost everything and change some small stuff... I mean just using the Client thread checker allows me to already have everything coded dealing with stamina, stats and other time related checks (meaning things like fb based on actual stamina amounts, xp skills based on actual xp bar and other fun stuff will work nicely)


<edit>

a reminder for anyone trying to add what I released...

keep in mind that seeing as there is no actual client connected, you do not need to send any of the packets back to the client to update status. Infact seeing as my basic version is linked to your actual client you do NOT want to do that or you will get all sorts of funky stuff happening (where someone damages your companion and it takes your own health while not changing your actual hp stats server side)
pro4never is offline  
Old 05/24/2010, 01:50   #7
 
elite*gold: 0
Join Date: May 2010
Posts: 630
Received Thanks: 130
I LOVE IT
it looks good
Keep the godo work up
.Summer is offline  
Old 05/24/2010, 01:52   #8
 
xScott's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 322
Received Thanks: 63
Interesting, keep this updated.
xScott is offline  
Old 05/24/2010, 04:15   #9
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
My AI Players i have created for my server at a service patrons right now. Players can buy there services , any class they want. They can buy water tao's to revive in guild wars. They can buy Trojans and warriors for doing quests. They can buy AI players to kill another player that killed them. And the list goes on. The system of AI players is not yet fully complete but that is something i have been working on for weeks now.
ImFlamedCOD is offline  
Old 05/24/2010, 06:55   #10
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Quote:
Originally Posted by -virTuaL View Post
does the bot continually follow you when you use /follow? or eh?
that was a test version. I've got alot done since then. I now have both walk and jump working with some basic artificial inteligence (it can follow you without ******* up too much) and i re wrote some cmd structure so controlling the bot will be easy (like /bot attack playername or w/e)

I finished cloning all the attack functions and once i finish up a bit more all attack should work (all skills, attack types etc)... then i'll have to do ai for its use after. Right now i just wanna be able to run attacks through the thing lol.

Good progress so far but still not super useful. Once i finish up attacks i'll write an ai duelist and release a basic version prob and leave the fun stuff up to you guys to work on (with or without me)
pro4never is offline  
Old 05/24/2010, 07:27   #11
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Man this is a freaking great idea!
I'm definitely writing my own when my server gets farther.
kinshi88 is offline  
Old 05/24/2010, 08:35   #12
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
Quote:
Originally Posted by kinshi88 View Post
Man this is a freaking great idea!
I'm definitely writing my own when my server gets farther.
Lemme know if you start working on it, i could def use some ppl to work on stuff w/..

Kinda done 2 steps forwards, 1 back at this point. I have skills working (i cheated, just sending th final atk info rather thann going through the existing calcs) cause i was getting problems with the other way.

I'm gonna write dedicated attack calcs and skill handling tomorrow as cloning existing ones is super messy as it has sooo many checks in place trying to deal with real clients.. it's just not needed.


Ai has gotten another minor upgrade. Walking and jumping no longer interfere making tpeverything sooo much smoother plus i added more checks in place.

A few logic calculations and variable difficulty and i can work on a real dueling bot but i wanna get the base structured alot more streamlined before i start throwing more stuff ontop.

Ooh, also added some stuff like removing the bot when the owner dc's and stupid stuff like that which i forgot about till now.
pro4never is offline  
Old 05/24/2010, 19:05   #13
 
elite*gold: 0
Join Date: May 2010
Posts: 298
Received Thanks: 57
I am gonna code that in after I got normal companions coded in xD
MonstersAbroad is offline  
Old 05/24/2010, 20:48   #14
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
@pro4never
Yeah dude I'll help you if you need, you got my msn?
kinshi88 is offline  
Old 05/24/2010, 20:50   #15


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
What sort of AI will you be using? Im still working on my monster AI, and at the moment it works quite well, although its difficult to test without implementing the majority of the monster system.
Korvacs is offline  
Reply


Similar Threads Similar Threads
[Fix] Companions Disappear (5165)
03/20/2010 - CO2 PServer Guides & Releases - 14 Replies
None of you deserve this. #request close
[5165] Summoning Companions
02/14/2010 - CO2 Private Server - 10 Replies
Hey everyone, I'm using the 5165 source and I was going to replace the bat with something cooler ... but the bat, skeleton, FireEvil, and BatBoss doesn't work. Instead of summoning a bat, it does this effect (which does nothing): http://i746.photobucket.com/albums/xx110/brokentw ilight91/Capture3.png Help would be appreciated. Thank you =s
Hello fellow companions i was seeking some help.
11/25/2006 - Conquer Online 2 - 3 Replies
Hi, i recently started using a bot to lvl myself but im not quite convinced with it, my one doesn't ignite xp skills such as cyclone..and also i put in the bot to pick up items such as meteors as there is a option to do that but when theres one on the floor he doesn't pick it up..is their a new bot lvler that does all that? i tried everyway with mine but still doesnt pick items up, i looked throguh the exploits and hacks but i did not see anything as im new to all this i didn't understand much....



All times are GMT +1. The time now is 23:23.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.