AI Are The Worst

I hate them. I really, really do.

Seriously, I spent something like three hours today fixing something that I thought I had fixed yesterday but which turned out to have been broken all along in a way that made me think it was working. In any case, I have made it so that AI will now check to see if a worksite is fully occupied before determining whether they should go to it.

If a building is not fully occupied the building will be evaluated based on its distance to the AI and if it’s the closest one the AI will select it as the target and increase its current worker could. Meanwhile, a building that is fully occupied will be skipped over in favour of another workplace altogether. I don’t yet have a behaviour for what the worshippers should do if all workplaces are occupied (right now they’ll go to the first workplace on the array generated when they ask for the closet workplace), but I’ll handle that sometime tomorrow or Friday.

I’ll also need to add a similar behaviour for when the AI are looking for houses, and I’ll need to set up the AI to lower the current occupancy count of their workplace when they stop work. They don’t do that yet as I was tired of writing AI code and decided that 50% was a good place to stop (although realistically it’s about 25% done at best).

One thing that I’m quite happy with, however, is the day/night system that I’ve implemented. I still have to write the code for player interaction with the sun and moon (and it’ll likely be a pain to get right as I’m using a pre-made script from the Unity wiki that I’ve modified slightly), but I can’t wait to give players the ability to alter the time of day :D. I also can’t wait to get my hands on a 3d model of a moon. I’ll need to do a whole bunch of little graphical things to make it look moonlike, but the day/night system should be pretty cool by the end of it.

Here’s a video of the system in action (the blue and green guys are miners and farmers, respectively).



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s