{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CutNotFail 5

# CutNotFail 5 - Tic-tac-toe Is the o-player forced to put o...

This preview shows pages 1–5. Sign up to view the full content.

Tic-tac-toe Is the o-player forced to put o in a particular position (is x-player threatening to win on its next move?) b(B1, B2, B3, B4, B5, B6, B7, B8, B9) represents the board For example: b(e,x,o, e,x,e, e,e,e) We can define line(B, X,Y,Z) to instantiate X,Y, Z to positions that make up a line: line( b(X,Y,Z, _,_,_, _,_,_), X,Y,Z). line( b(_,_,_, X,Y,Z, _,_,_), X,Y,Z). line( b(_,_,_, _,_,_, X,Y,Z), X,Y,Z). line( b(X,_,_, Y,_,_, Z,_,_), X,Y,Z). ... line( b(X,_,_, _,Y,_, _,_,Z), X,Y,Z). ... York University- CSE 3401- V. Movahedi 21 07_CutNotFail

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Tic-tac-toe (cont.) threatening(e, x, x). threatening(x, e, x). threatening(x, x, e). forced_move(Board) :- line(Board, X, Y, Z), threatening (X, Y, Z), ! . Generator: line(Board, X, Y, Z) generates possible lines Tester: threatening(X, Y, Z) checks if the line has a threatening pattern If the generated line is not threatening, backtracking occurs and another line is generated If threatening does not succeed on any line, “ forced_move ” will fail . If threatening succeeds, the “fence” will be crossed, therefore no backtracking (no more solutions, one is enough), and it is

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}