This is one of our project for Artificial Intelligence subject at the Jaume I University, in december 2018.
Z Nation is a turn-based strategy video game, in which the player will face a second player managed by an AI. The goal of the game is to destroy your enemy's city. To do this, both must collect the different hidden resources scattered around the map in order to improve their cities and get units to attack and collect.
The game should contain:
This project was made with a group of 3 students from Jaume I University.
The visual design of the game is based on the use of 3D low poly models, among which we can find the figures of resources, the city and the unity, as well as the scenery. Within the game, two types of units coexist: the explorer and the collector/attacker.
As for the conceptual design, the player must send many units as possible to attack the enemy city in order to defeat the opponent and win the game. To do this, you will have to explore the map in search of resources, amoung which we find two different types: food and materials. Material resources allow the construction of element called barracks, located within the city and capable of sheltering units. Food resources make it possible to capture and maintain (per turn) units, which will be limited in number by the number of existing barracks at a ratio 3/1, that is, 3 units per built barracks.
The limitations that the player has as are linked to the "fog of war", that is, the player does not know the map, does not know the position of the resources, so he must explore it, thanks to the help of the explorer unit character, in order to discover as mucha area as possible and thus be able to establish a winning tactic.
Finally, it is worth mentioning that victory will be granted to the player who has successfully assaulted the enemy city, and this will be when the number of attacking units that arrive in the city is greater than the number of units that remain inside it.
The representation of the terrain in our game has been through a grid (or matrix) of square nodes. We have chosen this implementation since the hexagonal way seemed more complicated to us when traversing the matrix and since we needed several loops to do it, we preferred the "natural" way.
Each node stores all the necessary information of the terrain:
The grid is made up of nodes. The grid script has several functions that will help us iterate through it:
The influence map in our game iterates through the nodes until it reaches a certain level to create the influence. In our game we have two types of objects that generates an influence: food and resources.
The influence expands as follows:
The enemies have got “walkies” to send warnings between them, we have represented this with a range in which the enemies detect the playero chen another enemy has detected him, they try to go through different paths to overthrow the player.
As said before, each node has two booleans indicating if that node was visited or not by the user, by the enemy or both. We use these booleans in order to create the FOW. The units can only move to the nodes they visited before. When making decisions, only the nodes that have been visited will be taken into account. The implementation is very easy, we go through all the neighbors of each node and we update the list of visible elements.
The purpose that drives city AI in search of resources is the constant imposed need to create barracks, which in turn allow the creation of units.The decision tree implemented in the AI is more detailed bellow.
The city will send different groups to do different actions. But there may be situations along the way that they will have to deal with. We have decided that the AI will be agrassive, which means it won't considerer if the enemy group is bigger than it, it will attack it, so when they finished they will return to the decision that the city had sent them. If there are no enemies nearby, it will check to see if there are any nearby resources within its view range. If there is, it picks it up, if not, it will communicate with the explorer and ask if there is any resource nearby that it has seen, if so, it will go for that resource, otherwise the decision of the city will continue.