Write a program for tic tac toe

Assignment Help Programming Languages
Reference no: EM131215474

1 TIC TAC TOE

In a Tic Tac Toe game two players, X and O, take turns to mark the spaces in a 3X3 grid. The winner will be the player who first succeeds in placing three of his/her marks in a horizontal, vertical, or diagonal row.

Write a program for a computer (X player) to play with a human (O player) on Tic Tac Toe game given an initial status of the game. The initial status of the game can be represented by a string of 9 characters.

1706_Figure.jpg

For example, the game status in figure 1.1 can be expressed using string "OOO_OX_XX". Your program should always play the winning strategies and try to defeat the human player if possible, whichmean you have to do the game tree search to find the subgame equilibrium for the computer player. When the game finishes, print out who wins the game (Hint*: User recursive function).

The sample input and output are shown below:

Example 1:

java A2_Q1 "XXO_O_XO_"

The computer chooses to fill the cell #4

X X O

X O

X O

The ComputerWon!

Example 2: (Note that the green text is the typed input from a human player)

Èjava A2_Q1 "XXOOO_X__"

The computer chooses to fill the cell #6

X X O

O O X

X

Human player please select a cell number to fill: 1

Not a validmove, please try again. Please select a cell to fill: 8

Thanks. Now the board looks like:

X X O

O O X

X O

The computer chooses to fill the cell #9

X X O

O O X

X O X

The game is finished. No one won the game.

Reference no: EM131215474

Questions Cloud

North american indian civilizations : Compare the north american indian civilizations with those in mexico and south america?
Discuss how the planning process enhanced your ability : Discuss how the planning process enhanced and/or challenged your ability to teach effectively and efficiently, with regards to catering for the diversity of needs within your practicum context.
Describe the type of network or combined networks : Review the types of networks in Chapter 6. Examples of network types are Cellular, Wi-Fi, Bluetooth, LAN, MAN, WAN, PAN, Cable, DSL, T1, Satellite, Fixed Wireless, Fiber to Premises, Optical Carrier, Broadband over powerlines (BPL).
What is pangea : What is Pangea? Approximately when did it split apart and form the land masses that we recognize today as North, Central, and South America?
Write a program for tic tac toe : Write a program for a computer (X player) to play with a human (O player) on Tic Tac Toe game given an initial status of the game. The initial status of the game can be represented by a string of 9 characters.
Impact of the fishing industry : Explain the importance and impact of the Fishing Industry. Discuss problems and issues surrounding the Fishing Industry today.
Monotheistic and others polytheistic : Why did people create very different religious structures? Why were some monotheistic and others polytheistic?
Pivotal to human development : Which era do you think was more pivotal to human development - The Paleolithic Era or the Neolithic Era?
Explain what kind of evidence does the author use : What kind of evidence does the author use? (e.g., facts, statistics, examples, personal experience, expert testimony, analogy, etc.). Is the evidence sufficient, specific, relevant, and convincing?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write code for member method expand

Write code for the member method expand. To keep the code simple, you may assume that the array element has enough capacity and does not need to be resized.

  Write a menu driven program that accepts words

Write a menu driven program that either accepts words and their meanings, or displays the list of words in lexicographical order (i.e. as in a dictionary).

  A program is required which prompts the user

A program is required which prompts the user to enter the individual price of 3 different items and computes and prints the total cost of the 3 items as well as the average cost. remember to add sales tax (5% or 0.05) to the total cost.

  Write procedure list-records whihc returns list of records

Write a procedure called list-records which returns a list of all records by artist from a list of records containing several artists.

  Write a method to accepts string as parameter

Write a method called wordCount that accepts a String as its parameter and returns the number of words in the String. A word is a sequence of one or more nonspace characters

  Write program in java to input basic salary of persons

Write the program in java to input basic salary of 15 persons. Each one of them gets 25% of basic as hra (house rent allowance), 15 % of basic as conveyance and 10 % of basic as entertainment allowance.

  Write a program to read student data from standard input

Write a program to read student data from standard input, sort it by last name / first name, and print result to standard output.

  Write program using array to show fifo queue

Write program using any language which uses the array to demonstrate simple FIFO queue with 10 job entering the queue and 5 jobs removed from the queue by the server.

  Create a default string of cars in main

Build the default constructor first. Create a default string of cars in main. Build an output function, similar to the old one, but dereferrencing the pointers.

  Programming project

Write programs in Visual Basic while being guided by the six steps of the program development cycle: analyze the problem, design a solution, choose the interface, write code, test and debug your solution, and document code.

  Write program to open file for reading

Write the program to open file for reading which has twenty (20) rows and in each row there are three (3) columns. After reading each row call user-defined function to display each row.

  Add comments to the different sections.

Add comments to the different sections.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd