Interactive Tic Tac Toe

Similar documents
The Interactive Visual Picross Solver (IVPS)

CSC 110 Lab 4 Algorithms using Functions. Names:

Number Plate recognition System

CPSC 217 Assignment 3 Due Date: Friday March 30, 2018 at 11:59pm

Taffy Tangle. cpsc 231 assignment #5. Due Dates

FACULTY MENTOR Khoshabeh, Ramsin. PROJECT TITLE PiB: Learning Python

EXPLORING TIC-TAC-TOE VARIANTS

Unit 12: Artificial Intelligence CS 101, Fall 2018

Training a Neural Network for Checkers

Embedded Systems Lab

Introduction to ABB Labs. TA s: Ryan Mocadlo Adam Gatehouse

ENHANCING THE PERFORMANCE OF DISTANCE PROTECTION RELAYS UNDER PRACTICAL OPERATING CONDITIONS


Intro to Java Programming Project

AN EFFICIENT APPROACH FOR VISION INSPECTION OF IC CHIPS LIEW KOK WAH

Tic-Tac-Toe and machine learning. David Holmstedt Davho G43

Seam position detection in pulsed gas metal arc welding

Tic-tac-toe. Lars-Henrik Eriksson. Functional Programming 1. Original presentation by Tjark Weber. Lars-Henrik Eriksson (UU) Tic-tac-toe 1 / 23

STRESS DETECTION USING GALVANIC SKIN RESPONSE SHAHNAZ SAKINAH BINTI SHAIFUL BAHRI UNIVERSITI MALAYSIA PAHANG

Lab 7: 3D Tic-Tac-Toe

Automatic Electricity Meter Reading Based on Image Processing

Coin Cappers. Tic Tac Toe

AN APPROACH TO ONLINE ANONYMOUS ELECTRONIC CASH. Li Ying. A thesis submitted in partial fulfillment of the requirements for the degree of

Lane Detection in Automotive

Revised Curriculum for Bachelor of Computer Science & Engineering, 2011

Training Neural Networks for Checkers

CS 4700: Foundations of Artificial Intelligence

Full Contents. Survey V8.08 Essentials

ARDUINO BASED WATER LEVEL MONITOR- ING AND CONTROL VIA CAN BUS TUAN ABU BAKAR BIN TUAN ISMAIL UNIVERSITI MALAYSIA PAHANG

CONTENTS FOREWORD... VII ACKNOWLEDGMENTS... IX CONTENTS... XI LIST OF FIGURES... XVII LIST OF TABLES... XIX LIST OF ABBREVIATIONS...

SMALL OFFICE TUTORIAL

GENERALIZATION: RANK ORDER FILTERS

AI Approaches to Ultimate Tic-Tac-Toe

Game Variations: Ultimate Tic Tac Toe

Hierarchical Controller for Robotic Soccer

Technical Note. How to Use the Image Studio Software Western and MPX Western Analyses. Developed for: Image Studio Software

Deep Green. System for real-time tracking and playing the board game Reversi. Final Project Submitted by: Nadav Erell

THE DEVELOPMENT OF INTENSITY DURATION FREQUENCY CURVES FITTING CONSTANT AT KUANTAN RIVER BASIN

Arrays. Independent Part. Contents. Programming with Java Module 3. 1 Bowling Introduction Task Intermediate steps...

INTELLIGENT HOME AUTOMATION SYSTEM (IHAS) WITH SECURITY PROTECTION NEO CHAN LOONG UNIVERSITI MALAYSIA PAHANG

NURIKABE. Mason Salisbury, Josh Smith, and Diyalo Manral

Full Contents. Essentials, Workbook

For our EC331 project we successfully designed and implemented a PIC based Tic-Tac-Toe game using the PIC16874.

Contents Technical background II. RUMBA technical specifications III. Hardware connection IV. Set-up of the instrument Laboratory set-up

Game Boards for Various Strategy Games

APPLICATION NOTE FOR PA.700A ANTENNA INTEGRATION

SEM Training Notebook

Lane Detection in Automotive

Graphics packages can be bit-mapped or vector. Both types of packages store graphics in a different way.

This game can be played in a 3x3 grid (shown in the figure 2.1).The game can be played by two players. There are two options for players:

Contents. Notes on the use of this publication

An Artificial Intelligence System for Monitoring and Security for Vehicular Plate Number in Lyceum of the Philippines University Laguna

SCRABBLE ARTIFICIAL INTELLIGENCE GAME. CS 297 Report. Presented to. Dr. Chris Pollett. Department of Computer Science. San Jose State University

Name: 1. Match the word with the definition (1 point each - no partial credit!)

Connect Four Emulator

ANCIENT GAME REVIEW HISTORY OF VIDEO GAMES MR. GALLERY

Automatically Generating Puzzle Problems with Varying Complexity

Math 152: Applicable Mathematics and Computing

CONTENTS CHAPTER 1 WHAT THIS IS ALL ABOUT...

TABLE OF CONTENTS CHAPTER TITLE PAGE

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four 1

Legend. The Red Goal. The. Blue. Goal

Copies of the Color by Pixel template sheets (included in the Resources section). Colored pencils, crayons, markers, or other supplies for coloring.

1. SALIENT FEATURES OF THE DIPLOMA PROGRAMME IN MECHANICAL ENGINEERING (TOOL AND DIE)

VALVE CONDITION MONITORING BY USING ACOUSTIC EMISSION TECHNIQUE MOHD KHAIRUL NAJMIE BIN MOHD NOR BACHELOR OF ENGINEERING UNIVERSITI MALAYSIA PAHANG

The Mathematics of Playing Tic Tac Toe

Chapter Two: The GamePlan Software *

Real-time FPGA realization of an UWB transceiver physical layer

Proximity Matrix and Its Applications. Li Jinbo. Master of Science in Software Engineering

QUALITY CHECKING AND INSPECTION BASED ON MACHINE VISION TECHNIQUE TO DETERMINE TOLERANCEVALUE USING SINGLE CERAMIC CUP

Maximum-Gain Radial Ground Systems for Vertical Antennas

Robust Hand Gesture Recognition for Robotic Hand Control

TEMPORAL DIFFERENCE LEARNING IN CHINESE CHESS

Slitherlink. Supervisor: David Rydeheard. Date: 06/05/10. The University of Manchester. School of Computer Science. B.Sc.(Hons) Computer Science

Simulation of a mobile robot navigation system

Real-Time Connect 4 Game Using Artificial Intelligence

Investigation of data reporting techniques and analysis of continuous power quality data in the Vector distribution network

Preprocessing and Segregating Offline Gujarati Handwritten Datasheet for Character Recognition

NEVADA GOOD SAMS GAME RULES Revised September 2015

Announcing the 2018 International Games SIG Classic Game Showcase

Documentation and Discussion

Planning of the implementation of public policy: a case study of the Board of Studies, N.S.W.

Creating a VEX IQ Event in Tournament Manager (TM)

Tac Due: Sep. 26, 2012

The Principles Of A.I Alphago

INDIAN VEHICLE LICENSE PLATE EXTRACTION AND SEGMENTATION

The game of Reversi was invented around 1880 by two. Englishmen, Lewis Waterman and John W. Mollett. It later became

Let s Make. Math Fun. Volume 19 January/February Dice Challenges. Telling the Time. Printable Games. Mastering Multiplication.

Determining the Cost Function In Tic-Tac-Toe puzzle game by Using Branch and Bound Algorithm

Contents. Foreword. Using this Guide

Introduction to Artificial Intelligence CS 151 Programming Assignment 2 Mancala!! Due (in dropbox) Tuesday, September 23, 9:34am

Connect 4. Figure 1. Top level simplified block diagram.

For slightly more detailed instructions on how to play, visit:

