You are on page 1of 17

Informatics College Pokhara

Artificial Intelligence
CU6051NP

Coursework 1

Submitted By: Submitted To:


Student Name: Prawesh Acharya Mr. Avhinav Lamsal
Student ID: 17031984

Date: 31-Jan-2019
Table of Contents
1. Introduction .................................................................................................................................... 4
2. Description..................................................................................................................................... 5
3. Research work............................................................................................................................... 6
4. Algorithm Used .............................................................................................................................. 7
5. Mind Maps ..................................................................................................................................... 9
6. State Transition Diagram ............................................................................................................. 12
7. Pseudo code................................................................................................................................ 14
7.1 Attacker AI ............................................................................................................................ 14
7.2 Finder AI ............................................................................................................................... 14
7.3 Game .................................................................................................................................... 15
8. Conclusion ................................................................................................................................... 16
9. References .................................................................................................................................. 17
Table of figures
Figure 1 A* algorithm ......................................................................................................................... 8
Figure 2 Mind Map 1 ........................................................................................................................... 9
Figure 3 Mind Map 2 ........................................................................................................................... 9
Figure 4 Mind Map 3 ......................................................................................................................... 10
Figure 5 Mind Map 4 ......................................................................................................................... 10
Figure 6 Mind Map 5 ......................................................................................................................... 11
Figure 7 Sate transition diagram of AttackerAI ............................................................................. 12
Figure 8 State transition diagram of FinderAI ............................................................................... 12
Figure 9 State transition diagram ................................................................................................... 13
1. Introduction
AI (Artificial Intelligence) is taking hype in future. There are many concepts algorithm
used for AI robots and problem solving techniques are now moving towards AI based development.

The coursework of AI was given which makes student very curious one of them is me. I was stunned
by the capabilities of AI, machine learning based on patterns which can certainly forecast future
results in seconds. But it was too difficult to get into complex programs in AI. So, starting with a
simple "Tank destroy game" I got into AI.

This AI game is a simple looking game containing scriptable object which performs certain functions
like calculating path to the destination tank using algorithm called A*. This algorithm is a smart and
different algorithm which is used to find the path of the destination object in a grid. This algorithm is
used by the tank which is an object to find the other tanks. This game contains three object that is
Attacker AI Finder AI and User. The Attacker AI finds the other components which comes into its
border and follows it and attacks it until it is destroyed. Finder AI is the component that only attacks
the user tank and attacker tank found in its border and does not follows it.

This game is developed on Unity Engine which is easy to use and provide sufficient GUI for the
environment where the game is runs. It also provide object GUI like human vehicles and can be used
according to the development. We can also develop #d game using unity engine.
2. Description

This AI game is called "Tank destroyer" it contains two AI components and a user component.
The two AI components are called AttackerAI and FinderAI. This components spawns in any
location at the starting of the game .The AttackerAi object moves in its own definite path until it
comes in contact with other two components. After it comes in contact with any other component
the definite path changes to the path of components and it starts following other components
and attacks and destroy it follows the component until it is destroyed or the AttackerAI is
destroyed. The component is called FinderAI which moves in its definite path also if it comes in
contact with other components. But if the component comes in contact it attacks the components
until it resides within the range.

The user component is controlled by the player (human). This components does not have any
AI functionality and the user runs it. This is a 2d game developed in Unity engine. The game
ends when any two of the components is destroyed and the remaining one is winner.

It uses A* algorithm to find the path of the opponent which is described below.
3. Research work
For this course work I have searched a lot of web sites and article but there were many projects
built using python and using other overlays in the development platform. But after starting to search
into YouTube I found new engine for the development called Unity Engine. Which I thought most
suitable for developing game. So, I got into game development using AI in Unity and Finally I also found
the simple game developed using AI which is called tank War. After researching a bit I found the unity
engine interesting for development and started using it. After just a Week or less the game was
developed as Unity engine provides all the GUI components necessary for the project. It was a simple
game with AI components and user playing it. So all the researches done provided me with the suitable
development platform and game.
4. Algorithm Used
The algorithm used is called A* algorithm. This is algorithm which is used to find the
path of the object based on certain properties. This algorithm differs from other algorithms as it has
'brains'. This algorithm finds the next node form a factor f which depends on the two other factors i.e.
accumulated path cost and heuristic.

