Introduction to Computing and Games Designing
by Sarfraz Raza and Amanullah
Team Members:
Nimra Dilawar
Momina Mohsin
Sara Nadeem
Faizan Anjum
Team Members:
Nimra Dilawar
Momina Mohsin
Sara Nadeem
Faizan Anjum
What is Computer?
What is Computation?
What is Algorithm?
Guessing Game
Introduction to Logarithm
Finding Heaviest ball problem
Sarim-Jamila Proposal story (the introduction to Cryptography)
Parallelism (Counting problem)
Introduction to Exponential functions.
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 1 - Computational Thinking
Week 1: DAY 1 - Home Task (Logical and Computational Thinking)
Measuring Water Using Cans.
Counting Handshakes in class.
Gauss's proof of Arithmetic Series
Log_3 N: Generalization of searching the Heaviest Ball.
Calendar formation of a month using Two cubes
Logical reasoning (Given 5 white beans And 10 Black Beans And a drawing criteria which will be the last ball in the pot.
Prune and search technique
Geometric Series.
Finding the trustworthy person out of trustworthies and untrustworthies
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 1 - Computational Thinking
Week 1: DAY 1 - Home Task (Logical and Computational Thinking)
Why we need C++
"Hello World" program...!
Using cout
String Messages printing/Maths expression printing
Printing a Table with all fixed values
Introduction to variable
Why generic coding is important
Introduction to Iteration
While loop and generalized Table Printing
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 3 - Introduction to C++ (Table Printing) Notes
Week 1 - Day 2 - Homework (C++ Begins)
Data Type Integers and operators (+, -, / , * , %)
Digits summation problem
If Statement
Block statements
If else Statement
if else if .... else
Checking divisibility (Using Modulus % operator)
Compound Statement ( AND: && and OR: ||)
Finding Maximum out of the 5 numbers
Using 5 ifs and 4 conditions in each
Using 5 ifs then else if .... and with one condition removed
Using the efficient way of finding max (by maintaining max)
The Problem of repeating the same structure again and again (The Need of function)
Character Data-Type
ASCII values
Capital or Small letter
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 4 - Selection Statements
Week 1 - Day 3 - Homework (Control Structure I)
Digit by Digit display
Implementation using if then else statement
Implementation using switch statement
Introducing Functions as black box
Implementing DigitsDisplay as functions and avoiding multiple switch conditions
Quardrilatral Type
Using distance function
and PrintQuardType
Making Menu based
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 5 - Divide, Conquer and Rule (Designing Functions, Menu Based Application Development, Age Calculator)
Week 1 - Day 4 - Homework (Control Structure II)
Making Rock paper scissor Game
Introducing getch function
Winning Condition
Displaying Game message
Validating Input from the user
Introducing replay of the game
Simplifying input using TOUPPER function
Making STOPWATCH
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 5 - Divide, Conquer and Rule (Designing Functions, Menu Based Application Development, Age Calculator)
Week 2 - Day 1 - Homework (Control Structure II)
Age Calculator
Given two dates validate them as Date of Birth and Data of Death or Current Data and calculate the age in years, months and days. In case of Invalid entry ask again/Just like menu based.
Making STOPWATCH
Displaying 4 clocks on four corners of the screen.
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 5 - Divide, Conquer and Rule (Designing Functions, Menu Based Application Development, Age Calculator)
Week 2 - Day 2 - Homework (Age Calculator and Stopwatch)
for loop vs while loop
Printing some series
1 2 3 4 5 6 7...
1 3 5 7 ....
1 1 3 6 5 11 7 16 9 21...
IsCompound function
IsPrime function
Triangle Number
Printing Triangle numbers sequence
Input stream ending with -1
Read an input stream and tell how many of the numbers were odds/evens???
Read an input stream and tell the Maximum and Minimum
Fibonacci numbers sequence
Designing Fib(N) function - which returns the N'th fibonacci number
Print the Fibonacci numbers sequence between a given range...
Scoping rules in blacks...
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 6 Reusability and Extensibility Iterations, Loops, Nested Loops and Functions
Week 2 - Day 3 - Homework (loops and functions)
Loops and Functions II
int IntegerSquareRoot(int N)
bool IsPerfectSquare(int N)
bool IsPrime(int N) // with loop till sqrt(N)
void PythagorianTripplets(int Range)
void FindTrippletsSatisfyingEqution(int T)
int Reverse(int N)
int IsPalindrome(int N)
ShapesPrinting
void PrintASymbolKTimes(int K, char Sym)
void PrintTriangleLeftRightAngled(int Height, char Sym)
void PrintTriangleLeftRightAngledUpsideDown(int Height, char Sym)
void PrintTriangleRight_RightAngled(int Height, char Sym)
void PrintTriangleEquilateral(int Height, char Sym)
void PrintingHollowTriangle(int Height, char Sym)
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Chapter 6 Reusability and Extensibility Iterations, Loops, Nested Loops and Functions
Week 2 - Day 4 - Homework (loops and functions II ) + Shapes Printing
Memory and References
Application
SWAP function
Divide function
Pointers and Memory
Application
Writing SWAP function
Discussion on SCANF of C function
Arrays and its deeper connection with pointers
Initialization
Taking list of integers from User
Its connection with [ ] and pointer based de-referencing.
Finding Minimum from an array.
Finding Maximum from an array.
Finding Min/Max from an array.
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: 08-Chapter 8: References, Randomization, Arrays and Filing
Week 3 - Day 1 - Homework (References, Pointers and Arrays)
Initializing an array during Declaration
with garbage values
with different values
with all 0's
with 1 54 0 0 0 .... and so on
Constant Variables ( const keyword )
Init() function - Array Initialization
Initializing in different ways
0 1 2 3 .......
0 1 4 9 ......
0 2 4 6 ...... and so on
Initializing random numbers using rand() function
seed in random function and time(0)
using srand(time(0)) function
Initializing with Prime Numbers
Initialization with input ending at -1
Difference in Capacity and Size of an array
SEARCHING in an array
Finding first index of a specific element
Finding last index of a specific element
Finding index of Kth existence of a specific element
Finding index of last Kth existence of a specific element
FREQUENCY based problems
Finding frequency of a specific element in an array
Finding frequency of all elements in an array
Compute all DISTINCT elements
Finding MODE of an array
Finding all UNIQUE elements in an array
SORTING
Bubble Sorting
using Nested Loop
using Bubbling() function in for() loop
using boolean ChangeHappened and Bubbling() function in while() loop
Range Minimum and Selection Sort
MERGING Arrays
Simple Merging the sorted arrays
Merging the sorted arrays in Sorted Order
SEGREGATION in Arrays
Segregate smaller values on the left and larger values on the right of a specific value in an array
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: 08-Chapter 8: References, Randomization, Arrays and Filing
Week 3 - Day 2 - Homework (Static Arrays)
Setting up Console Window in Debugging and Non-Debugging mode
Windows Dimension
Windows Size
Buffer Size
Printing on Console using gotoRowCol() function
Understanding system("cls") with ClearScreen() function
FAN animation
Vertical Fan printing
Horizontal Fan printing
Playing with Sleep() function
Scaling up and scaling down Fan
Speeding up and slowing down Fan
abs() function
Circle drawing using
Standard Equation
Polar Equation
Circular Spiral using Polar Equation
Introducing structs and its importance
Position Struct
Multiple Circles animation with Different Centers using an array of Circle's Structs
Stone Throwing animation using an array of Stone's Structs
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: 07-Chapter 7: ANIMATIONS
Week 4 - Day 1 - Homework (ANIMATIONS)
Difference between and Average and the good programmer
Two Dimensional arrays
Array mapping function (how two dimensional arrays are stored as single dimensional array)
how to access it
How to load it
how to print it.
#define global constants using preprocessor directives and how to take capacity as global variables.
Two Dimensional Arrays Application
Implementing Matrices
Making Matrices Calculator
Add function of Matrices
Subtract function of Matrices
Multiplication function of Matrices
Transpose Function for Matrices
Introducing Structs
Implementing Two Dimensional Arrays handled with struct of Matrix with the following definition
struct Matrix
{
char FN[100]; int R, C; int Vs[ROWS][COLS];
};
Application - THE Prison Break
Making its mainflow
FindPrisoner
FindTopLeftCorner of Room
FindBottomRightCorner of the Room
Figuring out the prisoner's destiny
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: 07-Chapter 7: ANIMATIONS
Week 4 - Day 2 - Homework (Two Dimensional Arrays)
Limitations of Arrays
Problems with Single Dimensional Array:
1. If Size is smaller then Capacity
2. If the input size is greater then Capacity???
Problems with Two Dimensional Array:
1. If Rows and Cols are smaller then Capacity
2. If the input size is greater then Capacity
Introduction to POINTERS
4 Memory Segments of the Program
1. Code Segment 2. Global Segment 3. Heap Segment and 4. Stack Segment
How memory is managed using Stack and Heap
Dynamic Memory Location
Application
Making an array on run time.
Making Growable array
We implemented the following functions
void Print(int* A, int Size)
void AllocateArray(int* &A, int Size)
void LoadArray(int* RTA, int Size)
void InsertAtEnd(int* & A, int& Size, int d)
void LoadArray(const char* fn, int* &A, int &Size)
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Notes on Pointers
Reading Material 2: Notes on Dynamic Memory Location
Reading Material 3; https://hank.feild.org/feild-guide-cpp/pointers.html
Reading 4: https://www.tutorialspoint.com/cplusplus/cpp_pointers.htm
Week 4 - Day 3 - Homework (Dynamic Memory Location
Making a Set struct with Dynamically allocation array setting
struct SET
{
string name; int Size, int * Vs;
};
void Print(SET S)
void LoadArray(int* RTA, int Size)
void ReadingSet(SET& S)
void InsertAtEnd(int*& A, int& Size, int d)
void LoadArrayFromFile(const char* fn, int*& A, int& Size)
void LoadSET_EndWith_1(const char* fn, SET& S)
bool Search(int* A, int Size, int T)
void UnionSet(SET& U, SET S1, SET S2)
void Sort(int* A, int Size)
Dynamically Allocated 2D Array
struct MATRIX
{
int Rows, Cols,
int**Vs;
};
void LoadMatrix(const char* fn, int** &TDA, int &Rows, int &Cols)
void LoadMatrixFromFile(const char* fn, DynamicMatrix& M)
void PrintMatrix(DynamicMatrix &M)
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Notes on Pointers
Reading Material 2: Notes on Dynamic Memory Location
Reading Material 3; https://hank.feild.org/feild-guide-cpp/pointers.html
Week 4 - Day 4 - Homework (Dynamic Memory Location II)
Conway Game of Life
Playing with initialization
mouse control and a paint game
int mainGOL()
{
char Sym = -37; int K = 0; char World[Rows][Cols];
Init(World, Sym);
do
{
RepopulateWorld(World, Sym);
DisplayWorld(World);
} while (true);
}
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Notes on Pointers
Reading Material 2: Notes on Dynamic Memory Location
Reading Material 3; https://hank.feild.org/feild-guide-cpp/pointers.html
Week 4 - Day 4 - Homework (Dynamic Memory Location II)
Multiplayer Tic-Tac-Toe
Tic-Tac-Toe Main Flow
Memory usage of the game
Step by Step division of the game's flow
Divide and Conquer approach
Internal Implementation of Unit Steps
Annotating the validity of player's move
Initialization
ifstream-based FILING
Displaying Board
WIN Check Utility Functions
DoIWinDiagonallyLeftToRight
DoIWinDiagonallyRightToLeft
DoIWinVertically
DoIWinHorizontally
Game DRAW Check
struct Pos
{ int ri, int ci ; }
int mainGomuko()
{
srand(time(0));
int Dim, NOP, WinCount, Turn, Winner = -1 ;
string* PName; char* PSym; char** Board ;
bool GameEnded = false;
Init (Dim, NOP, WinCount, Turn, PName, PSym, Board);
DisplayBoard (Board, Dim);
do {
do {
DisplayTurnMsg (PName[Turn]);
MakeAMove (Pos);
} while (!IsValidPos (Board,Dim,Pos));
UpdateBoard(Board, Pos, PSym[Turn]);
DisplayBoard(Board, Dim);
GameEnded = IsWin(Board, Dim, PSym[Turn], WinCount);
if (GameEnded == true)
Winner = Turn;
if (GameEnded == false)
GameEnded = IsDraw(Board, Dim);
if (GameEnded == false)
TurnChange(Turn, NOP);
} while (!GameEnded);
if (Winner == -1)
cout<<"The Game is Draw...!! " ;
else
cout<<P[Name]<<" has WON the Match...!! " ;
return _getch();
}
(Video Lecture: Youtube-Playlist): NOT Available
Reading Material: Notes on Pointers
Reading Material 2: Notes on Dynamic Memory Location
Reading Material 3; https://hank.feild.org/feild-guide-cpp/pointers.html
Week 4 - Day 4 - Homework (Dynamic Memory Location II)
(Video Lecture - recorded at UCP: Youtube-Playlist):
Lecture 16B: Playlist (starts from 29:00)
Reading Material: Notes on Pointers
Reading Material 2: Notes on Dynamic Memory Location
Reading Material 3; https://hank.feild.org/feild-guide-cpp/pointers.html
Week 4 - Day 4 - Homework (Dynamic Memory Location II)
_kbhit() and getch() function
Making Program with nonblocking console input
Making Snake Struct
Making flow of the snake game
(Video Lecture: Youtube-Playlist): NOT Available
Discussing MAINFLOW
Memory Requirement
Discovering the ways HOW TO STORE THE PIECES IN THE BACKGROUND
(as alphabets and showing the pieces in a different fashion)
Initializing the Board
Displaying the Board in the form of a grid (8x8 grid)
Taking input coordinates by the player
BASIC Validating
whether the selected piece is the piece of the player
where the player placed is a legal destination (regardless of checking the move of the piece)
i.e. either it is a space character or opponent piece.
Updating memory
Turn changing
(Video Lecture: Youtube-Playlist): NOT Available
Updating MAINFLOW with MOVEMENT LEGALITY
Designing Six Utility functions
IsHorizontalMove
IsVerticalMove
IsDiagonalMove
IsHorizontalPathClear
IsVerticalPathClear
IsDiagonalPathClear
Designing the pieces' legal Moves under the abstraction of the Six utility functions
IsRookLegalMove
IsBishopLegalMove
IsQueenLegalMove
IsKingLegalMove
IsHorseMove
IsPawnLegalMove (including its special Move)
Incorporating these legal steps into one LEGALITYCHECK function
It should supervise the possible move to be considered or not
(Video Lecture: Youtube-Playlist): NOT Available
Pawn promotion
Saving each and every move
Save and Exit
Undoing a move
Replay of the game
Replay and start from where I press enter
Restart of the Game without saving
Check
Castling
Checkmate
Stalemate
Illegal Moves:
An illegal move is any move which results in a check or
A move within check which isn’t able to remove check is also an illegal move
(Video Lecture - recorded at UCP: Youtube-Playlist): The Game of Chess Phase 2 - Playlist