Day 1 - Improve the Brain Dead AI


Background

Ratfolk Mage vs Human Swarm was a game I made 2 months ago (so plenty long enough that the code is a complete mystery to me now) for the "Lame Jam 32" jam. Lame Jam is a 3 day Jam. On Day 1 I over-scoped hard... I decided I wanted to do all sorts of things I hadn't done before (A Turn based Tactics RPG...) on the evening of Day 2 I realised this was not going to be finished so I hatched a plan, a plan to Keep It Simple Stupid, and at the end I made a game I found "fun".

Artificial Stupidity

The AI from Ratfolk Mage vs Human Swarm was... well pretty dumb, it just tried to go in a straight line towards the player getting stuck on any walls in the way and was, pretty easy to cheese. Also for detecting if it could attack the player it was just done by "being close" which for the original game was "fine" I had no thin barriers for the player to hide and the distance was short because the only enemy was a melee fighter so it "worked" even if it was completely janky and deep down I knew I could do better, but This was me starting from scratch on Day 3 of a 3 Day Jam... "worked" was as good as I could give. So a good first night task after a day of work... right?


Old Code

Really Really dumb AI code


Example Movement
It really Likes that Hedge... probably too much

Enemies that know they can't walk through Hedges... Most of the time

So whats the solution? Well Godot (3.5 and 4... I'm on 3.5 still) has a "Navigation Agent (2D)" that can handle pathing pretty well so by passing that the Players Global Position, setting a timer to recalculate the pathing (currently on a 0.5 second timer) and drawing some navigable areas on the level the AI no longer gets stuck... most of the time (Silly me for drawing a complex map with plenty of tight areas in it... Curse you past me, oh well Future Me can consider tweaking the map further).

Slightly Smarter AI

Still pretty dump... not too sure why this gif is so stuttery though

Speaking of Future me they have plenty of other problems... now that the AI could beat a single rock (two rocks might be a challenge, and three in a trench-coat will smash it) in a contest of thinking... the game difficulty has increased... a lot facing wages of dozens or hundreds was not too daunting when a hedge was a challenge for them, now they go around them I might have to tweak wave generation (and maybe... make more enemies types)... Oh that is the next 2 tickets (Yes I made a kanban style board for this).

Leave a comment

Log in with itch.io to leave a comment.