October 21, 2013 11:00 am

Tic-Tac-Toe

 
 
Simple Tic-Tac-Toe game against computer. AI is written by simple rules in
Prolog language (www.swi-prolog.org). 
Every move of the computer is done by specific rule according to importance. This is done by order of rules in the source code. Matrix is 10×10, computer is represented by ‘x’ symbol, user by ‘o’. The game is started by ‘start’ command. Every next move by ’tah([x,y])’ and computer plays by ’tahp’ command.
 

Objects for the rules

 

Horizontal

vod

vodorovne5_1([X,Y],[X1,Y],[X2,Y],[X3,Y],[X4,Y]) :- X1 is X+1, X2 is X+2, X3 is X+3, X4 is X+4.
vodorovne5_2([X1,Y],[X,Y],[X2,Y],[X3,Y],[X4,Y]) :- X1 is X-1, X2 is X+1, X3 is X+2, X4 is X+3.
vodorovne5_3([X1,Y],[X2,Y],[X,Y],[X3,Y],[X4,Y]) :- X1 is X-2, X2 is X-1, X3 is X+1, X4 is X+2.
vodorovne5_4([X1,Y],[X2,Y],[X3,Y],[X,Y],[X4,Y]) :- X1 is X-3, X2 is X-2, X3 is X-1, X4 is X+1.
vodorovne5_5([X1,Y],[X2,Y],[X3,Y],[X4,Y],[X,Y]) :- X1 is X-4, X2 is X-3, X3 is X-2, X4 is X-1.

 

Upright

zvislo

zvisle5_1([X,Y],[X,Y1],[X,Y2],[X,Y3],[X,Y4]) :- Y1 is Y+1, Y2 is Y+2,Y3 is Y+3, Y4 is Y+4.
zvisle5_2([X,Y1],[X,Y],[X,Y2],[X,Y3],[X,Y4]) :- Y1 is Y-1, Y2 is Y+1, Y3 is Y+2, Y4 is Y+3.
zvisle5_3([X,Y1],[X,Y2],[X,Y],[X,Y3],[X,Y4]) :- Y1 is Y-2, Y2 is Y-1, Y3 is Y+1, Y4 is Y+2.
zvisle5_4([X,Y1],[X,Y2],[X,Y3],[X,Y],[X,Y4]) :- Y1 is Y-3, Y2 is Y-2, Y3 is Y-1, Y4 is Y+1.
zvisle5_5([X,Y1],[X,Y2],[X,Y3],[X,Y4],[X,Y]) :- Y1 is Y-4, Y2 is Y-3, Y3 is Y-2, Y4 is Y-1.

Sidelong

sikmo1

sikmo2

sikmo1_1([X,Y],[X1,Y1],[X2,Y2],[X3,Y3],[X4,Y4]) :- X1 is X+1,Y1 is Y+1,X2 is X+2,Y2 is Y+2,X3 is X+3,Y3 is Y+3,X4 is X+4,Y4 is Y+4.
sikmo1_2([X1,Y1],[X,Y],[X2,Y2],[X3,Y3],[X4,Y4]) :- X1 is X-1,Y1 is Y-1,X2 is X+1,Y2 is Y+1,X3 is X+2,Y3 is Y+2,X4 is X+3,Y4 is Y+3.
sikmo1_3([X1,Y1],[X2,Y2],[X,Y],[X3,Y3],[X4,Y4]) :- X1 is X-2,Y1 is Y-2,X2 is X-1,Y2 is Y-1,X3 is X+1,Y3 is Y+1,X4 is X+2,Y4 is Y+2.
sikmo1_4([X1,Y1],[X2,Y2],[X3,Y3],[X,Y],[X4,Y4]) :- X1 is X-3,Y1 is Y-3,X2 is X-2,Y2 is Y-2,X3 is X-1,Y3 is Y-1,X4 is X+1,Y4 is Y+1.
sikmo1_5([X1,Y1],[X2,Y2],[X3,Y3],[X4,Y4],[X,Y]) :- X1 is X-4,Y1 is Y-4,X2 is X-3,Y2 is Y-3,X3 is X-2,Y3 is Y-2,X4 is X-1,Y4 is Y-1.

