hex combinatorial search in game strategy by brandon risberg may 2006menlo school

11
Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006 Menlo School

Upload: earl-mcbride

Post on 26-Dec-2015

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Hex

Combinatorial Search in Game Strategy

by

Brandon Risberg

May 2006Menlo School

Page 2: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Background

• Where I got the idea:• I first got the idea for “Hex” when we played it

during an Algebra 2 class period with Mr. Squilante.

• I got the idea to make an artificial intelligence for the game when I went to see the “Mastering the Game” exhibit about computer chess at the Computer History Museum.

Page 3: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Introduction

• “Hex” is a board game defined by the mathematician Piet Hein

• It is a two player game played on a diagonal board.

Page 4: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Rules

• Both players trade off claiming “hexes” on the game board.

• The goal is to create a chain of hexes from your side to your other side.

Page 5: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Java Game Programming

• Used nested “Swing” components and graphics.

• Imported image files created in Photoshop.

• Used multiple threads to handle animation.

• Implemented a recursive method to detect a winning chain.

• Added help files and windows for ease of use.

• Created an opening splash dialog.

Page 6: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

A.I. Algorithms

• Mini-Max• Generate a move tree.

• Evaluate each position in tree.

• Select best move at each level:• Minimize score on opponent move.

• Maximize score on own move.

Page 7: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Example Search Tree

Page 8: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

A.I. Algorithms (con’t)

• Alpha – Beta pruning• Pruning branches of the search tree that will

yield less favorable results.

• Improves search speed; does not improve quality of moves.

• Heuristics or “Rules of Thumb”• Guidelines that will help constrain the search.

Page 9: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Examples of Heuristics

• In real life:• Menlo registrar must assign students to class

sections.• This is a complex search problem.• Heuristic: make the critical assignments first.

• Senior English sections (workshops) cannot be interchanged, so begin with these.

• Freshman English classes are interchangeable so do these last.

Page 10: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Examples of Heuristics

• In board games:• In chess, keeping your pieces in the center will

usually be a stronger position.• “A knight on the rim is dim”

• In Hex, a longer chain of connected hexes will usually be a stronger position.

• This logic is typically built into the static evaluator.

Page 11: Hex Combinatorial Search in Game Strategy by Brandon Risberg May 2006Menlo School

Care to try a game?