Premium Essay

# Tic Tac Toe Programming

In:

Submitted By tazh
Words 3911
Pages 16
Introduction
Tic-Tac-Toe is a popular simple game for two players all over the world. Traditionally one person plays for “X” while another plays for “O”. The game is played on the square board of 3x3 or even more size. The aim of this game for player is to win by filling with “X” or “O” any row, column or diagonal of the main game board. The game sets players thinking because players should reflect a little bit on strategy and predict some moves of the opponent. So it teaches people to make decisions quickly.
MATLAB is computer software for technical computing from the MathWorks. Used for a wide variety of scientific and engineering calculations. The functions of the MATLAB are solving equations, plotting 2D, 3D graphs, calculating statistics, etc.
The aim of the report is to describe how Tic-Tac-Toe game simulation was made with the help of MATLAB. The report describes how program reads the code and computer strategy for winning/not losing in the game.

Theory.
The aim the individual coursework was to program 4x4 Tic-Tac-Toe game for player and computer using MATLAB with condition that computer should always win or just not loose. Programming the game basic loops such as “while”, “for”, “if” were used, where “while” means to repeat smth until some particular conditions are holding, “for” means to do smth for particular conditions, and “if” means to do smth if some conditions are true. There also were used “sum” function which helps to count “X”-s or “O”-s in rows, columns, diagonals and basic commands for matrices.

Methodology
The game is played in command window, using the matrice 4x4, where “X” is 1, “O” is -1 and empty cells are zeros. The main algorithm of the program is on Graph 1.

Graph 1. The main algorithm of the Tic-Tac-Toe program.
The game is starting by choosing randomly either computer is playing for “X” or for “O”. Then first

### Similar Documents

Premium Essay

#### Tic Tac Toe Java Code

...OBJECT ORIENTED PROGRAMMING TIC TAC TOE Contents: Page 1. Specifications 3 2. Background 4 3. UML Design i. Use Case Diagram 5 ii. Class Diagram 6 4. Implementation i. How code is working? 7 ii. Conclusion 9 iii. Future Work 10 5. Appendix 10 6. References 15 7. Bibliography 15 1. Specifications: A requirements specification for a software system - is a complete description of the behavior of a system to be developed. It includes a set of use cases that describe all the interactions the users will have with the software. Use cases are also known as functional...

Words: 1071 - Pages: 5

Free Essay

#### Tic Tac Oe

...Computer Programming Computer Programming TIC TAC TOE PROJECT TIC TAC TOE PROJECT Flor Garcia FINAL EXAM Flor Garcia FINAL EXAM 2015 2015 DEFINE THE PROBLEM: Write a Tic Tac Toe program that inputs the player’s names and then asks if you want to play again. It displays a score board at the end of the game. OUTLINE THE SOLUTION: INPUT | PROCESSING | OUTPUT | Name of Player 1 | Names of Both players is inputted | Score board of who won, lost or any draws | Name of Player 2 | Player 1 makes the first move by choosing a number in the box then [X] will replace the chosen number | | Numbers on each box | Player 2 makes the second move by choosing a number in the box then [O] will replace the chosen number | | | If either of the players win, they receive a point in the score board | | | If it is a draw, the score board will display it | | DEVELOP AN ALGORITHM: 1. Insert name of player 1 [X] 2. Insert name of player 2 [O] 3. Players choose the number of the box they want to input their letter in. 4. Once then choose the number they inputted their designated letter will replaced the number in the box 5. These steps are repeated as it is each player’s turn 6. The game will end until someone wins or it becomes a draw 7. The Score board will be displayed at the end TEST THE ALGORITHM: 1. Name of Player 1: Flor 2. Name of Player 2: Karla 3. Flor chooses number 3 and is replaced by [X] 4. Karla chooses...

Words: 1048 - Pages: 5

Premium Essay

#### Wajihaider

...|[pic] |Syed Muhammad Waji Haider | |Born 1994 | | | |Address: House no.7, Bastami road, samnabad lahore | | |Contact: 0307-0408091 | | |Email: waji58@gmail.com | | |Site: waji58.wordpress.com | | |Date of birth: February 12, 1994 | | | | |Personal Profile |Reliable and dependable in meeting objectives | | |Hard working, possess strong planning, organizing and monitoring abilities ...

Words: 513 - Pages: 3

Premium Essay

#### Famous Thinkers

