Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin.
Search for scripts directly from SSMS, and instantly access any saved scripts in your
SSC briefcase from the favorites tab.
Download now (direct download link)
Thank this author by sharing:
By Adam Haines,
This script allows a player to compete against a computer in tic tac toe. The game was written in SQL 2005 and may not work correctly in other versions. The game has a little more kick than a game of tic tac toe with an inadequate opponent. This is because to make the game feel more realistic; I added a layer of AI to the computer. The computer can logically determine if he should block the player from wnning the game or go for the win itself.
Playing the game is very simple. The game feeds off three main stored procedures.
usp_PlayTicTacToe has 2 mandatory inputs Quadrant and Mark. Quadrant is the spot you want to mark on the game board. Examples of a quadrant are a1,a2,a3,b1,b2,b3,c1,c2,c3. Mark is a one character notation of your player. Mark can be either 'X' or 'O'.
usp_Redraw_Board simply renders the game board by reading the data from the table and redrawing the board.
usp_New_Game is used once the game has completed to start a fresh game. It just resets the necessary columns in the table to start afresh.
Other than these three stored procedures, the game itself will tell you if something is wrong with your inputs. Additionally, after each of the computer's moves; you can view where the computer moved on his last turn.
This design really has scalablity for future enhancesments. The table could be created as a Global Temp table and the game could be played by remote players.
That's about it. Enjoy.
Create a 'Gartner Magic Quadrant Chart'
There is an Adobe Flash Player available to address a security issue. The bulletin shows as being re...
I wanted to start this series in regards to impact players that go above and beyond in the SQL Commu...