# Make a Pseudocode From a Simple Tic Tac Toe Game

Yesterday, I got project from my client. This project reminds me of subjects when I was in college. Yes Right, Algorithms and Programming Courses. This is a project that is quite challenging for me. Because I haven’t talked about this in a long time.

I was asked to create a pseudocode and flowchart from a simple program created by my client. In this post, I will try to write about pseudocode. Because I know, this will be very exciting and also long. For those of you who don’t know what Pseudocode is. You can see the explanation in this link.

Okay, here I will try to share the results of my work. Oh no, the result of my memory after almost 3 years of forgetting about this.

``` Title Pseudocode
Pseudocode Game Tic Tac Sederhana

Declaration
MATRIX_SIZE: int
matrix: array
win: char
splash, init, draw, run, check, finish: void

Implements
Start
Function main
Call splash
Call init
Call run
Call finish
return (0)
End Function

Function splash
Print 'Game Tic Tac Sederhana'
Print 'Untuk 2 Pemain'
Print 'Refky Satria'
End Function

Function init
i, j:int
win <- ' '

For i = 1 To MATRIX_SIZE Do
For j = 1 To MATRIX_SIZE Do
matrix[i][j] <- ' '
End For
End For

End Function

Function draw
i, j: int

Print '0 1 2'
Print '218, 196, 196, 196'
Print '197, 196, 196, 196'
Print '197, 196, 196, 196, 191'

j <- 0
For i = 1 To 5 Do
If (i % 2 == 0) Then
Print j, 179, matrix[j]
Print 179, matrix[j]
Print 179, matrix[j], 179
Else
Print '197, 196, 196, 196'
Print '197, 196, 196, 196'
Print '197, 196, 196, 196, 180'
End If
End For

Print '192, 196, 196, 196'
Print '193, 196, 196, 196'
Print '193, 196, 196, 196, 217'

End Function

Function run
p: char
i, x, y, m: int

p <- 'X'
i <- 0
m <- 0

do
Call draw

If (m == 1) Then
Print '! Input tidak valid, ulangi'
Else
Print '\n\n'
End If

Print '> Posisi p'

If (x > 2 || x < 0) || (y > 2 || y < 0) Then
m <- 1
Else
If (matrix[x][y] == ' ') Then

matrix[x][y] <- p

If (p == 'X') Then
p <- 'O'
Else
If (p == 'O') Then
p <- 'X'
End If
End If

If (m == 1) Then
m <- 0
End If

win <- Call check
i++
Else
m <- 1
End If
End If

while((i < 9) && (win == ' '))

End Function
Function check
i: int

For i = 1 To 3 Do
If (matrix[i] == matrix[i]) && (matrix[i] == matrix[i]) Then
return (matrix[i])
End If
End For

For i = 1 To 3 Do
If (matrix[i] == matrix[i]) && (matrix[i] == matrix[i]) Then
return (matrix[i])
End If
End For

If (matrix == matrix) && (matrix == matrix) Then
return (matrix)
End If

If (matrix == matrix) && (matrix == matrix) Then
return (matrix)
End If

End Function

Function finish
Call draw

If (win == ' ') Then
Print 'Seri'
Else
Print 'Menang'
End if

End Function

End ```

I also took some references from various sites, like this. For Pseudocode itself, there is indeed no standard form in the scientific world. I also have not found a reference to the standard form. Of course, the Pseudocode that I wrote is not necessarily true. There might be many improvements in it. Therefore I am very grateful, if you want to give a rebuttal or other opinions regarding the writing of the Pseudocode that I made. So we can both learn better. Regards.