Is it possible to let player write AI and do AI vs AI wars?

I’m trying to make a game where different players can write their own AI (js or lua or any user friendly language) so that players can upload their own AI and do AI war against another player’s AI. I want to know if it is possible to do in unity and if it is where should i start looking at.
I want to know how to compile and run in runtime the AI written by a player. Please point me in a direction.
The game will have server running and all the moment, damage etc is calculated on server. For this i’m thinking of using unity networking. So the solution should be able to run on unity server.

You can have a look at a package I’m maintaining: http://www.pandabehaviour.com.
The AIs are written using a minimalist language based on Behaviour Tree.
The scripts are TextAssets and are compiled at runtime.

If you have question or suggestion, you are welcome on the dedicated thread:

Internally we have competitions doing just that. We have a game called tank wars that has a node based ai. We have several days to build and test our ai, then they are pitted against each other In a huge tournament. Its a lot of fun and is a great way to explore ai.

1 Like

It’s probably easier than writing an actual game because the AI doesn’t care if it’s having any fun! :slight_smile:

Screen savers aren’t too popular these days, but I’ve always wanted one that was just a giant non-stop space war, so I’m writing one. It’s a three-way fight with three separate approaches to the AI. I’m not entirely sure a lot of the differences will be apparent in the end product but it’s fun to write, it looks cool, and it makes for a great realistic-scope learning project.

Letting users actually compile code is extremely difficult to do safely, but as others have said, there are plenty of scripting options available.

@JoeStrout 's Robo-Reindeer Rumble just finished up a couple months ago. Players could write and upload their AIs in an interpreted language called MiniScript that Joe designed. It doesn’t run on an authoritative server, but it’s a good example of competitive player-written AI battles.

Microsoft had something for .NET way back when it was new. I forget the name, it was “virtual ant farm” or something like that. It was meant to showcase the sandboxing capabilities of .NET and IIS. That would be a highly advanced approach but it can be done.

For the life of me I can’t find any links about that particular project any more though, does anyone remember it?

@170524_Plato , Robo-Reindeer Rumble is built on MiniScript, an asset I’m working on. It’s mostly waiting now for more detailed documentation before I release it… but if you want to be an early adopter, just PM me and I’ll get you set up. What you’re describing is exactly the sort of thing MiniScript is designed for.