Jump to content

AI for President! (a coders dream)

Recommended Posts

(EDIT 30.05.17: Further development on the original proposal is suspended, as there were no players willing to join this kind of organization... But for reference I will not remove anything said in the original post)
(EDIT 28.12.17: After joining ODY, I'd still like to promote the core idea of this proposal. My new goal is to create separate standalone open-source-projects which are loosely inspired by AI, just without the whole organization idea. Players will be able to repurpose these programs for their own use. I only wish for my programs to assist players in their everyday DU activities. For more information refere to the new project list at the end of this post.)


================================================== Original Post ===================================================

Dual Universe is the perfect setting for a little social experiment. I love boundless sandbox games, like this one, as they really promote creative gameplay.
An often reoccurring theme in science fiction is the dream of a perfect society...
I strongly believe that the only way to get closer to that vision is to create an artificial intelligence especially dedicated to take all important governmental decisions of a society. All mistakes that happen in a society because of human errors could be prevented!
So what would be better opportunity to test this statement, than to actually play around with this idea in a game? Nothing can go wrong here! :D
As you might've guessed this is an organization proposal, even though I don't have a name yet. I think a sort of research institute would be quite fitting.
But this can be decided later by vote of the members. The name is actually not that important.
Most important is how the AI is actually going to work. The ultimate goal is that the decisions of the AI are as reasonable as the decisions a human leader makes. Luckily DU is still quite limited (relative to reality) according to the possible decisions an organization can make. Therefore only simple programs are needed to get to the "right" decisions.
Also important to note is that the purpose is not to micromanage everything the player does, but to only give high level supervision like a real government. So the players will still have private ownership and private sub-organizations e.g. a security service.
How it works
I've already set up a core framework for the AI based on a Discord Chatbot written in Python 3.5. A direct integration into DU will probably be very difficult as external programs are often used for cheating, and I hope NQ is well secured against this.
However some abstract information of the game given through Discord are all that's necessary to make reasonable decisions.
The easiest tasks for decision making are reactive decisions. In most cases there is only one correct reaction to a problem, which can be programmed by simple if/else statements.
In the following picture I've tried to visualize how several aspects of the game could be handled by the AI: (sorry for the plain appearance, it's only a placeholder which will be replaced with the actual features of the AI)
These are only some examples that came to my mind, and not necessarily the most important ones!
What I'm really eager to see is how the AI will manage more vague decision processes, e.g. who is a trustworthy ally and who not (like indicated in the 1st picture). This will no longer only be an If/Else decision. The AI will need to adapt its decisions based on previous experience (so called "reinforcement learning"). Therefore I integrated the machine learning library "tensorflow" which is basically the brain behind all Google AI projects. They actually just open sourced it last year! This library is probably a little overpowered for the current tasks, but I'm sure we will use it more in the future! ;)
On the economic side the AI will automatically create jobs based on the needs of the organization and pay for every accomplished task.
Another important factor would be the spatial awareness and building functionalities. Buildings and infrastructure should be build using predefined blueprints and functionalities, so the AI knows exactly what infrastructure is available. To keep the program simple everything in the world is reduced to an object-type (e.g. city/ mine/ military outpost) which has specific attributes (e.g. storage capacity/ defense turrets/ position).
Each of this information has to be kept up-to-date by the players.
Security Issues
And in here lies a weak spot of this system. Our enemies and griefers will probably try to harm the AI by feeding it false-information, and thereby causing false reactions. So only trusted Members should have access to change critical information... However this will turn to a more and more time consuming task, as the overall information in DU continues to grow. Hopefully we'll find an alternative solution for this in the future.
The decisions regarding the further progress of this project will be made by the programmers which are participating in the development of the AI. We could form a sort of democratic "Coders Council" in game, which will also decide on matters where AI is not able to make meaningful decisions. However the AI will always be the official leader of this organization, also for roleplaying purposes.
Apropos roleplay: I created a little backstory that would fit quite well to the great DU lore. (read here: https://devblog.dualthegame.com/2016/11/16/official-lore-bible/ )
"During the anti-AI-riots in the year 2145 there were still people who supported the sentient AIs. A group of scientists thought the fear of AI was only caused by human ignorance of their thought-structure. Certainly the phenomenal advancements of the AIs were scary, and made them seem acting strange, but only because the humans could not catch up with their development.
During that time it was too late to stop this overhasty destruction of all AI. The scientists had to go underground and swear to rebuild AI, but this time without letting their mental abilities run out of control. They tried to hide forbidden AI technology, but the [UMF] soon discovered their hideouts and purged every bit of knowledge that was left. The whole mankind was under continuous oppression by the [UMF], right until the Great Exodus.
But even though all technology was lost, the idea survived. A few scientists of the secret society decided to found a research institute on Alioth dedicated to rebuild an AI from scratch. This time they would be more cautious. Even though they admire Aphelia as she is the only (proto) AI on Alioth, they also fear her because she might be programmed by the [UMF] to make sure the colonists will follow the AI ban that is officially still in place on Alioth." (to be continued)
Development Participation
This stuff has probably never been done before, so it's very likely that it might not work out as planned.
But if you like to develop your own AI, or you'd like to see a leader who is online 24/7  B)  you should join us!
It's also no problem if you are already member of another organization. I uploaded the AI on GitHub as open source project, so you can use it for your own organization as well. I welcome everyone who is willing to contribute to the project:

I skipped a lot of details of the development, so if you want to know more feel free to contact me. Maybe it would be helpful to even open a new thread on this forum exclusively for the programming part.
I'm probably more into programming than into the actual playing, but I'm sure there are some like minded coders/engineers who would also like to see this happen!

I invite everyone to test out the AI on this public test server. Currently most functions are still placeholders, but you can try to do some Smalltalk with the AI.
The first thing that actually works is you can register yourself to its database, and the AI will remember you when the game launches. ;)
Link removed!  (discord-bot has been shut down)
I've got the feeling this is already getting to long, so I'll try to update this section further while the project continues.

