Addis Ababa Institute of Technology Center of Information Technology and Scientific Computing Department of SW Eng

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

Addis Ababa Institute of Technology

Center of Information Technology and Scientific


Computing
Department of SW Eng.

AI BOT FOR A 2D GAME


Software Design Specification
Team Members
Amanuel Genene
Fasil Haymanot
Gerizan Tibebe
Henok Edmealem
Kidus Paulos
Sibhat Teshome
Advisor: Mr. Fitsum Alemu

May 2018
Table of Contents
List of Tables................................................................................................................................................ii
List of figures..............................................................................................................................................iii
Definitions, Acronyms, Abbreviations.........................................................................................................iv
1. Introduction.........................................................................................................................................1
1.1 Purpose..............................................................................................................................................1
1.2 General Overview........................................................................................................................1
1.3 Development Methods & Contingencies...........................................................................................1
2. System Architecture............................................................................................................................2
2.1 Subsystem decomposition..................................................................................................................2
2.2 Hardware/software mapping..............................................................................................................4
3. Object Model..........................................................................................................................................5
3.1 Class Diagram....................................................................................................................................5
3.2 Sequence Diagram.............................................................................................................................6
3.2 State chart Diagram.........................................................................................................................12
4. Detailed Design......................................................................................................................................12
References.................................................................................................................................................20

i|Page
List of Tables
Table 1: General description of Game class...............................................................................................13
Table 2: Attribute description of Game class.............................................................................................13
Table 3: Operation description of Game class...........................................................................................14
Table 4: General description of Player class..............................................................................................14
Table 5: Attribute description of Player class............................................................................................15
Table 6: Operational description of Player class........................................................................................15
Table 7: General description of Settings class............................................................................................16
Table 8: Attribute description of Settings class..........................................................................................16
Table 9: Operational description of Settings class.....................................................................................16
Table 10: General description of Mob class...............................................................................................17
Table 11: Attribute description of Mob class.............................................................................................17
Table 12: Operational description of Mob class........................................................................................17
Table 13: General description of SpriteSheet class....................................................................................18
Table 14: Attribute description of SpriteSheet class..................................................................................18
Table 15: Operational description of SpriteSheet class.............................................................................18
Table 16: General description of Platform class........................................................................................18
Table 17: Attribute description of Platform class.......................................................................................18
Table 18: General description of AI class...................................................................................................19
Table 19: Operational description of AI class.............................................................................................19

ii | P a g e
List of figures
Figure 1: layer 1 component diagram..........................................................................................................2
Figure 2: layer 2 component diagram..........................................................................................................2
Figure 3: layer 3 component diagram..........................................................................................................3
Figure 4: deployment diagram....................................................................................................................4
Figure 5: class diagram................................................................................................................................5
Figure 6: play game sequence diagram.......................................................................................................6
Figure 7: settings sequence diagram...........................................................................................................6
Figure 8: pause game sequence diagram....................................................................................................7
Figure 9: change audio sequence diagram..................................................................................................8
Figure 10: change difficulty sequence diagram...........................................................................................9
Figure 11: change keybindings sequence diagram....................................................................................10
Figure 12: exit game sequence diagram....................................................................................................11
Figure 13: state diagram............................................................................................................................12

iii | P a g e
Definitions, Acronyms, Abbreviations
Layered Pattern: a pattern that can be used to structure programs that can be decomposed into
groups of subtasks, each of which is at a particular level of abstraction. Each layer provides
services to the next higher layer.
GUI: graphical user interface

iv | P a g e
1. Introduction
1.1 Purpose
The purpose of System Design document is to translate the business requirements and business
processes into a technical design that will be used to develop the application.

1.2 General Overview


The system shall follow a layered architecture to implement its functionalities. The system
will follow the three-tier architectural style and be organized into three layers: the interface layer,
application layer and the storage layer. The interface layer will be the graphical user interface
that allows the users to interact with the system. It will contain all the menus and settings. The
application layer will contain the system logic and rules for storing data and also retrieving it in
accordance with the user’s needs. This is the layer that will allow controlled access to the data
files. Finally, the storage layer will store the metadata required for the system.