...Famous Thinkers Marquis Jackson PHL/458 May 28, 2012 Jane Muratore When we look back in history and try to discover famous thinkers in our society, many men and women stand out. Famous thinkers are people who used critical thinking and perseverance to overcome adversity to succeed in the endeavors that they choose to face. When I look back and try to pick only two famous thinkers, the two that stand out in my mind are Bill Gates and Dr. Martin Luther King Jr. Here we will look back and discuss their contributions to society as a whole, the problems or issues that they resolved, and how they were able to come up with their solutions. Contributions to Society Self made multi-billionaire, entrepreneur and philanthropist Bill Gates was born in Seattle, Washington in 1955. Everyone in America recognizes the name Bill Gates; it is hard not to be famous when you are the richest self-made man in America. The contributions to society made by Mr. Gates are numerous, but most notable and arguably his best is his company Microsoft, the world’s largest software production company. From a small, no name company formed in 1975 Bill Gates worked countless hours and in no time was able to bring his company to a multi-billion dollar corporation. Eventually, Bill Gates knew that his money and his wife could help the rest of society as his mother had done as a civic leader. In the year 2000, Bill and his wife Melinda formed the Bill and Melinda Gates Foundation...

Words: 1699 - Pages: 7

Free Essay

#### Prg 410 Week 3 Assignment

...PRG 410 WEEK 3 ASSIGNMENT http://www.coursehomework.com/product/prg-410-week-3-assignment/ Contact us at:  +1 315-750-4434  help@coursehomework.com PRG 410 WEEK 3 ASSIGNMENT C++ Programming I PRG-410 Assignment#3 Problem 1: [marks 20] Write a program that implements simple game scenario. Game has two-player or a three-player MODE. For each MODE you have to choose among four HEROs. These are ALPHA, BRAVO, CHALIE and DELTA. You have to design and implement proper notation for each MODE and implement them accordingly using appropriate conditions e.g., First player is selecting ALPHA then Second Player can’t select ALPHA. Against each MODE ask five values for each player if: • Ask input range is between (1-100) player will win with 10 points for one value. • Ask input range is between (101-200) player will win with 20 points for one value. • Ask input range is between (201-500) player will win with 50 points for one value. Add all five values for HERO/HEROs and printout the winner of the game. Problem 2: Rock, Paper, Scissors Game [marks 20] Write a program that lets the user play the game of Rock, Paper, and Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...

Words: 933 - Pages: 4

Premium Essay

#### Bill Gates Accomplishments

...Alfonso Guerrero William Henry Gates III, most famously known as Bill Gates, entered this world on October 28, 1955 in Seattle, Washington. At the young age of 13, he showed a keen interest in computer programming. He pursued his dream through college. His early life consisted of a upper middle class family structure which included two sisters and his parents. All of the children were encouraged to be competitive as his father was a lawyer and mother was an outgoing athlete and always involved in some sort of student leadership activities. As a young child, Bill Gates loved to read and would spend hours going through encyclopedias and eventually his parents worried and had concerns he would be a loner so they enrolled him into a preparatory school due to his boredom and look...

Words: 584 - Pages: 3

Premium Essay

#### Bill Gates Accomplishments

...Washington in October 28, 1955 in a middle to upper class family (Bill Gates Wordpress). His parents had a business mind for him. Gates began his journey to success when his parents decided to enroll Gates into a private school called Lakeside School. In this school he was considered a prodigy, acing all of his classes and being considered one of the smartest kids in the school. In this school he found his interest in coding and programming and his teachers even excused him from math to help him pursue his interest. However, the school was running low on funds and couldn’t use the computer. So, Gates ended up hacking into the computer to use it. He was later caught and banned from using the computer, but later on, the company asks Gates to report the bugs and problems with the computer to the company in exchange for using the computer for free. This is where he started developing his skills. After the experience, he took advantage of the computer and developed a basic program on a piece of paper that allowed a person to play against the computer on a game of tic tac toe. At the age of fifteen he develops another program with his friend Paul Allen called Traf-O-Data which monitored the traffic patterns in Seattle (Bill Gates Weebly). This netted him \$20,000 but soon the company failed. After Gates graduated he continued on the path to becoming the richest man in America by attending one of the best schools, Harvard. Gates was a very intelligent man and scored a 1590 out of 1600 on his SAT’s...

Words: 970 - Pages: 4

Free Essay

#### Take a Good Hard Look Inside