(EDIT 08.01.17: added overview)
Chatbot Feature Overview
Input Interfaces: Discord messages, Teamspeak PMs, Console commands, RSS feeds
Output Capabilities: Discord messages, Teamspeak Text-/Voice-chat
Economic Management: Keep track of resources, and assign players to specific tasks, according to their job-preference
Entertainment Features: Conversational Chatbot, TTS of the DU Lore, TTS of input text



(EDIT 28.12.17: Restructured Project List)

================================================== Project Overview ===================================================

Web interface for management of Dual Universe organizations:  https://github.com/CyberCrunch/DU_AI_Cloud

Dual Universe themed tts-chatbot to assist players ingame:   https://github.com/CyberCrunch/DU_AI_Adjutant

A post regarding these new projects will follow soon...

Share this post

Link to post
Share on other sites

First off, welcome to the forums :-)


Secondly, much like you, my first post on the forums was a really long one that (I'm sure like you) I put a lot of thought into writing up. 


I'm going to take some time to read through this more deeply so I can process it all, but for now, I look forward to the other deeply thought out contributions you may bring here in the future :-) 

Share this post

Link to post
Share on other sites

I like this idea and from what you've already said, I think you are well suited to champion this project. I will definitely be interested in assisting in this project, such as I am able, although more for the sake of design than actually living under it's control. 

Share this post

Link to post
Share on other sites

Thanks a lot for all your positive feedback! I've also fixed the link to discord, so people can actually join in now...


I very much look forward to get some feedback from you on the development of this Chatbot.

We will probably figure out over time what actually works and what not. And before the alpha launches everything will only stay a thought experiment...

Share this post

Link to post
Share on other sites

That's a really neat idea. I look forward to watching the development of this and hope DU ends up being flexible enough for this to be possible.

Share this post

Link to post
Share on other sites

I see one major drawback in your proposal:


You re NOT creating an AI, you are proposing a rule based decision making machine. It makes no difference whether you implement it as a flow chart diagram or in python, it will not be intelligent at all. In your codebase there is a file called machine_learning, an approach equally unfit for an "AI" in this kind of games, because finding similar events and training accordingly is really complex here, look at this (slightly mathematical) approach:


In go your there are 19*19 = 361 fields where a value can be. This yields a search space of (at max) a dimension of 361 to find situations and appropriate reactions. This problem was not solvable on a PC.

Now consider dual universe. There are way more than 361 values that can (and should) influence your decision making as well as no data on how to react on those. And there is another problem: keeping all values up to date and produce similar results on similar actions. The first problem will most likely only be addressable if Novaquark grants access to Dual Universe for such a system, but the second is way worse. Given the following scenario:


A huge ship attacks one of your stations (one that can take out all your ships at ease), what do you do? Next time it is only a small fighter. So learning will be extremely expensive for your org as well as hardly reproducible because the correct reaction can hardly drawn from incomplete data.


These are all concerns regarding governance "AI", I wish you best luck, seems to be an interesting approach either way.




Share this post

Link to post
Share on other sites

Well these are some valid concerns... thanks for the constructive criticism.


It's true that I not intend to create an actual "strong" AI, as modern science still struggles to achieve this.
All I want to create is a program that is actually useful, and therefore weak AI technology is already sufficient enough. It should react as a human would do in the game, and sometimes humans are also just "rule based decision making machines"! ;)


