Skip to content

this is the implemntaion of the game TicTakToe using Raw Sockets in python

Notifications You must be signed in to change notification settings

kunz398/TicTakToe-Raw-Sockets-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TicTakToe-Raw-Sockets-Python

this is the implemntaion of the game TicTakToe using Raw Sockets in python I divided my python program in to 9 modules or functions


What happens is it firstly calls the form_submit function to check if a submission has been made
once it has been made the player_move function is invoked for the human’s movement on the board
then after that inside a while loop the function computer_turn is made so that if the computer chooses a spot which has already been used
it won’t select that space again after all that is done then the final function who_wins to decide who wins is called.

Who_wins

Two arrays were declared then I used numpy to separate them in to parts ,
like this diagonal and the reverse diagonal and the first row and so on Then I checked them with the check_Xcheck_O
check_X = when a player makes a move
check_O = when a computer makes a move

Who_wins

I made a random number generator between 1 to 9. So what I did was ever time a move is made it is inserted in to a variable called history so every move gets recorded in the history array and If a move is present in the history array the computer will choose another move.

*I also made a supplementary 2D array for calculating where in the board a player has made a move and so this gave me a way to calculate who would win

How to run 1) open up rawsockets.py and run it it will say
Serving HTTP on port 8888
2) Open up Browser and type localhost:8888
3) you will see a display like so:


About

this is the implemntaion of the game TicTakToe using Raw Sockets in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published