Game On: Creating a Worthy Connect Four Opponent with Heuristic Algorithms

CSEF · 2014 Mathematics & Software Fourth Award

Overview

Objectives/Goals The objective was to design a computer program to model the game of Connect Four and to sometimes win against average human beings using defensive, offensive, and look ahead algorithms. Methods/Materials Four algorithms to play Connect Four against a human player were constructed using JavaScript: random, defensive, aggressive, and look ahead. The random algorithm placed pieces randomly on the board compared to the more strategic defensive algorithm that placed pieces using heuristic scoring to block the human opponent. The aggressive algorithm combined both defensive and offensive strategies, also using a heuristic scoring system. The look ahead algorithm built upon the aggressive algorithm by simulating one opponent move ahead on the game board and scoring the possible moves accordingly. The algorithms were tested against a variety of human subjects to find average success rates for the algorithms. Results The look ahead algorithm was the most successful of the four algorithms in trials against human opponents. Conclusions/Discussion Heuristic algorithms like these could be worthy opponents because their success rates are comparable to human players themselves. These are usable algorithms to create an engaging game play experience for a wide variety of practical applications.

Summary statement

I designed a computer program to model the game of Connect Four and to be a worthy opponent against humans using several heuristic algorithms.

Help received

Father helped understand and learn JavaScript language and debugging

Awards (1)

Competition history

  • CSEF 2014 Mathematics & Software · Entry J1417

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