Category: Video games

  • Welcome Back, Commander – Adding LLMs to OpenRA

    It will not shock anyone to hear that I’ve played a lot of computer games. One of my favourite series is Command & Conquer, and in all of the C&C games a large part of the fiction has been the Electronic Video Agent – E.V.A.

    E.V.A. is an artificial intelligence tasked with assisting you (the commander) on the battlefield, keeping track of objectives and notifying you of important events. Of course, the E.V.A was really just a collection of sound files and video clips that were triggered by certain events in the game. But what if we could add an actual AI into the mix?

    I’ve been playing a lot of OpenRA, which is a recreation of the classic C&C games with modern touches and multi-platform support. I recommend it to anyone with happy memories of C&C from the nineties. It is open source and written in C#/.Net, which makes it ideal for this experiment.

    I used Semantic Kernel to add Large Language Model functionality to OpenRA. Semantic Kernel is useful because it allows you to swap in and out LLMs and experiment with different providers, and it also allows those models to call local functions in your code to gain information.

    Code showing how to instantiate Semantic Kernel.

    I hacked it together so that you could ask E.V.A. for advice about anything by typing “/eva” in the chat, and also set it to automatically call the LLM every two minutes to get the most important advice right then. I also added text to speech and made it so that OpenRA could play back the sound files without reading them from disk first.

    I actually had a really interesting double bug situation to solve when the WAV files being returned by OpenAI wouldn’t play. It turns out that in WAV files there is an 32-bit unsigned int header declaring how many bytes of data will follow in the file. OpenAI just sets all the bits in that header to 1, which I speculate is because they don’t know the final size of the file when they start generating it. Essentially it means that they declare all their WAV files to be 4 GB in size and hope the program reading these files is lenient about parsing them.

    OpenRA wasn’t lenient, but more than that, it had a bug where it read the unsigned int as a signed int. That mean that instead of trying to move 4,294,967,295 bytes ahead in the data stream (also not good), it was trying to move -1 bytes ahead, which obviously made it hard to play back the data correctly. I fixed that bug and made the handling of WAV files more lenient.

    Code showing a function that Semantic Kernel can call the get information about the player’s economy.

    I created indicators for the game economy and build queues, and fed the LLM an initial prompt with how it was supposed to behave and what faction the player was. I added a bit of my own tactical wisdom and finally linked to a strategy guide for OpenRA. Getting the tone right was tricky – LLMs tend to be very verbose and friendly, and what we need is a no-nonsense robot.

    Code configuring an initial prompt for E.V.A.

    After a decent amount of fiddling about, I got it all working. The sounds of the new E.V.A. collide a bit with the original E.V.A., but that could be fixed with some more effort.

    Starting the game and asking an initial query.
    An example of the automatic advice every two minutes.

    One of the useful features of Semantic Kernel is the ability to switch LLMs easily, so I experimented with that. I tried Microsoft’s Phi Micro 4, OpenAI’s GPT-4o-mini, and their 4o model.

    The great thing about Phi Micro 4 is that it ran locally! The not so great thing is that on my old clunker, it took a full minute of fans going maxed out to get an answer.

    GPT-4o-mini ran faster, but the obvious disadvantage is that you have to be always online and pay real money every time you play. 4o was even better at being E.V.A., but costs multiple times more money every time you play.

    It has to be said though, none of the LLMs were savants at playing Red Alert. Obviously having a tuned or pretrained model specialising in mid-nineties real time strategy games would help a lot here.

    Some sound tactical advice in green, and some unsound tactical advice in red.

    There’s an interesting discussion to be had here about the tradeoffs between local models and high-spec hardware versus remote models and pay-per-use billing. Especially if you were going to design a computer game around having LLMs as part of the experience, how would you split the cost of that LLM usage between you as the developer and your customer, the player?

    All in all, I had a blast making this! I don’t think I’m going to spend more time perfecting it, but it sure was an interesting experiment and gave me some insights in what you have to weigh against each other when implementing LLM functionality into programs. I held a talk about the project at Sopra Steria Norways internal tech conference, Bytefest, where I feel it was well received. It might be making its way to a recording on the net or as a lightning talk other places, in which case I’ll be sure to update this blog post.

  • Regarding Ace Combat

    Fourteen years ago, I wrote a review of Ace Combat: Assault Horizon, and gave it fanboy out of ten points. But since then, my feelings for it have cooled – it never really lasted in my playing rota like the other Ace Combats. I found myself missing the lore of Strangereal, the “other Earth” that allows Ace Combat to disregard which nation those wonderful planes come from.

    In 2019, Ace Combat 7: Skies Unknown arrived and showed me what it was I was missing. Six years later, and it is still a go-to in my limited playing time. A beautiful spectacle and a triumphant return to form.

  • Installing Jedi Knight II On Linux

    After seeing the new trailer for Star Wars Episode VII, I was suddenly overcome with the urge to play my favourite Star Wars game of all time, Jedi Knight II: Jedi Outcast. Since I’ve sworn myself to a Windows-free home environment, some challenges were posed.

    Lucikly, Raven Software released the source code for the game engine last year, and this helpful person has created binaries that will run it on Linux: https://github.com/xLAva/JediOutcastLinux. But since it is only the engine and not the game assets, we need to get them from somewhere. Steam to the rescue! I went ahead and bought the full Star Wars pack on sale. But when you open Steam, you’re told that you can’t install the game since it is not available for Linux on Steam. Booo.

    This is where SteamCMD comes in! It’s a commandline tool meant for administrating dedicated servers, but it can be used to download game data for any game! Follow the instructions on the site to download it and run it, and if you have Steam for Linux installed, it will automatically pick up on your Steam login.   Just remember to remember to force it to pretend it’s on Windows by setting the correct variable, and then download the  app.  For JKII, the Steam app ID is 6030. (Protip: You can check the steam app ID by looking at the page for it in the Steam store: http://store.steampowered.com/app/6030/ .)

    Installing JKII with SteamCMD.
    Installing JKII with SteamCMD.

    Next, you have to follow the README for JediOutcastLinux.  One snag I hit was that Ubuntu 14.04 LTS 64-bit does not have ia32-libs, but install lib32z1,  libopenal1:i386, and libXrandr2:i386 instead and things should work the same. (When you run the game from the command line error messages will tell you what you’re missing.) Just download the whole repo as a zip if you’re only interested in playing, and grab the binaries from the code/Release folder. Copy the base folder that you’ve downloaded via SteamCMD together with the binaries, mark the binary as executable, and you should be good to go! The game works beautifully, with fullscreen, crisp graphics and smooth framerates.

     

    Jedi Knight II Fullscreen on LInux!
    Jedi Knight II Fullscreen on LInux!

    Update: I just finished playing through the entire game without ever crashing! (Which I believe is better than when I played it on Windows back in the day…)  The only things that were a bit off were that debug messages sometimes appeared in the top left corner, and that dark or foggy places sometimes were overly dark/foggy. (I guess the video drivers behave a bit differently than ten years ago on Windows.) But no problem, because we have night-vision gear in the game!

    I even managed to make it load up a mod, but sadly it crashed after the mod’s intro was over. Ah well, still not a bad showing all in all!

  • Video Game Review – Ace Combat: Assault Horizon

    Disclaimer: This review is written by a longtime Ace Combat fanboy.

    Here’s a trailer of the game in order to set the stage and give you a little on what to expect:

    Second disclaimer: If this trailer full of awesome explodeyness and allround adrenalin-pumping didn’t get you interested, you probably have no interest in the rest of this review.

    Ace Combat has always been about flying awesome planes around in awesome aerial combat whilst shooting down others in at fist-pumpingly awesome manner, and this game is no different. However, they’ve had a go at spicing it all up with some new stuff that wasn’t in previous games and shaking it all about. Gritty dark reboot type thing, like Batman Begins.

    Here’s some of the new stuff:

    • Moving from a parallel dimension to more or less our dimension. Previously, all AC games were on a sort of parellel earth with different geography and countries (although always vaguely reminiscent of real countries), but all the same plane manufacturers as we have in our world. That allowed us to have great mixes of planes without having to think over why someone had Russian and American planes in the same air force. Since they had developed it over several games, I felt a rather strong attachement to it and was concerned that putting things in the real world would make things more boring. However, they avoided this by completely disregarding boring stuff like politics, economy and logistics which is a bit silly at times but generally rather fun. Also, doing battle over cities you recognize from the real world is kinda awesome and gets automatic bonus points from me since I study geomatics.
    • Helicopters! (Aw hellyeah-acopters.) For the first time in AC you get to hover if you want to, but then you’ll probably get shot down by a PRG-toting maniac on the ground. Quite fun, but some issues with control and general playability. Still, it’s fun to ambush armoured columns by waiting for them to drive onto the Moscow boulevard you’re hovering at the end of.
    • Miniguns! You get to stand behind a minigun and blast the hell out of people on the ground. Makes for a nice distraction, but glad it’s not the entire game.
    • Strategic bombers and AC-130s ! What’s not to like? Eminently satisfying one-off missions, just the right amount of this kind of gameplay.
    • Dogfight mode. As seen in the trailer, you can initiate dogfights where you get up close and personal. To begin with I thought it was kinda silly, but by the end I had really warmed to it. Adrenalin-pumping excitement which really gives life to encounters with enemy aces and lets you fly through some ridiculous setpieces.

    The new stuff is generally good, and the old stuff is classic Ace Combat, the kind of game where when you get shot down you pound the sofa pillows and shout “I’ll get you next time, Markov! AGAIN!”.

    Third disclaimer: This kind of behaviour may worry girlfriends, boyfriends or anyone else within hearing distance.

    Also, there’s a bunch of online stuff which I haven’t tried yet, but it’s probably a bit less off the hook and considerably harder. (But still fun, no doubt.) I would recommend this game to anyone has enjoyed previous Ace Combats and anyone who thinks a video game directed by a Japanese Michael Bay sounds fun. All in all, I give this game fanboy/10.