The three-tier architecture style shall be used because it not only separates the user interface
and the metadata, but also provides an application logic layer. The application layer provides a
middle layer that allows the data files and the GUI components to be loosely coupled. The
application layer has to be modified if there are any changes to the format of the data files and
the interface layer will need little or no modification. This will make it easy for clients of this
software to modify the data file format and attributes for further research purposes if they wish to
do so. This layer makes the system more maintainable and reusable and also hides the
complexity of processing data from the users.

1.3 Development Methods & Contingencies


The development of this system used a combination of prototyping and structured software
designs. Structured design is handy, especially when used in junction with layered architecture.
The developers of this system can group similar components together into a structured form
while following the three layers as a guideline. In this particular case prototyping has been a big
part of the design as users of the system are not able to specify their functional requirements at
the initial draft. Rather, they add requirements as they use or visualize some parts of the system
to be developed.

1|Page
2. System Architecture
2.1 Subsystem decomposition

Figure 1: layer 1 component diagram

Figure 2: layer 2 component diagram

2|Page
Figure 3: layer 3 component diagram

3|Page
2.2 Hardware/software mapping

Figure 4: deployment diagram

4|Page
3. Object Model
3.1 Class Diagram

Figure 5: class diagram

5|Page
3.2 Sequence Diagram

Figure 6: play game sequence diagram

Figure 7: settings sequence diagram

6|Page
Figure 8: pause game sequence diagram

7|Page
Figure 9: change audio sequence diagram

8|Page
Figure 10: change difficulty sequence diagram

9|Page
Figure 11: change keybindings sequence diagram

10 | P a g e
Figure 12: exit game sequence diagram

11 | P a g e
3.2 State chart Diagram

Figure 13: state diagram

4. Detailed Design
Game
- clock:pygame.time.Clock
- running:boolean
- loadData()
- new()
- run()
- update()
+ events()
+ draw()
+ showStartScreen()
+ showPauseScreen()

12 | P a g e
+ showSettingsScreen()
+ showAudioScreen()
+ showDifficultyScreen()
+ showKeybindingsScreen()
+ showGoSCreen()
+ drawText(text, size, color, x, y)
+ button(text,x,y,width,height,color)
Table 1: General description of Game class

Attribute Type Visibility Invariant


clock pygame.time.Clock Private Clock should be a number with many digits to
represent the system time.
running Boolean Private Running should be a Boolean with the initial value of
True.
Table 2: Attribute description of Game class

Operation Visibility Return Argument Pre-Condition Post Condition


type
loadData Private void . A data should be A data should be
requested loaded

new Private void . The system should The system


be on waiting or should begin the
pause state main game
run Private void - The new() method The system
should be invoked should be in a
playing loop

update Private void The run() method The system


should be invoked should update
graphics
continuously
events Public void The system should The system
be running should execute
the requested user
event
draw Public void The system should The system
be running should draw the
specified graphics
showStartScreen Public void Either the system The system
should be at a first should display the
startup or the game start screen
playing loop should
13 | P a g e
be aborted
showPauseScreen Public void The system should The system
be in a game should display the
playing loop pause screen
showSettingsScreen Public void The system should The system
be on waiting loop should display the
settings screen
showAudioScreen public void The system should The system
be in settings screen should display the
audio screen
ShowDifficultyScreen Public void The system should The system
be in settings screen should display the
difficulty screen
showKeybindingsScreen Public void The system should The system
be in settings screen should display the
keybindings
screen
showGoScreen Public void The system should The system
be in the game should display the
playing loop game over screen
drawText Public void text, size, A text draw should The system
color, x, y be requested should draw a text
on the screen
button Public void text, x, y, A button should be The system
width, requested should draw a
height, button on the
color screen
Table 3: Operation description of Game class

Player
+ vx:int
+ vy:int
- img:image
- walking:boolean
- jumping:boolean
- current_frame:int
- last_frame:int
+ update()
+ jump()
+ animate()

Table 4: General description of Player class

14 | P a g e
Attribute Type Visibility Invariant
vx Integer Public vx <> NULL

vy Integer Public vy <> NULL

img Image Private Img should have an some image for initial value

