Advertisement

Incorporating programming into gameplay

Started by March 25, 2015 02:09 PM
16 comments, last by Norman Barrows 9 years, 8 months ago

There have always been some games which focus on the player doing some programming but I've only seen this done AS the game e.g. write a bot AI for a bot fighting game.

My interest is mainly in RTS games and particularly in giving the player a higher-level position in controlling their base and armies instead of individual units. One interesting idea (to me) is having a hierarchical AI system... each unit has its own AI, each unit is in a squadron which has squadron-level AI, squadrons group into larger groups led by a General who has it's own AI, etc... similarly your base has AI controlling how to prioritise resource harvesting, unit creation, which buildings to power/protect in case of shortages.

Being able to upgrade these AIs as part of the game could make a big difference rather than just having bigger guns. But then one thought I had was letting the player actually write their own AI code. Designing how your Generals will function to complement your tactics, and so on.

Many games use scripting (Lua, etc) for AI which means in theory you can already do this if a game exposes those scripts. But what do people think about this actually being a deliberate part of the game?

Both in RTS and other games, how does the idea of part of the game being about programming grab you? Is this so niche that it's commercial suicide and could only happen as an open-source/hobby project?

I love games that incorporate some kind of programming, the first that comes to mind is SpaceChem.

In that one though, it IS the game as you say, just wanted to mention it since it illustrates my point.

It's not actually a turing complete language, but still with so much flexibility that it feels a bit like programming for the initiated, but not too much to scare "normal" people away.

It feels more like a puzzle.

I think that is the main problem, design something that has some of the flexibility of programming, but not too much flexibility so it becomes more or less an AI programming assignment and require the player to read a couple of AI textbooks to have a chance.

That sort of thing would be nice as a university/college competition, but not really a game.

Maybe let the player task be more about setting up decision trees and balance weights, and combining already made algorithms and less about actually implementing the algorithms themselves.

Advertisement

Good points. You would have to provide a great "standard library" of functions like "find a route to (x,y)" or "what is the nearest enemy unit" so the 'player' only has to focus on high-level logic.

I quite like the idea of an RTS where all the player does is write these AI routines... like an AI bot game except you're writing a multi-layered RTS strategy. Then you get to watch your creation engage in real battles. But that's definitely moving away from a real game, so let's not go there ;)

Many RPGs include a simplified programming interface to define companion AI behaviours. For example, the Tactics system in Dragon Age: Origins.

Mastering tactics setup is essential if you want to avoid having to micro every member of the party, but similarly, if you are good at micro, it can be ignored entirely, so it's not clear that it forms an integral part of the gameplay.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Also, you would need to design some kind of visual scripting system so the programming muggles wouldn't be totally turned off by the sheer amount of ASCII greatness on screen.

Some brightly colored blocks with nice, intuitive icons and transition symbols would certainly help with that. Just have a look at Blueprint in Unreal, or some Visual Scripting Thirdparty assets for Unity.

Then you of course, as swiftcoder mentioned, need to decide just how deep the system should be. Should it be a simple rock scissor paper system? Should it be the visual scripting equivalent of Java, with the player being expected to understand what a loop or recursion is?

Personally, I like a mixed approach. Give players a deep system that needs REAL involvement, and maybe some basic programming skills to master... you know, the stuff players can debate for years on forums and never get tired of... real food for nerds.

On the other hand, add the options of macros, give the players some preconfigured macros. These are multiple "lines of codes" (or visual scripting blocks) combined into one simple block. Players can use a few of these to write a simple AI script quickly.... or they can dive in and write their own routines from scratch, and maybe save them into their own custom macros.

Hell, you could give players the option to export macros and share / trade them on the games forum. If the balancing is well done, that would only lead to even more nerd-food and thus forum activity / talking about your game / promotion for free as there is no perfect AI build, and players would try for years to come up with the ultimate AI script... some might actually code real neuronal networks in your game. Maybe your game would become the real world Skynet thanks to the player community? :D

Anyway, the big problem might be balancing the AI and the game design so that a) there is no perfect AI build, b) a person that doesn't invest hours just to come up with the perfect AI will be able to succeed in your game (might be partially solved with my Macro idea I put forward), c) a very strong AI build cannot totally crush the normal computer AI, if your game has that.

For the last problem: maybe make your computer AI able to learn by analyzing the players AI, incorporating part of it into the computer AI or finding suitable counters?

Graal Online Era lets players use HTML tags for formatting text in various objects. One use is customizing your guild page with different fonts, colors, text styles (bold, italic), and images. Yes, it was small, but it was interesting. That's actually how I learned my first bit of HTML off-handedly. For people who like modding, this might be the game for them (they can code in-game, after all). Sorry for not giving a whole lot input here. I don't really know of many games that include that form of gameplay.

Advertisement

I think it's an interesting idea that could be used to introduce kids to programming. Final Fantasy XII allows you to program a lot of the behaviour of your allies through something called Gambits so it's not something that is entirely unheard of in the gaming world.

I think something like behaviour trees in-game could be fun. One essential for me is not allowing the player to break the game, e.g. write scripts that infinite loop etc. Definitely not Turing complete. If your game was based on robots you could actually capture enemy units and harvest new decision/action modules from them to expand your scripts.

I think the FFXII Gambits is a good way to conceptualize AI in a way that non-programmers can get it. A script is a list of IF X THEN DO Y conditions, ranked by priority; always execute the highest true condition. That gets you a lot of what you need without letting the player write ill-formed code, write infinite loops, etc.
One consideration is whether this is basically a single-player or multiplayer experience. If it's basically single-player, then the game itself can be about the fun of experimenting and discovering new ways to do it. If it's basically multiplayer, and the primary goal is to defeat an opponent with the same scripting capabilities, I think you may get a situation where the majority of players are just entering scripts by the community's best AI designers. That's kind of neat in an abstract sense, but I wouldn't find that in-and-of-itself fun.

I've been mulling over protoyping a sci-fi coding/racing game for a while now. You "control" a simple space-ship in a 2D-top-down view, and can only rotate and thrust, like Asteroids for instance. The game is to navigate the ship through a maze as fast as possible. The twist is that you don't have direct control of the ship. Instead, you have to write (or build visually with some UI) a script of inputs which is then applied to the ship. The goal of each level is to optimise your scripted inputs to achieve the best time.

If you remember the drawing script language LOGO, I imagine it'd be a bit like a dynamic version of that: Turn left 30 degrees, thrust for 2 seconds, sleep for 1 second, turn right 60 degrees... etc. Maybe as you unlock more levels you'd also upgrade the language constructs available, to include conditionals, loops etc which could query the state of the ship's local environment. That would then enable things like "WHILE (door.closed) { SLEEP 0.5; } THRUST 1;" to enable you to navigate dynamic sections of the level.

I dunno, maybe it'd work as a game, maybe not, like I say I'd need to prototype it. I think it'd teach the basic logical constructs of programming, but whether it'd actually be engaging for the player is questionable.

Visit http://www.mugsgames.com

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

Mugs Games on Twitter: [twitter]MugsGames[/twitter] and Facebook: www.facebook.com/mugsgames

Me on Twitter [twitter]BarrySkellern[/twitter]

This topic is closed to new replies.

Advertisement