Fish With AI

Fish is an assignment I worked on for a 4th year Computer Science course at York University called Artificial Intelligence. It involves emulating a predator (big red fish) chasing prey (small green fish).

The predator starts by swimming around looking for the nearest fish to chase. Once it finds a target it will move towards the target using the shortest route possible. The prey will attempt to run away from any predator it sees by following the shortest route to an area that isn't visible to the predator. The program takes into account walls which block the sightlines between fish. None of the fish can swim through walls (grey), and only smaller fish can swim through the hatch filled walls.

I had fun with this project because it was one of the few times in Computer Science we were allowed to be a little creative. Although the professor already gave us the algorithm to use for the predators chasing prey, he let me come up with my own platform for emulating the fish. I decided to use DirectX and some graphics libraries I had created earlier for my personal work to make this a more interesting project, so that I had animated fish instead of just using plain text. Programming was done in C++.

Languages Used: C++, DirectX

Screenshots

Green fish escaping from the red fish. Part of the AI for the prey involved determining which half of the screen had fewer predators and having the prey gravite to that half. If you let this program keep running, the red fish will eventually eat everyone.

Previous | Next

Green fish escaping from the red fish. Part of the AI for the prey involved determining which half of the screen had fewer predators and having the prey gravite to that half. If you let this program keep running, the red fish will eventually eat everyone.

Fish will get eaten more quickly in this map, as there are fewer walls to hide behind.

Previous | Next

Fish will get eaten more quickly in this map, as there are fewer walls to hide behind.

If you really want to terrify your fish, you can throw in more than one predator.

Previous | Next

If you really want to terrify your fish, you can throw in more than one predator.

Main menu of Fish, where you can choose a map and how many predators or prey to use.

Previous | Next

Main menu of Fish, where you can choose a map and how many predators or prey to use.

Fish With AIFish With AIFish With AIFish With AI