The WarLight AI goes open source!

Today, we’re proud to release a framework that allows anybody to develop a WarLight AI! This framework allows any programmer to write code that plays games of WarLight, using any of WarLight’s settings and maps, for the purposes of eventually developing a new, smarter, AI to replace the current one.

Last year, TheAIGames.com ran a WarLight AI competition that allowed players to write their own WarLight bot, which would then compete with everyone else’s bot in a big tournament. This was a lot of fun, and produced a lot of WarLight AIs.

The authors of three of the top AIs from that competition have agreed to donate their source code to WarLight: GreenTea, Norman, and cowzow. I have converted Norman’s AI to work with WarLight’s engine as an example of what can be done. You can find it on github at https://github.com/FizzerWL/WarLight.AI. This project includes a framework for writing and debugging WarLight AIs, and two example AIs. The first example AI is called Wunderwaffe, which was written by Norman for the AIGames competition, and the second example AI is the current WarLight AI that’s used in production today, called Prod.

Goals

The ultimate goal of this project is to replace the current AI with a new, smarter, one, for both single-player and multi-player. This is the first part of a larger effort to overhaul the single-player section of WarLight. Updating the AI needs to happen before new single-player levels can be developed, since those levels need to be balanced based on the AI. We don’t want the AI to significantly change after these levels are made, since the levels could be made too hard or too easy to be fun.

When developing a WarLight AI for this purpose, it’s important to understand what the goals of the AI are. In the AIGames competition, the goal of the bots were to be as good as possible when fighting the other bots — win the maximum number of games at all costs. For a WarLight AI, the goals are different. For example, some bots would have logic that would tell them to run away from the opponent once they’ve detected that they can’t win the game, in the hopes of prolonging the game and forcing a draw. This wouldn’t be a fun tactic to play against when playing a single-player WarLight level.

The main goals for a good WarLight AI are, in order:

1. Be fun to play against in single-player.
2. Be fast (don’t consume a lot of CPU or memory).
3. Be good at defeating human players.
4. Be fun to play against in multi-player.
5. Be good at defeating other bots.

As you can see from this list, being fun to play against is a higher priority than being good. While being good is a goal, it’s more important that people have a fun enjoyable experience while playing WarLight.

Since the AI is used in every single-player game, and only select multi-player games, single-player is placed at a higher priority than multi-player. The single-player experience is an important part of WarLight since it’s the first thing most people experience when they first play.

Making the AI fast has to be a high priority since a slow AI will time out, essentially breaking the game. Of course, “fast” is relative. The key thing is that the AI doesn’t take an insane amount of time. Some people play WarLight from low-powered devices/computers, and if they have to wait 30+ seconds in between every turn, it would not be fun for them. Since you can play with many AIs at once, the AI should not take more than one second to compute its moves/picks, even on large maps and relatively slow devices.

I was tempted to include “don’t be predictable” as a goal. However, this really falls under the category of “Be good at defeating human players.” One key part of defeating human players is not following the same patterns every time. Defeating an AI that’s too predictable will train players to fight that AIs tendencies, when an AI should be training players to fight other players.

Contribute!

If you can code and you want to help contribute to the AI, I put together a short video giving an introduction to the code:

Github repro: https://github.com/FizzerWL/WarLight.AI

21 thoughts on “The WarLight AI goes open source!”

  1. I’d suggest long term you want two AI’s, not one. The goals for single and multi player AI’s are rather different.

    A multiplayer AI shouldn’t have it’s primary goal to be fun to play against, but rather to be fun to play with. I’d want my team mate AI to focus on being good not making my opponent have a good time.

    1. Some of the single player levels will have AI teammates too. You can have an AI that detects when it has a teammate and behave accordingly.

  2. I wonder what will happen with current rewards and stars for beating single player maps/tutorial.
    Will they be removed, or left for those players, who achieved them before new AI is implemented?

    1. That hasn’t been planned out yet, but I suspect we’ll keep the current levels around in the new overhaul. If they don’t fit into the main flow, they can always be bonus levels.

    1. You could, but I prefer to vary the difficulty by varying how many enemies you start against, or by giving them more armies at the start of the game. This makes it more transparent.

  3. This seems like one of the best changes since I joined. Playing against the AI is normally very easy, so hopefully this will make it more fun. Great job!

  4. I would suggest that for Multi-player and for Single player custom games/scenarios (not built-in levels) that multiple AIs be selectable (and potentially configurable) so that each AI ‘player’ could be assigned a different AI ‘engine’. This would allow for much better games and custom scenarios with AIs. For example, you might want to have a ‘neutral’ AI that just tries to maintain its original territories, without expanding, to simulate ‘neutral but not passive’ countries in some historical scenarios. Or you might want a very aggressive ‘barbarian’ style of AI and a more long-term ‘expansionist’ style of AI in an ancient Rome scenario.

    With this possibility, you don’t have to worry so much about a single unified list of ‘goals of the AI’. Those could just be the goals of the *official* AI, for single-player levels and for default AI for most games.

  5. This current AI default warlight has a big bug !

    He don’t any move in a game with no income (i mean a game with setting basic armies per turn zero)…. however he have several army but he don’t any move without any income at the start the game and after that …

    Need someone enhance it .

  6. I wrote one of the frameworks to write the bots in Tcl for the AI competition, so my question is: where is the “API” that the bots need to use for Warlight?

    Can they talk over a socket (so that the bot can be run on a different machine)?

    1. The bots all talk to the AI Server, so yes, they can be run on different machines, but it happens with HTTP request, not sockets.

      Any language can be used, but right now the only sample provided is in C#. If you want to use another language, you’d have to look at the C# code in the “Common” folder and port it to your language of choice, as this is the only place the API is defined.

      The reason we only provide a C# starter pack is because the goal of this project is to make a new AI for WarLight, and this final AI has to be in C#. But you’re welcome to experiment with other languages as you please.

  7. There’s a class in the code called AIGamesParser and a line to uncomment in order to call it. But it has some issues. For example The AI Games’ server sends a command “pick_starting_regions” while your parser expects “pick_starting_region”. When I add the “s”, the Prod bot doesn’t make a valid response. Would I be correct in guessing that maintaining compatibility isn’t a priority for you?

    1. Ah, it appears this bot corresponds to what The AI Games calls “Warlight 2”. And that the protocol is not backward compatible.

  8. I am working in an AI for diplomacy games, but its a bit more complicated than I first thought.It goes in the lines of AI taking over players that get boot or surrender, and it expands only into neutrals, attacking only players that attack the AI first…its not easy cause if someone gets booted before turn 1 AI seems to go into random spots not “respecting” the claims of other players in the chat…anyway,just working on it…

Leave a Reply

Your email address will not be published. Required fields are marked *


*