In this project we have implemented a multiplayer tic tac toe game using socket programming in C# in which a server creates the game in local area network. The players in LAN can connect to the server by using the IP address of the server. We have used the concept of thread. When a new client connection arrives to server, new thread will be created and user will be able to play against the opponent player. Rules of the game: One by one the players have to click on buttons, ‘O’ or ‘X’. A player can win the game when either of the diagonals have the same key i.e., ‘O’ or ‘X’ or any of the rows or the columns have the same key otherwise the game will result in a draw. User can also play as a single player against an undefeatable AI.
- Tools Used:
C#Visual Studio 2019WPF (.Net Framework)Socket Programming - User can play as single player against AI
- User can play as multiplayer against opponents through LAN\similar wifi\common communications line
- User can connect to server by entering their name
- User can choose from list of available players to play with.
- Users can chat with each other through chat system
- Users can view their scores
- Client-side modules
- MainWindow
- MultiPlayer
- SinglePlayer
- Server-side modules
- MainWindow
📝IMPORTANT NOTE📝
- open cmd/terminal and type
ipconfig - Copy IPv4/IPv6 address, then open
Client/MultiPlayer.xaml.csfile and assign your ip address to thisSERVER_IP_ADDRESSvariable. - Server and Client both are seperate projects
- First run both server and client projects one by one so that it creates .exe file for both.
- Go to \TicTacGame\Server\bin\Debug
- Open Server.exe file/app
- After Server App Opens Click
Start - Now CLIENT Side
- Go to \TicTacGame\Client\bin\Debug
- Open Client.exe
- You can either play SinglePlayer or MultiPlayer
- With
SinglePlayeryou can play with an AI - when you click on
MultiPlayeranother window will open. - Enter Your Name and click
Connect - After that open another instance of Client.exe
- Enter your name and click
Connect - Select your opponent from list and click
Play - Congrats🎉🎊 You can now play and chat with an opponent
- when you dont want to play anymore exit Client.exe and on Server.exe click
Stopbutton and then exit. - THE END!!