...Take a Good Hard Look Inside Jason Pharr As I write this essay, I can say I am completely and utterly stressed out. Between all the calls from debt collectors, the tickets I am having to pay off, and all of my other bills and medical expenses that I am unable to pay, I can honestly say that I am concerned with where my life has gotten to over the course of the last year. Around two years ago, I was completely debt free, had a great job, and had never even taken a drink of alcohol or recieved a single ticket for anything. I had no worries, no stress, and no concerns what-so-ever for where I would be within a year or two. That's when things started heading downhill entirely. I began drinking, and completely let it take over my life, with all the stigmas attached. I became more and more reckless, and my decisions became more and more rash. I had never had much pressure in my life, but started feeling it from all directions. My recklessness carried over to the way I drove, and spent money, and handled social situations. That's what lead to all my current financial pressures. Between the tickets, the court fees, and all the expenses I had incured through my lifestyle, I had dug myself into a hole so deep that I couldn't see myself getting out of it any time within the forseable future. I know now that in order to address these bad habbits, I must change my lifestyle entirely, and know my weaknesses well enough to know what destructive habbits I should stay away from...

Words: 1163 - Pages: 5

Premium Essay

#### Bill Gates Road to Success

...age of 13, bill enrolled for Lakeside school, an exclusively preparatory school, which is said to be a turning point. It all began to create a new page in the history, when the mothers club at the school used funds arisen out of profit from sale of some miscellaneous things collected in the club, to purchase an ASR-33 teletype terminal and also a block of General Electric computers for school students. Gates developed a special interest in GE terminal computer and went ahead to learn and develop programs using programming language BASIC. He was excused from attending the Maths classes, while doing so. He developed his first major program on his own, which is an implementation of game called as tic-tac-toe. This is, perhaps the turning point in his career. In fact, Gates was always thinking, how the machine could execute his program perfectly without giving any problems. I think, as a professional programmer, that also one way, helped Gates to understand computer programming better. Laying first foundation stones, for a great distinguished career Gates got a chance to work in Computer Center Corporation (CCC), along with three other Lakeside students banned by the same CCC for the summer, after it caught them exploring...

Words: 1673 - Pages: 7

Premium Essay

#### Java

...Robert English 103 13 April 2013 Java the Programming Language Computer is very important in our live, we use computer in everywhere on our live. The doctor uses the computer to see file or pictures of his patients. Also, each engineer uses it in many ways of his work. The teacher in the classroom, employees in the offices and student in their study all of them use computer in them daily live. They are not using the mouse, the keyboard or the scream. They are using the applications by them these applications in the computer are like the soul in the body. The only way to build these applications is programming. To program we need to know one of the programming languages which are very similar each other. If you are professional in one of these languages you can be professional in the other language in a short period of time. It is acceptable if you have the same application written with Java once and with C++ or C sharp at the same time. So for this reason you cannot say that a programming language is better than others. There are three types of programming languages procedural, functional and object-oriented languages. The most uses of these languages are object-oriented and one of these languages is Java you can write any application you need using it. Also you can translate any application to its word. The message of the High-Level programming languages such as Algol and Pascal in first programming revolution was Control abstraction. In the next...

Words: 2352 - Pages: 10

Premium Essay

#### Love in the Air

...Big Bang Board Games Table of Contents Big Bang Board Games.....................................1 Finding/Starting a Game...................................2 Preferences.........................................................3 4-In-A-Row.........................................................6 Tic Tac Toe..........................................................6 Backgammon......................................................7 Checkers.............................................................8 Chess...................................................................9 Mancala..............................................................11 Reversi...............................................................12 Technical Issues/Help......................................13 Credits...............................................................14 Big Bang Board Games and the Macintosh At the core of Big Bang Board Games is the use of Apple technology and the iApps. Casual games are not best played full screen. People like to play them while surﬁng, or iChatting or doing a bit of email. Big Bang Board Games recognizes this and becomes part of their Mac OS X experience. You can effortlessly send turns back and forth via email, invite your IM buddy to a match from within the game itself or just scan your local network–it’s never been this easy. And once the game starts, the tight integration into Apple’s Address Book, iSight, and your iTunes playlists is just what you’d hope...

Words: 3885 - Pages: 16

Premium Essay

#### Tiles