6. True or false? Shapes that have no right angles also have no perpendicular segments. Draw some figures to help explain your thinking.

Year 11 Graphing Notes

Game Playing in Prolog

Virtual Furniture Using Augmented Reality

UNIVERSITI TEKNOLOGI MARA IDENTIFYING AND DETECTING UNLAWFUL BEHAVIOR IN VIDEO IMAGES USING GENETIC ALGORITHM

Free Crochet Pattern Lion Brand Off The Hook Milo Blanket Pattern Number: L80261 Designed by Kaz

Thesis: Bio-Inspired Vision Model Implementation In Compressed Surveillance Videos by. Saman Poursoltan. Thesis submitted for the degree of

Transcription:

Interactive Tic Tac Toe Stefan Bennie Botha Thesis presented in fulfilment of the requirements for the degree of Honours of Computer Science at the University of the Western Cape Supervisor: Mehrdad Ghaziasgar Co-supervisor: Reg Dodds April 2016

ii

Declaration I, Stefan Bennie Botha, declare that this thesis Interactive Tic Tac Toe is my own work, that it has not been submitted before for any degree or assessment at any other university, and that all the sources I have used or quoted have been indicated and acknowledged by means of complete references. Signature:........................ Date:........................ Stefan Bennie Botha. iii

iv

Abstract The game tic tac toe had an early variant which began in the first century in the Roman Empire. During that time it was called Terni Lapilli where the players only had three pieces and had to move around the empty spaces to play. The actual game of tic tac toe could be traced back to ancient Egypt. The game was also known during that time as Three Men s Morris. The first reference to Noughts and crosses was made in 1864 in a British novel called Can You Forgive Her. For many years the game was referred to as noughts and crosses but was changed in the 20th century by the United States to tic tac toe. This paper will consist of a user requirements document as well as a requirements analysis document. The pupose of this paper is to create a program by which the user can play a game of tic-tac-toe using a sheet of paper as well a pen. The program will pick up the changes on the sheet of paper and superimpose its move on the screen showing the user which move was made. Various requirements will be handled in this paper with the help of one image to explain effectively what is happening. This project is designed purely for the sake of interest sake and thus has no real need at this current point. v

vi

Key words Support Vector Machine Visual Programming Graphical User Interface Requirements Analysis Document User Requirements Document vii

viii

Acknowledgment I would like to thank my supervisor Mr. G Ghazi as well as my co-supervisor Mr. R Dodds for their assistance with designing my project. Their help and support was really appreciated immensely and I would not be where I am today without their help. ix

x

Contents Declaration................................. Abstract................................... Key words.................................. Acknowledgment.............................. iii v vii ix List of Figures............................... xiii Glossary................................... xv 1. User Requirements Document................... 1 1.1 Introduction............................. 1 1.2 User s view of the problem..................... 1 1.2.1 Requirements expected from program............... 2 1.2.2 Requirements not expected from the solution.......... 2 2. Requirements Analysis Document................. 5 2.1 Introduction............................. 5 2.1.1 Designer s perspective....................... 5 2.1.2 Existing solutions.......................... 6 2.1.2.1 First Solution............................ 6 2.1.2.2 Second Solution........................... 7 2.1.2.3 Third Solution........................... 7 2.1.3 Best solution............................ 8 2.1.4 Testing............................... 8 3. Conclusion............................. 11 Bibliography................................ 12 xi

xii

List of Figures 1.1 Interactive Tic Tac Toe Representation.............. 3 xiii

xiv

Glossary SVM Support Vector Machine. RAD Requirements Analysis Document. URD User Requirements Document. CSV Comma separated variables. OpenCV Library used in Python for image processing. RASAC Random Sample Consensus. Custom Library designed and used in research paper. SURF Speeded Up Robust Features. Custom created method used in research paper. xv

xvi