sikmo2_1([X,Y],[X1,Y1],[X2,Y2],[X3,Y3],[X4,Y4]) :- X1 is X-1,Y1 is Y+1,X2 is X-2,Y2 is Y+2,X3 is X-3,Y3 is Y+3,X4 is X-4,Y4 is Y+4.
sikmo2_2([X1,Y1],[X,Y],[X2,Y2],[X3,Y3],[X4,Y4]) :- X1 is X+1,Y1 is Y-1,X2 is X-1,Y2 is Y+1,X3 is X-2,Y3 is Y+2,X4 is X-3,Y4 is Y+3.
sikmo2_3([X1,Y1],[X2,Y2],[X,Y],[X3,Y3],[X4,Y4]) :- X1 is X+2,Y1 is Y-2,X2 is X+1,Y2 is Y-1,X3 is X-1,Y3 is Y+1,X4 is X-2,Y4 is Y+2.
sikmo2_4([X1,Y1],[X2,Y2],[X3,Y3],[X,Y],[X4,Y4]) :- X1 is X+3,Y1 is Y-3,X2 is X+2,Y2 is Y-2,X3 is X+1,Y3 is Y-1,X4 is X-1,Y4 is Y+1.
sikmo2_5([X1,Y1],[X2,Y2],[X3,Y3],[X4,Y4],[X,Y]) :- X1 is X+4,Y1 is Y-4,X2 is X+3,Y2 is Y-3,X3 is X+2,Y3 is Y-2,X4 is X+1,Y4 is Y-1.

Win/loss detection :

test :- p(S1,x),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	((p(S2,x), p(S3,x), p(S4,x), p(S5,x))),
	nl, write('VYHRA!!!'), nl ; true.
	
test :- p(S1,o),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	((p(S2,o), p(S3,o), p(S4,o), p(S5,o))),
	nl, write('PREHRA'), nl ; true.

 

Rules

In every move, we have to test if it’s possible to score or defending is necessary.

Situations

utok2x4

tahp :- p(S1,' '),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	((p(S2,x), p(S3,x), p(S4,x), p(S5,x));(p(S2,o), p(S3,o), p(S4,o), p(S5,o))),
	retract(p(S1,' ')), assert(p(S1,x)),
	write(S1), write(' pravidlo 1 - prva pozicia patice'), nl,vypis, test, nl.

tahp :- p(S2,' '),
	((vodorovne5_2(S1,S2,S3,S4,S5));(zvisle5_2(S1,S2,S3,S4,S5));(sikmo1_2(S1,S2,S3,S4,S5));(sikmo2_2(S1,S2,S3,S4,S5))),
	((p(S1,x), p(S3,x), p(S4,x), p(S5,x));(p(S1,o), p(S3,o), p(S4,o), p(S5,o))),
	retract(p(S2,' ')), assert(p(S2,x)),
	write(S2), write(' pravidlo 2 - druha pozicia patice'), nl,vypis, test, nl.

tahp :- p(S3,' '),
	((vodorovne5_3(S1,S2,S3,S4,S5));(zvisle5_3(S1,S2,S3,S4,S5));(sikmo1_3(S1,S2,S3,S4,S5));(sikmo2_3(S1,S2,S3,S4,S5))),
	((p(S1,x), p(S2,x), p(S4,x), p(S5,x));(p(S1,o), p(S2,o), p(S4,o), p(S5,o))),
	retract(p(S3,' ')), assert(p(S3,x)),
	write(S3), write(' pravidlo 3 - tretia pozicia patice'), nl,vypis, test, nl.

tahp :- p(S4,' '),
	((vodorovne5_4(S1,S2,S3,S4,S5));(zvisle5_4(S1,S2,S3,S4,S5));(sikmo1_4(S1,S2,S3,S4,S5));(sikmo2_4(S1,S2,S3,S4,S5))),
	((p(S1,x), p(S2,x), p(S3,x), p(S5,x));(p(S1,o), p(S2,o), p(S3,o), p(S5,o))),
	retract(p(S4,' ')), assert(p(S4,x)),
	write(S4), write(' pravidlo 4 - stvrta pozicia patice'), nl,vypis, test, nl.

