Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
/ AIP-final Public archive

HexZomb - the hexagonal zombie survival game

Notifications You must be signed in to change notification settings

j-siderius/AIP-final

Repository files navigation

AIP-final 2022

Final project for the CreaTe MOD6 course AI Programming.


Description
Gameplay
Hardware
Code Overview
AI Pathfinding
Libraries
Attribution

Description

This Zombie survival game is based in a far away, hexagonally shaped world. The objective of the game is to survive long nights and days until help arrives to save you. The player is stranded on an island with lush fields, dense forests and big mountains. There are resources to be mined and fortifications to be built. But watch out, at night, the undead come out of the ground and try to eat you.

The game is completely written in Python, utilizing the PyGame library. The player can be controlled via the mouse or by using the external Nunchuck controller which integrates a LED clock, see below.

Gameplay

  1. To move your hero around the island, you either use your mouse or the joystick to select adjacent tiles, then press the left mouse button or the Z-key on the nunchuck to move.
  2. If you want to perform an action, select a tile and press the right mouse button or the C-key on the nunchuck. Depending on the tile, you will either gain resources, build a wall (that becomes very useful against the nightly invaders) or destroy a wall.
  3. During the night, creepy undead beings will spawn from the ground and try to devour you! Avoid their bites by running away or building barricades to exhaust them.
  4. The end...? If you manage to survive on this deserted island long enough, a search party will come to your rescue. For now though .. good luck!
Start gameplay Simple instructions Welcome to the island Watch out at night! Don't get bitten ..Or you won't survive Get rescued!

Hardware

For added fun, the game can be played with an external LED clock and Nintendo Wii Nunchuck. The LED clock displays the current time of the day as well as your remaining health. The Nunchuck provides an ergonomic and intuitive gaming interface to play HexZomb. In the images below, the LEDs are blown out, however the day cycle should contain blue skies and a yellow sun, while the night sky has a faint blue glow with a full white moon.

LED clock during daytime LED clock during nighttime Nunchuck controller

Code overview

Below you can find a class reference diagram which explains the relations between all classes.

AI Pathfinding

Since the main objective of this project was to incorporate the Algorithms and Artificial Intelligence learned in the AI Programming course. It was decided to integrate the A* pathfinding algorithm into the Enemy class, to make them intelligent in following the player.
The algorithm utilizes the distance to the player, the terrain type and possibly the time it takes to destroy obstacles (such as walls placed by the player) to calculate the most optimal route. Every type of tile has a specific walking speed, which contributes to the total movement cost of each step. The enemy re-calculates the optimal route at every game tick (movement or action). Below, the calculated scores of each explored cell can be seen, as well as the final chosen route.

Pathfinding normal terrain Pathfinding around walls Pathfinding through walls

Libraries

The terrain is generated by utilizing the Perlin Noise library. The communication with the arduino that drives the LED clock and controller is accompliced by using the PySerial library and a custom communication protocol. The Random library is used for randomisation of spawn and animations. Math helps with some of the tougher calculations by having loads of standard functions. The Time library is used for keeping track of game time, as well as calculations regarding the flow of animation frames and updating of the screen. Numpy is used for some heavier calculations and functions that the normal math library does not include. Lastly, the Bisect library is used for some array transformations and sorting.

Attribution

For this game, the following art and graphics were used:

About

HexZomb - the hexagonal zombie survival game

Resources

Stars

Watchers

Forks