Chapter 1 User Requirements Document 1.1 Introduction The user requirements document (URD) serves as a description of the user. It explains how the user sees the project by explaining it in a non- technical form. The URD will cover topics such as: the user s view of the problem, what is expected in the software solution and what is not expected. The first topic that will be discussed will be the user s view of the problem. This section will explain what the user wants to be implemented. Topics such as the requirements expected from the project will be discussed as well as what is not required. The URD will serve as the main source of information regarding how to build/construct the project to meet the exact specifications of the user. 1.2 User s view of the problem A interactive tic-tac-toe program is needed where the player will be able to play against the computer by using a piece of paper and a web camera. The camera will be mounted facing the sheet of paper at all times in order to prevent confusing the program by introducing different angles. The player draws a grid on the paper which will serve as the game board for the current match. When the player makes their move on the paper, the program will pick up this change on the board and make its move by superimposing a image representing its move towards the user on the screen. The game will end when one of the players is considered a winner or when it is considered as a draw when all entries are filled with symbols. 1

2 1.2.1 Requirements expected from program This section will explain in bullet form a few expected requirements regarding what the program should do.the requirements regarding this project/program will be listed below: This game has to be able to run on most modern computers and also on any Windows or Linux system supporting the Python environment. The game should be user friendly. The game should be easy to set up. The external peripherals should not be expensive. It should be flexible and be able to work on any similar web cam to the one currently in use. 1.2.2 Requirements not expected from the solution This section will explain in bullet form a few expected requirements regarding what the program should not do.what is not expected from the solution will follow below: The program should not be able to detect any other game on paper that is not related to tic-tac-toe. The game should not be slow and tedious to play. The program should not be complex to use. The game should never crash at any moment. The program is not expected to track games with the camera at a angle to the paper. The program is not expected to work under poor light conditions.

3 The figure below explains visually how the game will be played. Starting from the left side the computer will display the tic-tac-toe grid on the screen. Following the arrow the web cam will proceed to pick up the grid or any changes made withing the grid. The next arrow represents the move the player made on the sheet of paper. Lastly the change is picked up by the program and its move is made by superimposing a image representing their symbol on the screen. This cycle is repeating until a winner emerges or a draw occurs. Figure 1.1: Interactive Tic Tac Toe Representation

4

Chapter 2 Requirements Analysis Document 2.1 Introduction The requirement analysis document (RAD) explains how the program will work in more detail. In this document there will be various sections and subsections explaining what this program will consist of. This document will consist of a designers perspective, the identifying of existing solutions, deciding the best current solution and various ways to test the solution. The designer s will explain the requirements needed regarding how this program will be implemented. 2.1.1 Designer s perspective This section will discuss what needs to be done from the designer s perspective. This section also consists of possible attributes which will be considered when designing the program. The program will consist of a web camera picking up a drawn tic tac toe board on a clean piece of paper. The program should detect the board on the sheet of paper and notify the player that the game has begun. The game will continue to be played until all the white space inside the board is filled by a symbol or when three identical symbols are detected in a vertical, horizontal or diagonal line. The following bullet points represented below will provide more detail concerning this project. A mounted hi-definition web camera will be used,facing the sheet of paper, to ensure that a clear picture is provided to the user. A normal desktop computer will be used in order to create this program. 5

6 This program/game will be played strictly indoors to limit any changes in light affecting the program. The program will be written in the Python programming language using the OpenCV library. The OpenCV library will handle the image processing needed by this project. The board and the symbols will be converted into grayscale to eliminate the factor of which colours are used for the symbol or board. A Support Vector Machine (SVM) will be used to train the program on how to recognize different symbols as well as picking up the grid. The information given above demands the player to play in a controlled environment to ensure that the program will not crash or exit unexpectedly. 2.1.2 Existing solutions This section will cover different possible solutions which could be implemented in order to solve the problem. In each subsection, a different solution will be described in high-level which could provide some oversight as to what needs to be done. 2.1.2.1 First Solution A possible solution was created by Maguire and Saltzman (Joe Maguire, 2014) where by they implemented this project successfully by doing the following. They started by breaking down their algorithm into three parts: Acquiring the homography,in other words the board; detecting if the player moved and updating the projected board. To acquire the board they processes the current frame using the Speeded Up Robust Features (SURF) algorithm. They wanted to take advantage of the fact that the board consisted of four lines initially, but it turned out to be picking up too much noise as the camera was moving further away from the board. The SURF algorithm worked exceptionally well since it was able to pick up key points, which are the edges of the board very well when a marker was used to draw the board. To discard false key points they used the Random