...RAPTOR: Introducing Programming to Non-Majors with Flowcharts Martin C. Carlisle, Terry A. Wilson, Jeffrey W. Humphries, Steven M. Hadfield United States Air Force Academy Department of Computer Science 2354 Fairchild Dr, Suite 6G149 USAFA, CO 80840-6234 {Martin.Carlisle,Jeffrey.Humphries,Steven.Hadfield}@usafa.af.mil ABSTRACT When students are learning to develop algorithms, they very often spend more time dealing with issues of syntax than solving the problem. Additionally, the textual nature of most programming environments works against the learning style of the majority of students. RAPTOR is a flowchart-based programming environment, designed specifically to help students visualize their algorithms and avoid syntactic baggage. RAPTOR programs are created visually and executed visually by tracing the execution through the flowchart. Required syntax is kept to a minimum. Students preferred using flowcharts to express their algorithms, and were more successful creating algorithms using RAPTOR than using a traditional language or writing flowcharts without RAPTOR. Categories and Subject Descriptors D.1.7 [Visual Programming] General Terms Languages, Algorithms. Keywords Flowcharts, Visual Programming, Programming Environments, Problem Solving. 1. INTRODUCTION Shackelford and LeBlanc[6] previously observed that the use of a particular programming language in an introduction to computing course tends to “annoy and distract attention from the core...

Words: 3019 - Pages: 13

Free Essay

#### Artificial Intelligence

...1.INTRODUCTION: Artificial Intelligence is the science and engineering of making intelligent machines, especially intelligent computer programs. It includes people,procedure,hardware,software,data and knowledge needed to develop computer systems and machines that demonstrated characteristics of intelligence.It is related to the similar task of using computers to understand human intelligence, but AI does not have to confine itself to methods that are biologically observable. Intelligence is basically the computational part of the ability to achieve goals in the world. Varying kinds and degrees of intelligence occur in people, many animals and some machines.There is no solid definition of intelligence relating it to human intelligence. The problem is that it cannot yet be characterize in general what kinds of computational procedures can be called intelligent. We understand some of the mechanisms of intelligence and not others. Sometimes Artificial Intelligence is about simulating human intelligence but not always.On the one hand, we can learn something about how to make machines solve problems by observing other people or just by observing our own methods. On the other hand, most work in AI involves studying the problems the world presents to intelligence rather than studying people or animals. AI textbooks define the field as "the study and design of intelligent agents where an intelligent agent is a system that perceives its environment and takes actions that maximize its...

Words: 2505 - Pages: 11

Free Essay

#### America's Wealthy

...TO: Paul Welch, Vice President of Research FROM: Colten Harris, Jackson Wallace, Easton Heigley, Daniel Gift DATE: March 10, 2015 SUBJECT: America’s Wealthy Introduction Since America’s conception, new pioneers have walked this country not with a goal to finish a map like Lewis and Clark, but to strive for “The American Dream” and never settle for less than absolute success. Each man researched is from a different time period, with different circumstances surrounding them. With different presidents, different rules and regulations, even with different life expectancies. However, all men had one dream, to make America a better place. From oil pipelines to windows operating systems, these men truly did create things that changed the lives of all Americans for the better. They are the unspoken heroes. Not of war or battle, but of ingenuity, hard work and of sound mind. These are America’s Wealthy. Findings John D Rockefeller was born on July 8, 1836. He began with humble beginnings and is a perfect definition of a rags to riches dream that many Americans that try to live by. His life at home was somewhat shaky. His father was never at home very much because he was a traveling salesmen who sold elixirs. In his early teens his family moved to a suburb of Cleveland, there he took a 10 week business course that would help him later in his life as the richest man in America. His first job was with a bookkeeper at a commission firm. He excelled at keeping track of...

Words: 2482 - Pages: 10

Premium Essay

#### The Future of Gaming

...The Future of Gaming Devry University Eng 135 Today computers are an integral part of everyday life in America. There's hardly anywhere you can go without seeing a computer in use. It has simplified the hard task of everyday life and left more free time. Many people spend that free time playing video games. Video games are a good way of stress relief, a way to get away from the realities of everyday life and into a virtual world. Some will say that video games have lead to kids being more obese because they don't get outside and play. They say that video games contribute to violence, because acts in games are reenacted by individuals. Video games have also lead to addiction like those from drugs and alcohol. Games have done more to benefit society, than harm it. Video game simulations are used in many fields from the military, education, medical, and the science field. What was once just a break from tedious task on the job has now turned into a billion-dollar industry that doesn't have any signs of slowing down. Some of the negatives of gaming are now being overshadowed by the overwhelming positives. With introduction of the Nintendo Wii we now have interactive video game system that requires users to interact with the game. Gamers no longer sit back and play games but now they are required to interact with them. With games becoming a more integral part of everyday life, the real potential and benefits are now becoming realized. Games are being put...

Words: 3533 - Pages: 15