tahp :- p(S5,' '),
	((vodorovne5_5(S1,S2,S3,S4,S5));(zvisle5_5(S1,S2,S3,S4,S5));(sikmo1_5(S1,S2,S3,S4,S5));(sikmo2_5(S1,S2,S3,S4,S5))),
	((p(S1,x), p(S2,x), p(S3,x), p(S4,x));(p(S1,o), p(S2,o), p(S3,o), p(S4,o))),
	retract(p(S5,' ')), assert(p(S5,x)),
	write(S5), write(' pravidlo 5 - piata pozicia patice'), nl,vypis, test, nl.


tahp :- p(S1,' '),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	(((p(S2,x), p(S3,x), p(S4,x), p(S5,' '));(p(S2,o), p(S3,o), p(S4,o), p(S5,' ')));
	((p(S2,x), p(S3,x), p(S4,' '), p(S5,x));(p(S2,o), p(S3,o), p(S4,' '), p(S5,o)));
	((p(S2,x), p(S3,' '), p(S4,x), p(S5,x));(p(S2,o), p(S3,' '), p(S4,o), p(S5,o)));
	((p(S2,' '), p(S3,x), p(S4,x), p(S5,x));(p(S2,' '), p(S3,o), p(S4,o), p(S5,o)))),
	retract(p(S1,' ')), assert(p(S1,x)),
	write(S1), write(' pravidlo 6 - prva pozicia stvorice'), nl,vypis, test, nl.

tahp :- p(S2,' '),
	((vodorovne5_2(S1,S2,S3,S4,S5));(zvisle5_2(S1,S2,S3,S4,S5));(sikmo1_2(S1,S2,S3,S4,S5));(sikmo2_2(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S3,x), p(S4,x), p(S5,' '));(p(S1,o), p(S3,o), p(S4,o), p(S5,' ')));
	((p(S1,x), p(S3,x), p(S4,' '), p(S5,x));(p(S1,o), p(S3,o), p(S4,' '), p(S5,o)));
	((p(S1,x), p(S3,' '), p(S4,x), p(S5,x));(p(S1,o), p(S3,' '), p(S4,o), p(S5,o)));
	((p(S1,' '), p(S3,x), p(S4,x), p(S5,x));(p(S1,' '), p(S3,o), p(S4,o), p(S5,o)))),
	retract(p(S2,' ')), assert(p(S2,x)),
	write(S2), write(' pravidlo 7 - druha pozicia stvorice'), nl,vypis, test, nl.

tahp :- p(S3,' '),
	((vodorovne5_3(S1,S2,S3,S4,S5));(zvisle5_3(S1,S2,S3,S4,S5));(sikmo1_3(S1,S2,S3,S4,S5));(sikmo2_3(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S4,x), p(S5,' '));(p(S1,o), p(S2,o), p(S4,o), p(S5,' ')));
	((p(S1,x), p(S2,x), p(S4,' '), p(S5,x));(p(S1,o), p(S2,o), p(S4,' '), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S4,x), p(S5,x));(p(S1,o), p(S2,' '), p(S4,o), p(S5,o)));
	((p(S1,' '), p(S2,x), p(S4,x), p(S5,x));(p(S1,' '), p(S2,o), p(S4,o), p(S5,o)))),
	retract(p(S3,' ')), assert(p(S3,x)),
	write(S3), write(' pravidlo 8 - tretia pozicia stvorice'), nl,vypis, test, nl.

tahp :- p(S4,' '),
	((vodorovne5_4(S1,S2,S3,S4,S5));(zvisle5_4(S1,S2,S3,S4,S5));(sikmo1_4(S1,S2,S3,S4,S5));(sikmo2_4(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S3,x), p(S5,' '));(p(S1,o), p(S2,o), p(S3,o), p(S5,' ')));
	((p(S1,x), p(S2,x), p(S3,' '), p(S5,x));(p(S1,o), p(S2,o), p(S3,' '), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S3,x), p(S5,x));(p(S1,o), p(S2,' '), p(S3,o), p(S5,o)));
	((p(S1,' '), p(S2,x), p(S3,x), p(S5,x));(p(S1,' '), p(S2,o), p(S3,o), p(S5,o)))),
	retract(p(S4,' ')), assert(p(S4,x)),
	write(S4), write(' pravidlo 9 - stvrta pozicia stvorice'), nl,vypis, test, nl.

tahp :- p(S5,' '),
	((vodorovne5_5(S1,S2,S3,S4,S5));(zvisle5_5(S1,S2,S3,S4,S5));(sikmo1_5(S1,S2,S3,S4,S5));(sikmo2_5(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S3,x), p(S4,' '));(p(S1,o), p(S2,o), p(S3,o), p(S4,' ')));
	((p(S1,x), p(S2,x), p(S3,' '), p(S4,x));(p(S1,o), p(S2,o), p(S3,' '), p(S4,o)));
	((p(S1,x), p(S2,' '), p(S3,x), p(S4,x));(p(S1,o), p(S2,' '), p(S3,o), p(S4,o)));
	((p(S1,' '), p(S2,x), p(S3,x), p(S4,x));(p(S1,' '), p(S2,o), p(S3,o), p(S4,o)))),
	retract(p(S5,' ')), assert(p(S5,x)),
	write(S5), write(' pravidlo 10 - piata pozicia stvorice'), nl,vypis, test, nl.
	
	
tahp :- p(S1,' '),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	(((p(S2,x), p(S3,x), p(S4,' '), p(S5,' '));(p(S2,o), p(S3,o), p(S4,' '), p(S5,' ')));
	((p(S2,' '), p(S3,' '), p(S4,x), p(S5,x));(p(S2,' '), p(S3,' '), p(S4,o), p(S5,o)));
	((p(S2,x), p(S3,' '), p(S4,x), p(S5,' '));(p(S2,o), p(S3,' '), p(S4,o), p(S5,' ')));
	((p(S2,' '), p(S3,x), p(S4,' '), p(S5,x));(p(S2,' '), p(S3,o), p(S4,' '), p(S5,o)));
	((p(S2,x), p(S3,' '), p(S4,' '), p(S5,x));(p(S2,o), p(S3,' '), p(S4,' '), p(S5,o)));
	((p(S2,' '), p(S3,x), p(S4,x), p(S5,' '));(p(S2,' '), p(S3,o), p(S4,o), p(S5,' ')))),
	retract(p(S1,' ')), assert(p(S1,x)),
	write(S1), write(' pravidlo 11 - prva pozicia trojice'), nl,vypis, test, nl.

tahp :- p(S2,' '),
	((vodorovne5_2(S1,S2,S3,S4,S5));(zvisle5_2(S1,S2,S3,S4,S5));(sikmo1_2(S1,S2,S3,S4,S5));(sikmo2_2(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S3,x), p(S4,' '), p(S5,' '));(p(S1,o), p(S3,o), p(S4,' '), p(S5,' ')));
	((p(S1,' '), p(S3,' '), p(S4,x), p(S5,x));(p(S1,' '), p(S3,' '), p(S4,o), p(S5,o)));
	((p(S1,x), p(S3,' '), p(S4,x), p(S5,' '));(p(S1,o), p(S3,' '), p(S4,o), p(S5,' ')));
	((p(S1,' '), p(S3,x), p(S4,' '), p(S5,x));(p(S1,' '), p(S3,o), p(S4,' '), p(S5,o)));
	((p(S1,x), p(S3,' '), p(S4,' '), p(S5,x));(p(S1,o), p(S3,' '), p(S4,' '), p(S5,o)));
	((p(S1,' '), p(S3,x), p(S4,x), p(S5,' '));(p(S1,' '), p(S3,o), p(S4,o), p(S5,' ')))),
	retract(p(S2,' ')), assert(p(S2,x)),
	write(S2), write(' pravidlo 12 - druha pozicia trojice'), nl,vypis, test, nl.