walking Boolean Private walking should be a Boolean with the initial value of False.

jumping Boolean Private jumping should be a Boolean with the initial value of False.

current_frame Integer Private current_frame should be integer with the initial value of 0

last_frame Integer Private last_frame should be integer with the initial value of 0

Table 5: Attribute description of Player class

Operation Visibility Return Argument Pre-Condition Post Condition


type
update Public void . The run() method The player
should be invoked character should
update
accordingly
jump Public void . The system should The player
be in a game playing character should
loop jump
animate Public void - The player update() The player
method should be character
invoked movement should
be animated
Table 6: Operational description of Player class

Settings
+ width:int
+ height:int
+ fps:int
+ title:String
+ highscore_file:String
+ settings_file: String
+ SPRITESHEET:String
+ difficulty_file:String

15 | P a g e
+ AI_data:String
+ changeSettings()

Table 7: General description of Settings class

Attribute Type Visibility Invariant


width String Public width should be an integer with a specific value

height Integer Public height should be an integer with a specific value

fps String Public fps should be an integer with a specific value

title String Public title should be a string with some value

highscore_file String Public highscore_file should be a string with some value

settings_file String Public settings_file should be a string with some value

SPRITESHEET String Public SPRITESHEET should be a string with some value

difficulty_file String Public difficulty_file should be a string with some value

AI_data String Public AI_data should be a string with some value

Table 8: Attribute description of Settings class

Operation Visibility Return Argument Pre-Condition Post Condition


type
chageSettings Public void . The system should The system
be at settings screen should change the
requested setting
Table 9: Operational description of Settings class

Mob
- img:image
- game:Game
- vy:Double
- dy:Double
- walking:boolean
- jumping:boolean

16 | P a g e
- current_frame:int
- last_frame:int
+ update()
+ read()

Table 10: General description of Mob class

Attribute Type Visibility Invariant


img Image Private img should have an some image for initial value

game Game Private game should be an object of the class Game

vy Double Private vy <> NULL

dy Double Private dy <> NULL

walking Boolean Private walking should be a Boolean with the initial value of False.

jumping Boolean Private jumping should be a Boolean with the initial value of False.

current_frame Integer Private current_frame should be integer with the initial value of 0

last_frame Integer Private last_frame should be integer with the initial value of 0

Table 11: Attribute description of Mob class

Operation Visibility Return Argument Pre-Condition Post Condition


type
update Public void . The run() method The enemy
should be invoked character should
update
accordingly
read Public void . The system should The enemy bot AI
be in a game session should read from
with a player user collected data
to be challenging
Table 12: Operational description of Mob class

SpriteSheet
+ spritesheet:image

17 | P a g e
+ getImage(x, y, width, height):image

Table 13: General description of SpriteSheet class

Attribute Type Visibility Invariant


spritesheet Image Public spritesheet should have an some image for initial value

Table 14: Attribute description of SpriteSheet class

Operation Visibility Return Argument Pre-Condition Post Condition


type
getImage Public Image x, y, width, The system should The method
height request for a sprite should provide the
sheet system with a
sprite sheet
Table 15: Operational description of SpriteSheet class

Platform
- img:image
- rect:image.get_rect
- game:Game

Table 16: General description of Platform class

Attribute Type Visibility Invariant


img Image Private img should have an some image for initial value

rect Image.get_rect Private rect <>NULL

game Game Private game should be an object of the class Game

Table 17: Attribute description of Platform class

18 | P a g e
AI

+ learn()
- write()
- update()
Table 18: General description of AI class

Operation Visibility Return Argument Pre-Condition Post Condition


type
learn Public void . The system should The system
be in session with a should learn
player player moves
write Private void . The system should The system
invoke the learn() should write
method information for
later use
update Private void - The system should The system AI
be in session should update
some information

Table 19: Operational description of AI class

19 | P a g e
References
Smartdraw; https://www.smartdraw.com/component-diagram/#whatisComponentDiagram, On
May 17 2018

Smartdraw; https://www.smartdraw.com/uml-diagram/how-to-make-uml-diagrams.htm, On May


18 2018

20 | P a g e

You might also like