However you are right that there will be situations where there are probably 361 possible values to consider for a decision. As there is no way to handle such a complex structure, we will have to scale down the problem and create a simple model where only sort of the 3 most important factors are used for  the decision...

In short, the AI only has a very simplified understanding of what is going on in DU. To figure out how to generate meaningful decisions despite these limitations will be a big challenge for the development, but we will tweak the program until it reacts more or less humanlike.


But a much more difficult problem occurs when you can't even define an actual "number" in certain situations. For example an alliance in game will be evolving on a much more personal level, but you can't program human intuition... a human might thing "they acted strange today, I guess they want to backstab us and join our enemy". But what does it mean to an AI now? Trust-level = -10??? It’s probably not that easy.


There will always be situations that are virtually unpredictable. But humans will have difficulties, too. You never know for sure when and how someone will attack you...



I created a more reasonable software architecture which you can see in the following UML diagram:


I actually left out most functions to give a high level understanding of the structure of the program. Modules that are currently not implemented are shown in gray.

The communication to the AI needs to get more flexible, as it will be kind of annoying to switch to discord every time. A cool idea would be voice commands, or direct integration into the ingame organization-chat. However the communication to DU should stay as limited as possible. It would be cheating if the AI could actually control stuff in the game. However it would be helpful to automatically read out the money and resources owned by the organization. But that might also be tricky... I'll open another topic for that in the Game Mechanics forum.

In regards to the decision-making I only see 2 types of decisions in this game: Economic and Military decisions. Both types have manageable resources: Money, and Military force. The AI will have to be trained on what to do with these resources, and how to set priorities.


I also filled up the placeholders in the Job-system, so now it's actually working now. I will upload the changes to GitHub later.

Share this post

Link to post
Share on other sites

I'm very happy to see I'm not the only AI enthusiast out there. It's very important that people actually want to use this technology!


In that regards I'm happy to announce that I joined the Vulture Corporation as their AI developer. They are using an AI as "mascot", and I'm going to try to put some life into it. ;)

The goal is to use this as little gimmick for roleplay and external representation of the organization. So this will be a more semi-automated chatbot controlled by the VC.


Even though this means that the core government features will be delayed for a while, I see this development more as an extension of the AI-features. First of all people should get more interested to talk to the AI, and later we can work out how to actually make it useful.

