pente logic

posted 2/1/2004 9:32:12 AM by: timothy
basic rule set
  1. make five / capture to win
  2. block five
  3. make an open four (black capture to win)
  4. block open three
  5. make open three
  6. set up capture (or) work on a preset pattern (or) build two
  7. place random piece first couple of moves to set difficulty rating

computer player is @ ; human player is *
  1. if 8 captures, look for capture @**- else @@@@- or @@@-@ or @@-@@
  2. ****- or ***-* or **-**
  3. if opponend has 8 captures black *@@- else @@@- or @@-@
  4. ***- or **-*
  5. @@- or @-@ or maybe @-@-
    1. a) -**
    2. b) use pattern library to find closest match and place pieces within it
    3. c) @-
  6. random placement
  7. *@@@-

8 directional searching
pattern searching: 1-8

@**-	case 1	left to right

-**@	case 2	right to left

@	case 3	top to bottom
*
*
-

-	case 4	bottom to top
*
*
@

@	case 5	left to right
   *		top to bottom
     *
        -

-	case 6	left to right
  *		bottom to top
    *
      @

      @	case 7	right to left
    *		top to bottom
  *
-

       -	case 8	right to left
     *		bottom to top
   *
@

legend
black => *
red => @
space => -
pattern strings
**
@**-
@***-
@***-*
rules

first assign a 1 to every unoccupied space then search for ****@ or ***-*

set highest priority to block unless you have 8 captures and a capture is available or you can make 5 in a row.


basic patterns to search for:
	o
x	o
	o	o
	o	o	o
	o	o	o	o
	o	o	o	o	o
x	o	o
x	o	o	o
x	o	o	o	o
	o		o	o
x	o		o	o
	o		o	o	x

parser that takes strings such as

xxx 1xxx1

so that the priority of an intersection is increased

1 x x x 2 x x x 1

© 1999—2019 Timothy Lee Russell

vcard

View Timothy Russell's profile on LinkedIn

profile for Timothy Lee Russell at Stack Overflow, Q&A for professional and enthusiast programmers