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

  1 write a script to help users calculate compressed file

1. write a script to help users calculate compressed file size. prompt the user to enter the original size of a file

  Make a paper analyzing the use of databases

make a paper analyzing the use of databases in your organization. Include what database applications are used (Microsoft Access, DB2, Oracle, etc.). Conclude by proposing improvements.

  Make a view called v_no_cost

Using the ITD410_P1 database you created for the Independent Project in Unit 1, write scripts in a file known  ITD410_P3.SQL to create the following views. Remember to include a uses clause at the top of your script file to use the ITD410_P1 datab..

  Explain a subclass of jpanel called mycolorchooser

Declare a subclass of JPanel known as MyColorChooser that provides three JSlider objects and three JTextField objects. Each JSlider represents values from 0 to 255 for the red, green and blue parts of a color.

  Consider any of the supercomputing examples

Consider any of the supercomputing examples we discussed in class, and find a scientific paper describing it. Although you can use Wikipedia and similar sites as a starting point, you must find an article in a valid IEEE or ACM publication (journa..

  Jm sales employs five salespeople the sales manager wants

jm sales employs five salespeople. the sales manager wants an application that allows him to enter any number of sales

  Write down an application that displays a menu

Write down an application that displays a menu.

  Ethernet mac address

Specify the size of Ethernet MAC addresses. State the Ethernet MAC broadcast address. Explain the format of the Ethernet frame?

  You receive a complaint from the store that they cant print

you receive a complaint from the store that they cannot print on network color printer which is located on the third

  List possible objects in the book-store operation

the bookstore staff at pleasant creek community college works hard to satisfy students instructors and the schools

  Explain analog signal conditioning

Analog Signal Conditioning, An LVDT with associated signal conditioning will be used to measure work-piece motion from -20 to +20 cm. The static transfer function is 2.5 mV/mm. The output will be interfaced to a computer via an ADC.

  Design a class coord that includes the members

In ocean navigation, locations are measured in degrees and minutes of latitude and longitude. For in case, 149 degrees 34.8 minutes west longitude, and 17 degrees 31.5 minutes south latitude, to be written as 149°34.8' W, 17°31.5' S.

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