tahp :- p(S3,' '),
	((vodorovne5_3(S1,S2,S3,S4,S5));(zvisle5_3(S1,S2,S3,S4,S5));(sikmo1_3(S1,S2,S3,S4,S5));(sikmo2_3(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S4,' '), p(S5,' '));(p(S1,o), p(S2,o), p(S4,' '), p(S5,' ')));
	((p(S1,' '), p(S2,' '), p(S4,x), p(S5,x));(p(S1,' '), p(S2,' '), p(S4,o), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S4,x), p(S5,' '));(p(S1,o), p(S2,' '), p(S4,o), p(S5,' ')));
	((p(S1,' '), p(S2,x), p(S4,' '), p(S5,x));(p(S1,' '), p(S2,o), p(S4,' '), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S4,' '), p(S5,x));(p(S1,o), p(S2,' '), p(S4,' '), p(S5,o)));
	((p(S1,' '), p(S2,x), p(S4,x), p(S5,' '));(p(S1,' '), p(S2,o), p(S4,o), p(S5,' ')))),
	retract(p(S3,' ')), assert(p(S3,x)),
	write(S3), write(' pravidlo 13 - tretia pozicia trojice'), nl,vypis, test, nl.

tahp :- p(S4,' '),
	((vodorovne5_4(S1,S2,S3,S4,S5));(zvisle5_4(S1,S2,S3,S4,S5));(sikmo1_4(S1,S2,S3,S4,S5));(sikmo2_4(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S3,' '), p(S5,' '));(p(S1,o), p(S2,o), p(S3,' '), p(S5,' ')));
	((p(S1,' '), p(S2,' '), p(S3,x), p(S5,x));(p(S1,' '), p(S2,' '), p(S3,o), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S3,x), p(S5,' '));(p(S1,o), p(S2,' '), p(S3,o), p(S5,' ')));
	((p(S1,' '), p(S2,x), p(S3,' '), p(S5,x));(p(S1,' '), p(S2,o), p(S3,' '), p(S5,o)));
	((p(S1,x), p(S2,' '), p(S3,' '), p(S5,x));(p(S1,o), p(S2,' '), p(S3,' '), p(S5,o)));
	((p(S1,' '), p(S2,x), p(S3,x), p(S5,' '));(p(S1,' '), p(S2,o), p(S3,o), p(S5,' ')))),
	retract(p(S4,' ')), assert(p(S4,x)),
	write(S4), write(' pravidlo 14 - stvrta pozicia trojice'), nl,vypis, test, nl.

tahp :- p(S5,' '),
	((vodorovne5_5(S1,S2,S3,S4,S5));(zvisle5_5(S1,S2,S3,S4,S5));(sikmo1_5(S1,S2,S3,S4,S5));(sikmo2_5(S1,S2,S3,S4,S5))),
	(((p(S1,x), p(S2,x), p(S3,' '), p(S4,' '));(p(S1,o), p(S2,o), p(S3,' '), p(S4,' ')));
	((p(S1,' '), p(S2,' '), p(S3,x), p(S4,x));(p(S1,' '), p(S2,' '), p(S3,o), p(S4,o)));
	((p(S1,x), p(S2,' '), p(S3,x), p(S4,' '));(p(S1,o), p(S2,' '), p(S3,o), p(S4,' ')));
	((p(S1,' '), p(S2,x), p(S3,' '), p(S4,x));(p(S1,' '), p(S2,o), p(S3,' '), p(S4,o)));
	((p(S1,x), p(S2,' '), p(S3,' '), p(S4,x));(p(S1,o), p(S2,' '), p(S3,' '), p(S4,o)));
	((p(S1,' '), p(S2,x), p(S3,x), p(S4,' '));(p(S1,' '), p(S2,o), p(S3,o), p(S4,' ')))),
	retract(p(S5,' ')), assert(p(S5,x)),
	write(S5), write(' pravidlo 15 - piata pozicia trojice'), nl,vypis, test, nl.


