Jump to content

Persistent AI and its data storage


Recommended Posts

Hello,

i am currently creating new AI for 0 A.D. as it is one of my interests to architect interesting to play against and adapting computer player. One that will not act same every time You play with it.

For this reason AI is more like human and less like "all knowing" pre programmed machine. It has pregrommed game logic and concepts but tries to improve its game strategy based on previous experiences. For this reason statistical math would be used (I have experience in this field). Downside is that in order to learn from previous experiences ingame data is not enough and data from previously played games is needed.

Possible ways to do it:

1.1) Local SQLite database ( + easy to embed, OS license)

1.2) Local PostgreSQL database ( + embedable, powerful, OS license; - not as slim as SQLite)

2) External/server based PostgreSQL database with past experiences of all feedback submiting AI instances. In this way AI could access large experience base and do really humanlike strategy decisions: building, organizing military attacks ( + large experiences database; - difficult validation of feedback quality)

3) Local PostgreSQL/SQLite database with prefetch of additional packs of "experiences" from server ( + large initial experiences database; + no critical dependencies on extenral/internet resource)

What has to be done:

1) AI interface (from C++ side?) should allow scripted/javascript AI code to access persistent storage and execute SQL queries. In other words DB interface.

What will be done from my side:

1) Code for AI

2) C++ code for interface with DB

3) Local and remote database architecture

What is of question to me:

1) Should I coordinate this work with someone in order for it to be later merged into 0 a.d.?

2) Maybe posibility of persistent storage is no no from the perspective of Core team?

Time frame: initial working result till middle of May.

Maintainability: I have future plans to maintain this AI and involve other people in its development and development of 0 a.d. As I am working in the University and there is posibility to organise some of courses in the way that would benefit both students and lecturers and on the other hand 0 a.d.

  • Like 1
Link to comment
Share on other sites

Hi, welcome to the forum.

I have minimal knowledge about the AI interface, but I would suggest making a general enough database interface that it could fit any of the backends you suggest. Local SQLite seems fine as a starting point. Just my opinion, though (y)

Edited by zoot
Link to comment
Share on other sites

We have had a short discussion on IRC about multiplayer compatibility. The problem is that an AI needs to produce deterministic results at the moment to be multiplayer compatible. Pointer's question was if there is a way to only execute the AI on the host and input commands like a normal player.

Does anyone know if that's possible and what it would mean exactly?

I think if it worked it would at least:

  • Break the replay-system (if the host's AI-State isn't included in the replay)
  • Break savegames for non-host clients (if the host's AI-State isn't included in the savegame)

Link to comment
Share on other sites

It would also make it easier for the host to cheat, because he would be able to 'remote control' the AI if he hacked it sufficiently. Doesn't seem a good path to venture down, IMO.

Is the database too big to transmit over the wire in the beginning of the game?

Link to comment
Share on other sites

Welcome to the forum.

It should be fine with the replay system since it will just be the same as a normal player, so the commands should be stored in the replay. Saving could be more difficult, I think it would only be possible for the host to load the saved game, or perhaps other players could load the game and just have the AI play differently (like how saved games and AI work now).

Regarding the database PostgreSQL sounds like a very large dependency if you have it local. SQLite sounds like a better option. Requiring a central server doesn't sound ideal, though having one available might be nice.

Edit: With regards to the host cheating with local AI. I doubt anyone is going to play serious competitive games with AI so there is little incentive to cheat. I don't think this is worth much consideration.

  • Like 1
Link to comment
Share on other sites

Edit: With regards to the host cheating with local AI. I doubt anyone is going to play serious competitive games with AI so there is little incentive to cheat. I don't think this is worth much consideration.

Better to leave that up to the players, IMO, than trying to 'read their mind' before the fact.

Link to comment
Share on other sites

Wouldn't the best way to handle this adaptive AI be to make it a stand alone web service.?