f=accumulated path cost+ heuristic

Heuristic= h = abs (current_cell.x – goal.x) +

abs (current_cell.y – goal.y)

4.1 Algorithm

WHILE(QUEUE not empty && first pathnot reach goal) DO

•Remove first path from QUEUECreate paths to all children

•Create paths to all children•Reject paths with loops

•Add paths and sort QUEUE(by f = cost + heuristic)

•IFQUEUEcontains paths: P, Q

ANDP ends in node Ni&& Q contains node Ni

ANDcost_P ≥ cost_Q

THENremove P–

IFgoal reached THENsuccess ELSEfailure


Figure 1 A* algorithm

This algorithm can be used in different programming language to calculate the path of the destination
object in the square grid.
5. Mind Maps

Figure 2 Mind Map 1

Figure 3 Mind Map 2


Figure 4 Mind Map 3

Figure 5 Mind Map 4


Figure 6 Mind Map 5
6. State Transition Diagram

Figure 7 Sate transition diagram of AttackerAI

Figure 8 State transition diagram of FinderAI


Figure 9 State transition diagram
7. Pseudo code

7.1 Attacker AI
START
SPAWN
PATROL
IF Gizmos.RayCastHit= True
FOR (Player=Alive)
Gizmos.Raycolour= Red
ChaseTarget
ShootTarget
ENDIF

7.2 Finder AI
START
SPAWN
PATROL
IF Gizmos.RayCastHit= True
FOR (Player=Alive&&Gizmos.RaycastHit=true)
Gizmos.Raycolour= Red
ChaseTarget
ShootTarget
SCAN
ENDIF
7.3 Game
START
SPAWN_PLAYERS
BattleBegin
IF PlayersAlive=1

END GAME

ENDIF
8. Conclusion
This is a project of artificial intelligence. This project is built in unity. It simply shows the
use of A.I according to the objects built. The project works fine as they learn to find
another object for destruction. The objects are developed according to the ability for them.

This AI project provides the player with an AI which can follow the user and attack the
user and another component scans for the opponent that is a user which does not follow
the user but attacks if found in its zone. It provides user with an opponent that makes the
game more interesting and competing to play.

The system is built on unity engine with is easy to use and provide the surrounding for
the system the component GUI.
9. References
Anon., 2009. Applying Reinforcement Learning for Game AI in a Tank-Battle Game. [Online]
Available at: https://www.semanticscholar.org/paper/Applying-Reinforcement-Learning-for-Game-AI-
in-a-Fang-Ting/3dd1ba300138100ddbf6ab6c3232d2d9de3ebae6
[Accessed 30 january 2019].

Anon., n.d. Intro and Session Goals. [Online]


Available at: https://unity3d.com/learn/tutorials/topics/navigation/intro-and-session-goals

Dennis Barrios-Aranibar, L. M. G. G., 2007. LEARNING FROM DELAYED REWARDS USING


INFLUENCE VALUES APPLIED TO COORDINATION IN MULTI-AGENT SYSTEMS.

Epstein, S., 2009. Games & Puzzles. [Online]


Available at: http://www.aaai.org/AITopics/pmwiki/pmwiki.php/AITopi cs/Games
[Accessed 28 january 2019].

Michelle McPartland, M. G., 2008. Creating a multi-purpose first person shooter bot with
reinforcement learning, s.l.: s.n.

Russell, S. J., 2001. Artificial intelligence : a modern approach. s.l.:s.n.

You might also like