Draw the tree graph for tictactoe game

Assignment Help Computer Engineering
Reference no: EM13869172

Making a computer learn to play TicTacToe.

Background

As we talked about in class, you can write a program to play TicTacToe and which also learns strategy using MiniMax. As the program plays, it adds nodes to a game graph. The outcome of the games become the values (weights) of the end nodes. After each game, a MiniMax process (a double recursion you will write) is run to re-calculate all the weights. As the graph grows, the node weights will prevent the computer from following old losing paths. It will get to a point that you cannot beat it.

We do not implement any methods for playing. Well, that's not exactly true. We do assume that after a certain small number of games the computer would know to block the user if they already have 2 squares in a row and the third winning square has nothing in it. Similarly, we assume it would know to make a winning move if it had 2 squares in a row with the winning third square open when it is its turn to move. You can control when this knowledge appears by adjusting a const in the program called Early
(const int Early=3) near the beginning of the program. You can set Early to a high number and see that the computer will learn to block and notice winning moves, but it will take longer.

Your task(s)

The program is moderately large. To get into it, load the project TicTacToe2.vcproj. The main program is too long to ask you to do the whole thing. I wrote it all for you (in a file tictactoetemplate.cpp) except for the part that updates the graph weights after each run. There is a function in the program: void UpdateTree() that you need to fill out using the double recursion we discussed in class. I've also included a skeleton for 2 other functions you'll need, Min and Max. Without these doing minimax, the program plays but does not learn. So this is your end task. Write the needed functions. (They are quite short if you do it correctly.) But you also need to do a few other things.

It is not easy to test your work and to sort out how to integrate it with all the date structures and variables in the program. So I am posting (in the zip file) 2 other files that you must work with to get your code working. First, there is a node file (called nodesteatin.dat that has a "fake" set of 23 nodes. Your tasks are:

1. On paper, draw the tree/graph for this file (circles as nodes and lines from parents to children). The board positions in the nodes are real. The weights are not what would be in the real game, but they are good for testing. One node has 2 parents. The game starts with Min's move. Turn in your diagram.

2. Testing an algorithm inside a complex program can be hard. Often we write a "stub" program that just runs a new algorithm to test whether it works, but doesn't do the whold main program. You will complete such a test stub program in this part. Complete the test program I've posted in the zip file called updatenodestesttemplate.cpp. It does only 3 things. It reads the node value into the 2 dimensional array Tree[1500][19]. It then runs UpdateTree(), and it writes the updates tree (after minimax) to another file. So write your own UpdateTree and other needed functions here. Test your program and see that you get what you worked out on paper. (Note that in order to make writing and testing of this program easier, the input and output files are different so you do not overwrite the input file after the run. The main big program uses the same file for input and output so that you can run a session of 20 games, for example, and then another session of 30 games and the learning just goes on.)

3. Copy your functions into the main program and run it. Note that the main program has another constant you must adjust. It determines whether you will start and build a brand new nodes file or continue with a previous one. If you set const int GameCount = 0; then it will start over even if you have a nodes file. If you set the value to anything else, it will load the file named nodes.dat and continue with it and write its results to it when you finish.

Things to turn in:

1. Your diagnostic program.

2. Your main program and your final nodes.dat file.

3. On paper, turn in your graph of the 23 nodes including the weights and the board condition for each node.

Optional

Do you wonder what happens when the program is trained? I'm also enclosing two files called nodes400.dat and nodes500.dat. The numbers indicate the number of games played in each case to build that "brain." I can beat nodes400, but I can't beat nodes500. See if you can for fun. To run either, make a copy of it (to not mess up the original) and change its name to nodes.dat and run your main program.

Reference no: EM13869172

Questions Cloud

Substance a disappears following zero order : Substance A disappears following zero order kinetics with rate constant as 0.015 M s-1. Estimate the concentrationof A left after 25 seconds if the initial concentration is 0.5 M ? A first order reaction has half-life 10 min. If the reaction is start..
Explain entire marketing plan of action for chosen product : You are to select a tangible product that exists in the marketplace, not a service and create or explain the entire marketing plan of action for your chosen product, including the Four-Ps of marketing or all of the elements of the Marketing Mix
Specific industry guidance under u.s. gaap or ifrs : If a motion picture company wanted to find specific guidance on how to recognize revenue related to its film licensing rights,
Revised project management plan and report to management : You have recently been appointed as a project manager in a large engineering organisation. Some examples of such an organisation include, but are not limited to:
Draw the tree graph for tictactoe game : draw the tree/graph for this file (circles as nodes and lines from parents to children). The board positions in the nodes are real. The weights are not what would be in the real game
Determination of molecular weight by freezing point : Describe the determination of molecular weight by freezing point depression method. Write a proper descritipn of given topic along with proper refrences.
Perform a finite element analysis on a mechanical system : The purpose of this project is to perform a finite element analysis on a mechanical system in ANSYS and communicate the results clearly in a standard report format.
What types of risk do you think affects each of investment : What types of risk do you think affects each of the investments?
Formation of secondary organic aerosol : The atmospheric oxidation of isoprene (2-methyl-1,3-butadiene, C5H8) leads to the formation of secondary organic aerosol (SOA). In this study, the mechanism of SOA formation by isoprene photooxidation is comprehensively investigated, by measuremen..

Reviews

Write a Review

Computer Engineering Questions & Answers

  Listing each prompt that is used in this program.

Write down a new program in pseudo-code, it should input-and calculate the average of 5 numbers entered.

  Routers

Discuss in detail why the differentiated services (DS) domain comprises of the set of contiguous routers? Also explain how the boundary node routers are different from interior node routers in the DS domain.

  Gantt chart-project log

Morris Wildlife Services deals with the humane removal of wildlife from places it does not belong (such as removing bats from attics and trapping coyotes for release in more suitable habitat).

  Make a structure that has one variable called value

design a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list.

  Program that reads a set of scores from the file scores

plan and write a C++ program that reads a set of scores from the file scores.dat and outputs their mean and standard deviation on standard output. Use the following sets of input for testing the program.

  Questionthis is only necessary to be done in raptor flow

questionthis is only necessary to be done in raptor flow chartnbspa local department store hires you to write down an

  Write a ruby program that reads a line from the user

In class assignments #12. Design a Ruby class that inherits from the inbuilt String class and adds an additional functionality to check if the string is a palindrome. Email your code by end of day 02/28.

  Providing overview of lane

Describe in scholarly detail an overview of the LANE and explain its place in an organization's network strategy. Answer should be of 300 words and also provide reference.

  Writing c code to determine the balance

Write down a program in C++ which determines the balance because of each month on a non-interest loan. Ask user for the loan amount and how much s/he will pay each month.

  Bit binary counter utilizing ltl.

State the three bit counter utilizing the LTL. The following are the properties we may wish to try and prove are valid given the specification of the three bit counter. Eventually the counter reaches 111.

  Z-transformation and fourier transformation

Find the z-transform and the Fourier transform of x(n). Find the N-point DFT of x (n) for N=50,10 and 5.

  Mux design for the xnor function

A MUX design for the XNOR function - a MUX design for the XNOR function.

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