#| README FILE FOR CONNECT5 Author: Dominique Shelton (0850681) Lab: Thurs 7pm Date Due: 12/19/01 |# #| I. Purpose of the Program: Given a board of the proper dimensions and content*, return a move that will advance the game in favor of X. (See http://www.owlnet.rice.edu/~comp210/Assignments/Connect5/connect5.html for details.) II. How to execute the Program: After pressing execute, paste a board of the proper dimensions and content into the interactions window. Press enter. III. Here is how the program works: I separately analyze each row, column, and relevent diagonal (relevent = at least 5 in length). I assign a number from 0 to 4000 to each empty cell, indicating the benefit to a particular side (O or X). A potential win gets 4000 points. I do this both from an O's and an X's perspective. Then, I overlay the row, column, and relevent diagonal scores for X (offensive) and for O (defensive). Rules for assigning points: This deals with pattern recognition. I first define a few patterns: How the section of board would look if move is made: WINNER 4000 ;XXXXX FOURFREE 690 ;-XXXX- THREEFREE 170 ;-XXX- FOUR1OPP 150 ;OXXXX- THREESPACE 150 ;-XX-X- FOUR1OPPSPACE 135 ;OX-XXX- TWOFREE 17 ;-XX- TWOSPACE 15 ;-X-X- THREE1OPP 13 ;OXXX- TWO1OPP 1 ;OXX- NONE .1 ;cell is of no significance MISC 3 ;just in case I missed something In order to recognize these patterns, I need to look at a row. For each empty cell, I analyze a vector containing four cells before and four cells after the empty cell (if they exist). I call this a chunk**. This way, I can analyze all possible strings of five resulting from that one empty cell. Then, I go through an insane amount of if's and cond's, to decide which pattern applies to that particular chunk. I get the maximum score both by analyzing the board from my perspective (offense) and my opponent's perspective (defense). If my maximum score is 4000, I automatically take it. Otherwise, I compare the offensive and defensive scores. If the defensive score is greater than or equal to a constant I set (called AGGRESIVENESS), I move into the corresponding cell. Otherwise, I move into the cell corresponding to the maximum offensive score. * See board definition in program code. ** Highly technical name. However, not as good as the cytochrome oxidase-rich dual-opponent columns of occipital cortex in the brain. They are called "blobs", seriously.