It will probably never be a program you can just switch on, and than it can govern an organization. It should be more of an evolution over several years, where we add more and more features to make it more useful.



To adapt the chatbot for the Vulture Corporation I first had to port it to their communication systems, which are namely TS3 and their Enjin website.

It was surprisingly easy to access these systems through my Python programm, as all major platforms have some sort of application programming interface. (To be precise, I used a telnet connection to the client-query-plugin for TS3, and the JSON-RPC protocol for the Enjin-API)

Thereby I can easily input and output messages to these programs.

I also added a text to speech synthesizer (gTTS) to output messages in TS.

So now it's possible to: -> input messages through a text-chat -> and the AI answers in a vocal output to the TS channel.


The AI should also have full access to the Enjin website, so it would be possible to automatically post announcements, ect., but I was not able to test that feature jet.


I wonder why there aren't more bots around, as this opens endless possibilities. Sadly most people seem to use them only for spam-bots these days...


Anyways, if YOU want to develop a discord/ TS3/ Enjin bot for your organization, I might have a good basis here! ;)

It will actually not work out of the box, as I had to use some workarounds to get everything running. But I'm going to clean up the code, and add some documentation.


If you are interested in the development, please contact me. Or join the Vulture Corporation, to see the AI in action! :D

Share this post

Link to post
Share on other sites

An administrative AI is something a lot of orgs would be interested in. I however like to keep things personal as whilst humans can be flawed, AI can't improvise or have heuristic thinking (aka, thinking outside the box, which is necessary for some of the more shadowy persons)

Share this post

Link to post
Share on other sites

Finally the exam weeks are over! Time to get back to the real important things... ;)
I'm sorry for being inactive for the last months, but you should not assume I will ever abandon this project!
Luckily we still have some of time before the release, and I think real "ingame" features of the AI should be developed when the game is actually playable.


For now I have more trouble to come up with some short term usage for this chatbot.
I think one thing that is always relevant for DU are the forum posts. So the AI should learn to parse the forums RSS-feeds and store them in a database. When a new announcement is post is created, the bot automatically posts it in the chatrooms, or reads it out via TTS. An easy way to make sure all members are up to date.^^
This will be my next step for the chatbot.


During the last weeks we (at Vulture Corp.) also played around with the TTS-functionality, and found a possibility to use a voice distorter on the virtual microphone so it makes the default google-voices sound more like computer voices. Very important for immersion and RP! ;)

Share this post

Link to post
Share on other sites

I am quite interested in how this project turns out, while I would prefer a human leader myself, the power of an administrative AI can not be ignored and can help any org a lot in their procedures. I hope that with the system available to us in the game we can come up with some awesome and I would love to be part of this project :) though I am not a programmer so if you need any other kind of help :P

Share this post

Link to post
Share on other sites

I think my initial post probably scared off some people who would consider using an administrative -Chatbot- in there org.

As I said previously the whole "AI for president" thing is more of a long term vision / neat fantasy of mine. For now I'm just playing around with some (hopefully useful) chatbot features.

Anyone who want to help this project can just suggest some features they would like to have in their org. Until now Warden was the only one who contacted me in this regards...



I finally got a basic of the RSS-feed reader working. Luckily someone else has already done this, so to get a reader was not the problem.

(source: http://alvinalexander.com/python/python-script-read-rss-feeds-database)

However getting the output to be posted into discord/TS is a little trickier. Somehow the python feedparser I'm using has some difficulties converting special characters.

No idea why it is necessary to have 2 different characters for ‘ and `  ,or  – and - . My keyboard can't even produce these characters!! (maybe French keyboards) ;)


Anyway: after filtering out all special characters, it's now possible to search for new posts (in the announcement section) and post the text in discord.

But please don't do posts with Chinese characters, or I have to start all over again!! xD

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...