Then give it a chance to log in as a regular player and interface with the game the way other remote clients do. Then it could get better and better as people kept playing it. Replay wouldn't be a problem since the host game would just see it as another player. I know this would be a lot of work and not much help to the app, but it could be a cool thing to have.

  • Like 1
Link to comment
Share on other sites

Better to leave that up to the players, IMO, than trying to 'read their mind' before the fact.

I am not just randomly guessing. I am aware of competitive RTS gaming with AoE2, AoM and Starcraft. I have never come across a ranked multiplayer game with an AI. I don't think I have even come across a multiplayer game between people who didn't know each other in real life with an AI. Looking at database sharing later is fine but I don't think this should be discouraged at all for this reason.

Wouldn't the best way to handle this adaptive AI be to make it a stand alone web service.?

Then give it a chance to log in as a regular player and interface with the game the way other remote clients do. Then it could get better and better as people kept playing it. Replay wouldn't be a problem since the host game would just see it as another player. I know this would be a lot of work and not much help to the app, but it could be a cool thing to have.

You would need a hefty server since it needs to run the whole simulation for every AI it provides. Letting a player host the AI seems more realistic.

Link to comment
Share on other sites

Wouldn't the best way to handle this adaptive AI be to make it a stand alone web service.?

Then give it a chance to log in as a regular player and interface with the game the way other remote clients do. Then it could get better and better as people kept playing it. Replay wouldn't be a problem since the host game would just see it as another player. I know this would be a lot of work and not much help to the app, but it could be a cool thing to have.

Hosting an intro cinematic isn't favoured because it's considered as in-game content. I think the AI is more important than the intro cinematic. So online content certainly shouldn't be the only source.

The other nice thing about a learning AI is that the level of the AI grows organically together with the level of the player. So every game is challenging again. This won't be achieved when using a central database.

And for competition (if this is really a problem). If one plays in a tournament, the organisation of the tournament could host the game with the AI. A second option is that for tournaments, only static AIs could be used (like the current Aegis and qBot). A third option is to look into signing packages, and only allow packages signed with the 0AD key on tournaments. So there are enough possibilities.

Link to comment
Share on other sites

Are you sure that a relational database is a good fit for this feature? I'd guess that you'd rather need a more specialized graph database, of course depending on which approach you want to take (game trees etc.). Performance will most probably also get critical.

Link to comment
Share on other sites

Regarding the database PostgreSQL sounds like a very large dependency if you have it local. SQLite sounds like a better option.

Embeded Postgreqsl 9.1 is 20 Mb, when inited 34 Mb. Pgsql differs from similar products in its management and use of resources. Low resource usage combined with high level DB functionalities would allow to do more efficient data agregation inside DB and not in JS code of AI. Also, historical statistics of games played in the past and similar data could be stored in DB.

As I understand that addition of any such 3rd party element would require a lot of consideration for core team, it would be nice if at least most minimal of embedable DBs - SQLite would be added.

Are you sure that a relational database is a good fit for this feature? I'd guess that you'd rather need a more specialized graph database, of course depending on which approach you want to take (game trees etc.). Performance will most probably also get critical.

I am currently developing NewSQL type database (in C++) in some ways similar to Google Spanner, so I undestant pitfalls of RDBMS and some key/value or graph type databases would be very good addition, though added complexity too.

As I see, the problem is divided into two:

1) Ability for AI to store data in persistent store. Universal interface for comunicating with database.

2) Specific implementation of DB used by specific AI.

  • Like 1
Link to comment
Share on other sites

I am not just randomly guessing. I am aware of competitive RTS gaming with AoE2, AoM and Starcraft. I have never come across a ranked multiplayer game with an AI. I don't think I have even come across a multiplayer game between people who didn't know each other in real life with an AI. Looking at database sharing later is fine but I don't think this should be discouraged at all for this reason.

You would need a hefty server since it needs to run the whole simulation for every AI it provides. Letting a player host the AI seems more realistic.

I would really like a AI that could potentially be very challenging, when I play AoE 3 multiplayer 99% percent of the time it's me and a bunch of other people playing against an AI that's set to the hardest level.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...