Project
Project
Project
CBSE CLASS – 12
GAME CONSOLE
2022-2023
INTERNAL EXAMINOR
We Undertook this project work, as the part of our XII-Computer Science course. We
had tried to apply our best of knowledge and experience, gained during the study and
class work experience. However, developing software system is generally a quite
complex and time-consuming process. It requires a systematic study, insight vision and
professional approach during the design and development. Moreover, the developer
always feels the need, the help and good wishes of the people, who have considerable
experience and idea.
We would like to extend my sincere thanks and gratitude to our teacher Mr. Jegajeevan for
giving valuable time and moral support to develop this software.
We would like to take the opportunity to extend sincere thanks and gratitude to our parents
for being a source of inspiration and providing time and freedom to develop this software
project.
We also feel indebted to my friends for the valuable suggestions during the project work.
- Nikhil Y N
- Anunitha K U
- Himanshu
Content
1 Introduction 1
5 System implantation 9
5.1 The hardware used
5.2 The softwares used
7 Coding 11-37
8 Output 38-42
9 References 43
Introduction
The objective of this project is to make an offline game console
This software project is also aimed to make games with minimum requirements and lightweight
nature accessible offline. It uses MySQL to store score and show the best at the game and uses
gamer ID system to compare different gamers playing on the system.
To provide a user friendly, text-based Interface (GUI) based integrated and centralized
environment for gaming.
The proposed system should maintain all the records and should generate the required reports
and information when required.
To identify and switch games as per user’s choice
In its current scope, the software enables user to retrieve and update the information from centralized
database designed with MySQL. This software does not require much training time of the users due to
limited functionality and simplicity
Despite of the best effort of the developer, the following limitations and functional boundaries are
visible, which limits the scope of this application software.
1. This software’s chess game does not have trapped checkmate instead it provides 3 check
checkmate
2. There is graphical interface for ease of use
So far as future scope of the project is concerned, firstly it is open to any modular expansion i.e. other
modules or functions can be designed and embedded to handle the user need in future. Any part of
the software and reports can be modified independently without much effort.
This project mainly revolves around 4 modules that contains code of each game
Chess.py
Hangman.py
Ticktactoe.py
Main.py
1
Game console
Main.py
The main.py program is the main program that uses all the other modules in a menu
driven program to run systematically and in harmony. The main.py contains code that
gives access to the other 3 modules which contain the code for individual games.
main.py uses the user input to determine which game to run and main.py has code to
store the scores and data into a MySQL database which is further used to show each
players stats.
2
THEORETICAL BACKGROUND
Database :
Introduction and Concepts :
A database is a collection of information related to a particular subject or purpose, such as tracking
customer orders or maintaining a product collection. Using any RDBMS application software like MS
SQL Server, MySQL, Oracle, Sybase etc, you can manage all your information from a single database
file. Within the file, divide your data into separate storage containers called tables. You may and
retrieve the data using queries.
A table is a collection of data about a specific topic, such as products or suppliers. Using a separate
table for each topic means you can store that data only once, which makes your database more
efficient and reduces data-entry errors. Table organises data into columns (called fields) and rows
(called records) A Primary key is one or more fields whose value or values uniquely identify each record
in a table. In a relationship, a primary key is used to refer to specific record in one table from another
table. A primary key is called foreign key when it is referred to from another table.
To find and retrieve just the data that meets conditions you specify, including data from multiple tables,
create a query- A query can also update or delete multiple records at the same time, and perform built-
in or custom calculations on your data.
3
Role of RDBMS Application Program :
A computer database works as an electronic filing system, which has a large number of ways of cross-
referencing, and this allows the user many different ways in which to re-organize and retrieve data- A
database can handle business inventory, accounting and filing and use the information in its files to prepare
summaries, estimates and other reports. The management of data in a database system is done by means
of a general-purpose software package called a Database Management System (DBMS). Some commercially
available DBMS are MS SQL Server, MS ACCESS, NGRES, ORACLE, and Sybase. A database management
system, therefore. is a combination of hardware and software that can be used to set up and monitor a
database, and can manage the updating and retrieval of database that has been stored in it. Most of the
database management systems have the following
capabilities:
• Creating of a table, addition, deletion, modification of records.
• Retrieving data collectively or selectively.
• The data stored can be sorted or indexed at the user's discretion and
• Various reports can be produced from the system These may be either
standardized or that may be specifically generated according to
specific user definition.
• Mathematical functions can be performed and the data stored in the database
can be manipulated with these functions to perform the desired calculations
• To maintain data integrity and database use.
The DBMS interprets and processes users' requests to retrieve information from a database. In most
cases, a query request will have to penetrate several layers of software in the DBMS and operating
system before the physical database can be accessed. The DBMS responds to a query by invoking the
appropriate subprograms, each of which performs its special function to interpret the query, or to locate
the desired data in the database and present it in the desired order.
4
My SQL:
MySQL, the most popular Open source SQL database management system, is developed, distributed, and
supported by Oracle Corporation- MySQL is named after co-founder Monty daughter, My. The name of the
MySQL Dolphin (logo) is
The MySQL Database Server is very fast, reliable, and easy to use.
If that is what you are looking for, you should give it a try. MySQL Server also has a practical set of features
developed in close cooperation with our users. You can find a performance comparison of MySQL Server
with other database managers on our benchmark page MySQL Server was originally Developed to handle
large databases much faster than existing solutions and has been successfully used in highly demanding
production environments for several years. Although under constant development. MySQL Server today
offers a rich and useful set of functions- Its connectivity, speed, and security make MySQL Server highly
suited for accessing databases on the Internet.
5
The Main Features of MySQL
Works on many different platforms.
Uses multi-layered server design with independent modules.
Provides transactional and storage engines
Designed to make it relatively easy to add other storage engines. This is
useful if you want to provide an SQL interface for an in-house database.
Uses a very fast thread-based memory allocation system-
Executes very fast joins using an optimized nested-loop join.
Implements SQL functions using a highly optimized class library that should be as fast as possible.
Usually there is no memory allocation at all after query initialization-
Provides the server as a separate program for use in a client/server networked environment, and
as a library that can be embedded (linked) into standalone applications. Such applications can be
used in isolation or in environments where no network is available.
Password security by encryption of all password traffic when you connect to a server.
Support for large databases- We use MySQL Server with databases that contain 50 million records.
We also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows.
MySQL client programs can be written in many languages. A client library written in C is available
for clients written in C or C++, or for any language provides c bindings
APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and are available, enabling MySQL clients to
be written in many languages.
The Connector/ODBC (MyOBDC) interface provides MySQL support for client programs that use
ODBC (Open Database Connectivity) connections.
The Connector/J interface provides MySQL support for Java client programs that use JDBC
connections. Clients can be run on Windows or Unix. Connector/J source is available.
6
Visual Studio Code :
Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made
by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include support
for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and
embedded Git. Users can change the theme, keyboard shortcuts, preferences, and
install extensions that add additional functionality.
In the Stack Overflow 2021 Developer Survey, Visual Studio Code was ranked the most popular
developer environment tool among 82,000 respondents, with 70% reporting that they use it.
Hierarchy Structure: The code files are located in files and folders.
Improving Code: Some code snippets can be declared a bit differently, which might help the user
in the code
Terminal Support
simultaneously.
7
Problem Definition & Analysis
The hardest part of building a software system is deciding precisely what to build. No other part of the
conceptual work is so difficult as establishing the detailed technical requirement. Defining and applying
good, complete requirements are hard to work, and success in this endeavour has eluded many of us.
Yet, we continue to make progress.
Problem definition describes the What of a system, not How. The quality of a software product is only as
good as the process that creates it. Problem definition is one of the most crucial steps in this creation
process. Without defining a problem, developers do not know what to build, customers do not know what
to expect, and there is no way to validate that the built system satisfies the requirement. Problem
definition and Analysis is the activity that encompasses learning about the problem to be solved,
understanding the needs of customer and users, trying to find out who the user really is, and
understanding all the constraints on the solution. It includes all activities related to the following:
8
System implementation
Dell Inspirion 15 3000 series, 12GB ram Intel(R) Core(TM) i5-7200U CPU @
2.50GHz
The Software used :
9
System design and development
Database Design:
An important aspect of system design is the design of data storage structure. To begin with a logical
model of data structure is developed first. A database is a container object which contains tables,
queries, reports and data validation policies enforcement rules or constraints etc. A logical data often
represented as records are kept in different tables after reducing anomalies and redundancies. The
goodness of data base design lies in the table structure and its relationship. This software project
maintains a database named “score” which contains the “score_count” table.
Table Design :
The database of “score” System contains 1 table. The tables are normalized to minimize the
redundancies of data and enforcing the validation rules of the organization. Most of the tables are
designed to store master records. The tables and their structure are given below.
10
Coding
chess.py
from math import *
import os
def game() :
global
turn,dummy_board,black_check,white_check,flag,gamer_id1,gamer_id2,winner,win_id,loser,lose_id
winner = ""
win_id = ""
loser = ""
lose_id = ""
flag = True
clear = lambda : os.system('cls')
white_name = input('Enter player name playing white : ')
gamer_id1 = input('Enter gamer ID of '+white_name+" : ")
black_name = input('Enter player name playing black : ')
gamer_id2 = input('Enter gamer ID of '+black_name+" : ")
bc = '\033[30m'
wc = '\033[37m'
turn = False
black_check = 0
white_check = 0
chance = {False:'[37m',True:'[30m'}
pawn = "♟"
knight = "♞"
bishop = "♝"
rook = "♜"
11
a = [[bc+"♜"],[bc+"♞"],[bc+"♝"],[bc+"♛"],[bc+"♚"],[bc+"♝"],[bc+"♞"],[bc+"♜"]]
b = [[bc+pawn],[bc+pawn],[bc+pawn],[bc+pawn],[bc+pawn],[bc+pawn],[bc+pawn],[bc+pawn]]
c = [[],[],[],[],[],[],[],[]]
d = [[],[],[],[],[],[],[],[]]
e = [[],[],[],[],[],[],[],[]]
f = [[],[],[],[],[],[],[],[]]
g = [[wc+pawn],[wc+pawn],[wc+pawn],[wc+pawn],[wc+pawn],[wc+pawn],[wc+pawn],[wc+pawn]]
h = [[wc+"♜"],[wc+"♞"],[wc+"♝"],[wc+"♛"],[wc+"♚"],[wc+"♝"],[wc+"♞"],[wc+"♜"]]
board = [a,b,c,d,e,f,g,h]
dummy_board = board.copy()
def print_board() :
if turn == False :
print(" A B C D E F G H"+"\n-------------------------------------------")
for i in range(len(board)) :
print(f"{i+1} | ",end="")
for j in board[i] :
if len(j) == 1 :
print(j[0],end=wc+" | "+wc)
else :
print()
print("-------------------------------------------")
else :
print(" A B C D E F G H"+"\n-------------------------------------------")
for i in range(len(board)) :
print(f'{8-i} | ',end="")
for j in board[::-1][i] :
if len(j) == 1 :
print(j[0],end=wc+" | "+wc)
else :
print()
print("-------------------------------------------")
12
def pos_point(pos) :
y = int(pos[1])-1
x = ord(pos[0])-97
return [x,y]
def point_pos(pos) :
m2=str(pos[1]+1)
m1=chr(pos[0]+97)
return m1+m2
def king_func(piece,sc) :
t_val = [] ; val = []
if bc in piece :
color = bc
opp_color = wc
else :
color = wc
opp_color = bc
for i in range(8) :
for j in range(8) :
try :
t_val.append([i,j])
except :
pass
try :
t_val.append([i,j])
except :
pass
try :
t_val.append([i,j])
13
for i in t_val :
pieces_seen.append(board[i[1]][i[0]][0])
pass
else :
val.append(i)
return [val,pieces_seen,opp_color]
def rook_func(piece,sc) :
if bc in piece :
color = bc
opp_color = wc
else :
color = wc
opp_color = bc
left = []
right = []
up = []
down = []
for i in range(8) :
for j in range(8) :
try :
if sc[0] == i :
if sc[1] > j :
up.append([i,j])
else :
down.append([i,j])
if sc[1] == j :
if sc[0] > i :
left.append([i,j])
else :
right.append([i,j])
except :
14
pass
path_st = [left[::-1],right,up[::-1],down]
val = [] ; pieces_seen = []
for i in path_st :
for j in i :
if j == [sc[0],sc[1]] :
continue
break
val.append(j)
pieces_seen.append(board[j[1]][j[0]][0])
break
else :
val.append(j)
return [val,pieces_seen,opp_color]
def bishop_func(piece,sc) :
if bc in piece :
color = bc
opp_color = wc
else :
color = wc
opp_color = bc
up_left = []
up_right = []
down_left = []
down_right = []
15
for i in range(8) :
for j in range(8) :
try :
if fabs(sc[0] - i) == fabs(sc[1]-j) :
if sc[0] > i :
if sc[1] < j :
down_left.append([i,j])
else :
up_left.append([i,j])
else :
if sc[1] < j :
down_right.append([i,j])
else :
up_right.append([i,j])
except :
pass
path_diag = [up_left[::-1],up_right,down_left[::-1],down_right]
val = [] ; pieces_seen = []
for i in path_diag :
for j in i :
if j == [sc[0],sc[1]] :
continue
break
val.append(j)
pieces_seen.append(board[j[1]][j[0]][0])
break
else :
val.append(j)
return [val,pieces_seen,opp_color]
16
def knight_func(piece,sc) :
t_val = []
val = []
if bc in piece :
color = bc
opp_color = wc
else :
color = wc
opp_color = bc
for i in range(8) :
for j in range(8) :
try :
t_val.append([i,j])
except :
pass
try :
t_val.append([i,j])
except :
pass
pieces_seen = []
for i in t_val :
pieces_seen.append(board[i[1]][i[0]][0])
pass
else :
val.append(i)
return [val,pieces_seen,opp_color]
17
def queen_func(piece,sc) :
if bc in piece :
color = bc
opp_color = wc
else :
color = wc
opp_color = bc
up_left = []
up_right = []
down_left = []
down_right = []
left = []
right = []
up = []
down = []
for i in range(8) :
for j in range(8) :
try :
if fabs(sc[0] - i) == fabs(sc[1]-j) :
if sc[0] > i :
if sc[1] < j :
down_left.append([i,j])
else :
up_left.append([i,j])
else :
if sc[1] < j :
down_right.append([i,j])
else :
up_right.append([i,j])
except :
pass
18
try :
if sc[0] == i :
if sc[1] > j :
up.append([i,j])
else :
down.append([i,j])
if sc[1] == j :
if sc[0] > i :
left.append([i,j])
else :
right.append([i,j])
except :
pass
path_diag = [up_left[::-1],up_right,down_left[::-1],down_right]
path_st = [left[::-1],right,up[::-1],down]
val = [] ; pieces_seen = []
for i in path_diag :
for j in i :
if j == [sc[0],sc[1]] :
continue
break
val.append(j)
pieces_seen.append(board[j[1]][j[0]][0])
break
else :
val.append(j)
19
for i in path_st :
for j in i :
if j == [sc[0],sc[1]] :
continue
break
val.append(j)
pieces_seen.append(board[j[1]][j[0]][0])
break
else :
val.append(j)
return [val,pieces_seen,opp_color]
def pawn_func(piece,sc) :
if bc in piece :
color = bc
opp_color = wc
num = -1 ; doubnum = -2
doubmove = ["a2","b2","c2","d2","e2","f2","g2","h2"]
promote = ["a8","b8","c8","d8","e8","f8","g8","h8"]
else :
color = wc
opp_color = bc
num = 1 ; doubnum = 2
doubmove = ["a7","b7","c7","d7","e7","f7","g7","h7"]
promote = ["a1","b1","c1","d1","e1","f1","g1","h1"]
t_val = [] ; val = []
20
try :
if board[sc[1] - num][sc[0]+1] != [] :
t_val.append([sc[0]+1,sc[1]-num])
except :
pass
try :
if board[sc[1]-num][sc[0]-1] != [] :
t_val.append([sc[0]-1,sc[1]-num])
except :
pass
try :
if board[sc[1]-num][sc[0]] == [] :
t_val.append([sc[0],sc[1]-num])
t_val.append([sc[0],sc[1]-doubnum])
except :
pass
pieces_seen = []
for i in t_val :
pieces_seen.append(board[i[1]][i[0]][0])
pass
else :
val.append(i)
return [val,color,promote,pieces_seen,opp_color]
21
def valid_move(piece,startpos,endpos) :
sc = pos_point(startpos)
ec = pos_point(endpos)
if len(piece) == 0 :
R = False
else :
piece = piece[0]
if pawn in piece :
R = False
pawn_fun = pawn_func(piece,sc)
if ec in pawn_fun[0] :
R = True
if R :
if endpos in pawn_fun[2] :
if pro == "Q" :
piece = pawn_fun[1]+"♛"
piece = pawn_fun[1]+"♜"
piece = pawn_fun[1]+"♞"
piece = pawn_fun[1]+"♝"
else :
print("err")
R = False
knight_fun = knight_func(piece,sc)
if ec in knight_fun[0] :
R = True
22
elif bishop in piece :
R = False
bishop_fun = bishop_func(piece,sc)
if ec in bishop_fun[0] :
R = True
R = False
rook_fun = rook_func(piece,sc)
if ec in rook_fun[0] :
R = True
R = False
queen_fun = queen_func(piece,sc)
if ec in queen_fun[0] :
R = True
R = False
king_fun = king_func(piece,sc)
if ec in king_fun[0] :
R = True
return [R,piece]
def check_check(dummy,turn,AorB) :
global see
turn = not(turn)
if turn :
col = bc
else :
col = wc
ret = False
23
for i in range(len(dummy)) :
for j in range(len(dummy[i])) :
piece = dummy[i][j][0]
sc = [j,i]
if bishop in piece :
see = bishop_func(piece,sc)[1]
see = rook_func(piece,sc)[1]
see = pawn_func(piece,sc)[3]
see = queen_func(piece,sc)[1]
see = knight_func(piece,sc)[1]
for x in see :
if king in x :
ret = True
return ret
def check_mate() :
global flag,winner,win_id,loser,lose_id
if white_check == 3 :
print(white_name+' WINS')
winner = white_name
win_id = gamer_id1
loser = black_name
lose_id = gamer_id2
flag = False
elif black_check == 3 :
print(black_name+' WINS')
winner = black_name
win_id = gamer_id2
24
def move() :
global turn,dummy_board,white_check,black_check
piece = board[int(startpos[1])-1][ord(startpos[0])-97]
validation = valid_move(piece,startpos,endpos)
dummy_board[int(startpos[1])-1][ord(startpos[0])-97] = []
dummy_board[int(endpos[1])-1][ord(endpos[0])-97] = [validation[1]]
check = check_check(dummy_board,turn,'A')
dummy_board[int(startpos[1])-1][ord(startpos[0])-97] = [validation[1]]
dummy_board[int(endpos[1])-1][ord(endpos[0])-97] = []
clear()
if check == True :
else :
board[int(startpos[1])-1][ord(startpos[0])-97] = []
board[int(endpos[1])-1][ord(endpos[0])-97] = [validation[1]]
turn = not(turn)
check2 = check_check(dummy_board,turn,'B')
print_board()
if check2 == True :
if turn == True :
white_check += 1
else :
black_check += 1
print('CHECK !!!')
else :
clear()
print_board()
print_board() 25
while flag :
move()
check_mate()
hangman.py
import random
import os
def game2() :
global name,name_id,win
win = False
def main():
global count,display,word,already_guessed,length,play_game
words_to_guess = ["laptop","python","java","october","kerala","nitte"]
word = random.choice(words_to_guess)
length = len(word)
count = 0
already_guessed = []
play_game = ""
def hangman():
global count,display,word,already_guessed,play_game,win
limit = 9
guess = input("This is the Hangman Word: " + display + "\nEnter your guess: ")
guess = guess.strip()
hangman()
26
elif guess in word:
already_guessed.extend([guess])
index = word.find(guess)
print(display + "\n")
else:
count += 1
clear()
if count == 1:
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
elif count == 2:
" | | \n"
" | |\n"
" | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
27
elif count == 3:
" | | \n"
" | |\n"
" | | \n"
" | \n"
" | \n"
" | \n"
"__|__\n")
elif count == 4:
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | \n"
" | \n"
"__|__\n")
elif count == 5:
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | | \n"
" | \n"
"__|__\n")
elif count == 6:
" | | \n"
" | |\n"
" | | \n" 28
" | O \n"
" | |\ \n"
elif count == 7:
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | \n"
"__|__\n")
elif count == 8 :
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | / \n"
"__|__\n")
elif count == 9:
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | / \ \n"
"__|__\n")
win = False
win = True
29
elif count != limit:
hangman()
main()
Ticktactoe.py
import os
def game3() :
global winner,loser,win_id,lose_id,flag,draw,id1,id2,name1,name2
moves = ["a1","a2","a3","b1","b2","b3","c1","c2","c3"]
win =
(("a1","a2","a3"),("a1","b1","c1"),("a1","b2","c3"),("b1","b2","b3"),("c1","c2","c3"),("a2","b2","c2"),("a3","b3","c3"),("a
3","b2","c1"))
def board(a1,a2,a3,b1,b2,b3,c1,c2,c3) :
os.system('cls')
print(f' {a1} | {a2} | {a3} \n-----------\n {b1} | {b2} | {b3} \n-----------\n {c1} | {c2} | {c3} ')
player1 = []
player2 = []
flag = False
def dec(x,y):
global flag,a,b,win_id,lose_id,loser,winner,draw
for j in win :
a=0;b=0
for h in j :
if h in x :
a+=1
if h in y :
b+=1
if a == 3 :
print(f"{name1} wins!!!")
draw = False
if b == 3 :
print(f"{name2} wins!!!")
winner = name2
win_id = id2
lose_id = id1
loser = name1
flag = True
draw = False
def move():
global draw
a1=' ';a2=' ';a3=' ';b1=' ';b2=' ';b3=' ';c1=' ';c2=' ';c3=' '
for i in range(9):
if flag:
break
if i%2 == 0 :
player1.append(move1)
if move1 == 'a1':
a1 = 'X'
a2 = 'X'
a3 = 'X'
b1 = 'X'
b2 = 'X'
31
b3 = 'X'
c1 = 'X'
c2 = 'X'
c3 = 'X'
board(a1,a2,a3,b1,b2,b3,c1,c2,c3)
else :
player2.append(move2)
if move2 == 'a1':
a1 = 'O'
a2 = 'O'
a3 = 'O'
b1 = 'O'
b2 = 'O'
b3 = 'O'
c1 = 'O'
c2 = 'O'
c3 = 'O'
board(a1,a2,a3,b1,b2,b3,c1,c2,c3)
dec(player1,player2)
32
if not(flag) :
draw = True
move()
Main.py
import pymysql
import os
import chess
import hangman
import tictactoe
cnx = pymysql.connect(host='localhost',user='root',password='12345',database='score')
cur = cnx.cursor()
def scoreboard() :
cnx.commit()
con = cur.fetchall()
for i in con :
print("Name : "+i[1])
print("gamer ID - "+i[0])
print()
def main() :
print('1.CHESS (multiplayer)')
if num == 1 : 33
flag = True ; flag2 = True
flag = True ; flag2 = True
chess.game()
cnx.commit()
con = cur.fetchall()
for i in con :
if chess.win_id == i[0] :
if i[2] != None :
cnx.commit()
flag = False
else :
cnx.commit()
flag = False
if chess.lose_id == i[0] :
flag2 = False
if flag :
cnx.commit()
if flag2 :
cnx.commit()
elif num == 2 :
hangman.game2()
flag = True
cnx.commit()
con = cur.fetchall()
for i in con :
if hangman.name_id == i[0] :
if hangman.win :
if i[3] != None :
34
cur.execute(f"update score_count set hangman = {i[3]+1} where gamer_id =
'{hangman.name_id}';")
cnx.commit()
flag = False
break
else :
flag = False
if flag :
if hangman.win :
cnx.commit()
else :
cnx.commit()
elif num == 3 :
tictactoe.game3()
cnx.commit()
con = cur.fetchall()
for i in con :
if tictactoe.draw == True:
if tictactoe.id1 == i[0] :
if i[4] != None :
cnx.commit()
flag = False
else :
cnx.commit()
flag = False
35
elif tictactoe.id2 == i[0] :
if i[4] != None :
cnx.commit()
flag2 = False
else :
cnx.commit()
flag2 = False
else :
if tictactoe.win_id == i[0] :
if i[4] != None :
cnx.commit()
flag = False
else :
cnx.commit()
flag = False
if tictactoe.lose_id == i[0] :
flag2 = False
if tictactoe.draw :
if flag :
cnx.commit()
if flag2 :
cnx.commit()
36
else :
if flag :
cnx.commit()
if flag2 :
cnx.commit()
if num == 4 :
scoreboard()
print('Invalid option')
if cont == 'y' :
main()
else :
quit()
37
Outputs
38
39
40
41
42
References
Python.org
Geeksforgeeks (https://www.geeksforgeeks.org/)
Stackoverflow (https://stackoverflow.com/)
Computer science with python text book for class XII
by Sumita Arora published by Dhanpat Rai and Co.
43