Artificial Intelligence: Teaching a Computer to Play Tic-Tac-Toe

CSEF · 2012 Mathematics & Software Honorable_mention Award

Overview

Objectives/Goals Our purpose was to create a computer program that can learn to play tic-tac-toe. We were interested in how artificial intelligence works and wanted to see if we could create a program, teach it to play tic-tac-toe, and make it unbeatable. Methods/Materials The initial step was to learn the basics of JavaScript, HTML, and computer programming. Then, we created a web page to draw the square images to create a tic-tac-toe board. Functions were set up for the computer to pick the computers next move, such as being able to 'win and block if given the option' and 'picking the most popular move'. Test subjects were asked to play the game on various settings, and data was collected regarding wins, losses, and ties. Results Before we created a function that chose the 'most popular winning move' and saved a lot of game data, we could beat the computer almost every time. With plenty of data and the 'most popular winning move' function complete, the computer can never lose. The computer now only wins or ties. This has been demonstrated with several test subjects. Conclusions/Discussion The computer, after loading all previous game data files, cannot be beat, but it can be tied. This approach of computer learning can be applied to other fields such as medicine, engineering and manufacturing.

Summary statement

We programmed a computer to learn from human behaviors and play tic-tac-toe, showing that with limited learning data the computer didn't play as well as it did with total access to all recorded game data.

Help received

Mr. Boyd helped teach us JavaScript and HTML. He also helped us set up the beginning of the program. We also took the online HTML and JavaScript course at www.w3school.com.

Awards (1)

  • Honorable Mention

Competition history

  • CSEF 2012 Mathematics & Software · Entry J1403

Resources

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: California Science & Engineering Fair public projects

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google