tahp :- p(S1,' '),
	((vodorovne5_1(S1,S2,S3,S4,S5));(zvisle5_1(S1,S2,S3,S4,S5));(sikmo1_1(S1,S2,S3,S4,S5));(sikmo2_1(S1,S2,S3,S4,S5))),
	((p(S2,' '), p(S3,' '), p(S4,' '), p(S5,x));
	(p(S2,' '), p(S3,' '), p(S4,x), p(S5,' '));
	(p(S2,' '), p(S3,x), p(S4,' '), p(S5,' '));
	(p(S2,x), p(S3,' '), p(S4,' '), p(S5,' '))),
	retract(p(S1,' ')), assert(p(S1,x)),
	write(S1), write(' pravidlo 16 - prva pozicia dvojice'), nl,vypis, test, nl.

tahp :- p(S2,' '),
	((vodorovne5_2(S1,S2,S3,S4,S5));(zvisle5_2(S1,S2,S3,S4,S5));(sikmo1_2(S1,S2,S3,S4,S5));(sikmo2_2(S1,S2,S3,S4,S5))),
	((p(S1,' '), p(S3,' '), p(S4,' '), p(S5,x));
	(p(S1,' '), p(S3,' '), p(S4,x), p(S5,' '));
	(p(S1,' '), p(S3,x), p(S4,' '), p(S5,' '));
	(p(S1,x), p(S3,' '), p(S4,' '), p(S5,' '))),
	retract(p(S2,' ')), assert(p(S2,x)),
	write(S2), write(' pravidlo 17 - druha pozicia dvojice'), nl,vypis, test, nl.

tahp :- p(S3,' '),
	((vodorovne5_3(S1,S2,S3,S4,S5));(zvisle5_3(S1,S2,S3,S4,S5));(sikmo1_3(S1,S2,S3,S4,S5));(sikmo2_3(S1,S2,S3,S4,S5))),
	((p(S1,' '), p(S2,' '), p(S4,' '), p(S5,x));
	(p(S1,' '), p(S2,' '), p(S4,x), p(S5,' '));
	(p(S1,' '), p(S2,x), p(S4,' '), p(S5,' '));
	(p(S1,x), p(S2,' '), p(S4,' '), p(S5,' '))),
	retract(p(S3,' ')), assert(p(S3,x)),
	write(S3), write(' pravidlo 18 - tretia pozicia dvojice'), nl,vypis, test, nl.

tahp :- p(S4,' '),
	((vodorovne5_4(S1,S2,S3,S4,S5));(zvisle5_4(S1,S2,S3,S4,S5));(sikmo1_4(S1,S2,S3,S4,S5));(sikmo2_4(S1,S2,S3,S4,S5))),
	((p(S1,' '), p(S2,' '), p(S3,' '), p(S5,x));
	(p(S1,' '), p(S2,' '), p(S3,x), p(S5,' '));
	(p(S1,' '), p(S2,x), p(S3,' '), p(S5,' '));
	(p(S1,x), p(S2,' '), p(S3,' '), p(S5,' '))),
	retract(p(S4,' ')), assert(p(S4,x)),
	write(S4), write(' pravidlo 19 - stvrta pozicia dvojice'), nl,vypis, test, nl.

tahp :- p(S5,' '),
	((vodorovne5_5(S1,S2,S3,S4,S5));(zvisle5_5(S1,S2,S3,S4,S5));(sikmo1_5(S1,S2,S3,S4,S5));(sikmo2_5(S1,S2,S3,S4,S5))),
	((p(S1,' '), p(S2,' '), p(S3,' '), p(S4,x));
	(p(S1,' '), p(S2,' '), p(S3,x), p(S4,' '));
	(p(S1,' '), p(S2,x), p(S3,' '), p(S4,' '));
	(p(S1,x), p(S2,' '), p(S3,' '), p(S4,' '));
	(p(S1,o); p(S2,o); p(S3,o); p(S4,o))),
	retract(p(S5,' ')), assert(p(S5,x)),
	write(S5), write(' pravidlo 20 - piata pozicia dvojice, zachranne pravidlo'), nl,vypis, test, nl.

Download

Sourcecode pisk.pl

Tagy:

@cisary on twitter


Bitcoin, web applications, constraint processing, AI, soft-computing - evolution inspired algorithms, integration with the blockchain technology and more.    


Contact



Agile Software Development


cisary @ Github cisary @ Bitbutcket






Newest articles





Twitter & Delicious




  • New (beta) website