7 Sample Consensus (RASAC) feature. In order to pick up the symbols they used a OpenCV function called matchtemplate which was used after they took the nine subsections of the board, each corresponding where the player could potentially draw a symbol. To update the board they created an artificial intelligence agent called MinMax which detects any movement on the board between 5 10 frames per second. This method turned out to be robust since the camera had to mounted close to the board but it still did the job. In other words template matching was used to locate the grid effectively. 2.1.2.2 Second Solution Another solution could be to read in images instead of a real-time feed from the web camera. The pictures would then eliminate the factor of the player s hand coming into play. The program can be considered as much simpler to create and also eliminates a fair amount of problems that can occur. The picture can then be converted into grayscale which eliminates the variety of colours the player might use. After the conversion, a histogram can be used to detect any non-white pixels on the board which could potentially be the lines of the board. The use of morphological operations can also be applied to reduce the amount of noise found in the images. This solution will be programmed in Python using the OpenCV library. A artificial intelligence agent will need to be created which will play against the user. The program will also require some training to detect what each symbol as well as what the board will look like. A decision will then be made by the program whether the game has started according to what player has drawn on the page. 2.1.2.3 Third Solution This solution consists of using real-time Haar-cascades and other morphological operations. All tic tac toe boards have similar features which means by using Haar-cascades the same Haar-features will be used to detect every

8 board. By using morphological operation, the image can be cleaned up by removing any noise captured by the camera. This will, however demand more performance in order to be executed. The reason this would require more performance would be that thousands of Haar-Cascades will be applied to every real-time image. Other sections of this solution will be considered similar to the second solution mentioned above meaning that this solution will also require some training to be done as well as an artificial intelligence agent to be created. This solution will also be created in Python since it is an flexible and easy to understand programming language. 2.1.3 Best solution This section will discuss which solution is considered to be the most effective and easiest to implement. This section will also discuss some reasons as to why this solution is considered. All the above solutions are very promising to yield results, but the second solution seems like an effective solution to implement. The reason why this solution was chosen was not because it is easier to implement but it serves as an good starting point to serve a basic program towards the user. This solution, however could evolve in the future to meet all of the requirements set out by the user which allows this to serve as a prototype in the meantime. The fact that the image is converted into grayscale would also make the computations easier to calculate since the array elements for each picture is considerably less. Another reason why the second solution was chosen was because the Haar-Cascade is used for detecting faces which is not needed since this project does not detect faces but rather tic tac toe boards. 2.1.4 Testing This section will touch briefly on how one can test this program to make sure it is working effectively. The steps to testing will be listed in bullet form and will follow below. Compile the code and check if any errors occur.

9 Test if the board and symbols are recognized by the program. Test the web cam by taking example pictures and displaying them back to the screen. Test the tic tac toe algorithm. The above steps are general testing steps to ensure that the code is in working order and that it is ready to run as the program.

10

Chapter 3 Conclusion This tic tac toe project seems quite the interesting and challenging project to accomplish. By designing a RAD, to explaining logically how to meet the user s requirements mentioned in the URD, will indeed be helpful during project implementation. By discovering various solutions it shows that this project is in fact possible if not easy to create. The use of image processing, by using OpenCV, and its morphological operations will serve as a starting point to begin this project. 11

12

Bibliography Joe Maguire, D. S. (2014). Augmented reality tic-tac-toe. Technical report, Department of Electrical Engineering. 13