<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://sourceforge.net/p/sconvolt/wiki/Home/</link><description>Recent changes to Home</description><atom:link href="https://sourceforge.net/p/sconvolt/wiki/Home/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 29 Dec 2014 21:00:32 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/sconvolt/wiki/Home/feed" rel="self" type="application/rss+xml"/><item><title>Home modified by Orest</title><link>https://sourceforge.net/p/sconvolt/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,5 +1,6 @@
-Design and specification of the program built to solve the problem
-“sconvolt” is the name of the program created for this work, it is built using c/c++ (GNU GCC compiler is used to compile it), the graphical part uses the A.L.L.E.G.R.O programming libraries, a set of open source libraries used to simplify programming of graphics, the program is cross-platform and currently compiles and runs on Windows and Linux platforms (tested on windows xp, vista, 7, Ubuntu) on the x86 architecture
+Sconvolt is a graphical user interface + a native chess engine
+
+It is built using C/C++ (GNU GCC compiler is used to compile it), the graphical part uses the A.L.L.E.G.R.O programming libraries, a set of open source libraries used for graphics, the program is cross-platform and currently compiles and runs on Windows and Linux platforms (tested on windows xp, vista, 7, 8, Ubuntu) on the x86 architecture

@@ -9,135 +10,11 @@

 “Board [8][8]” is a global variable, and the GUI uses it to display the corresponding values on the computer screen. The 2D array is kept as a global variable, and various functions take it as input or as parameter when computing calculations and making decisions about outputs. The engine is structured in memory as a set of functions that can manipulate the board state (the 2D array) and can return values that represent decisions.

-A Chess engine consists usually of 3 parts:

-– Move generator
- 
-– Search Function
- 
-– Position Evaluator
- 
-The utility of the move generator is to generate all possible moves given a current position of the board and a side to move, a Search Function looks at all possible moves and replies and finds the best continuation according to the Position Evaluator which gives scores to positions. The faster is the search function, the better the chess engine will play chess, and a good position evaluator again can improve drastically the way the program plays chess. Sconvolt has 2 search algorithms implemented, Minimax and Alpha-Beta Pruning, Minimax is a recursive algorithm that computes the value of successors in logical trees, the algorithm explores all the leaves of the tree given a required depth and when the bottom is reached it returns the scores, that can represent decisions as to what moves are better to do . The most popular approach to building chess engines is by using enhanced alpha beta pruning search algorithms [6], pruning allows us to ignore portions of the game search tree that make no difference to the final choice [6] , it returns the same score as Minimax would, but
- 
-eliminating the branches that cannot change the outcome of the value to be returned. Alpha beta takes as parameter 2 values, that are alpha and beta, representing the minimum and the maximum value, and keeps updating them during the exploration of the tree, when a branch that cannot influence any more the result is found it cuts it off saving time.
- 
-Alpha beta can be significantly faster than a Minimax search algorithm, and it relies its speed on the way the moves to examine are ordered, if the best moves are selected first the algorithm will largely benefit in terms of computational speed because larger parts of the tree are excluded from consideration.
+The Sconvolt engine uses alpha/beta pruning to "think" a number of moves ahead, If a perfect evaluation function existed, then no search depth would be needed, because the machine could tell mathematically what is the best move at any given position, this is the main reason chess engines tend to go as deep as possible in their search of possible moves, because the correctness of a score improves.

-If we assume the move generator generates the best moves first, and considering m as the depth of the tree to be searched, and b the legal moves at each point, the complexity results O( b m/2) differently from the complexity of the minimax, that is O(bm ), resulting that alpha beta can look ahead twice as far if the best moves are generated first [6]
-An evaluation function is vital for a computer chess program to play, because it is the machine's way to define if a position is good or bad. Since such measure cannot be taken perfectly, a good evaluation function should be as close as possible to be able to communicate to the machine the rating of a move. If a perfect evaluation function existed, then no search depth would be needed, because the machine could tell mathematically what is the best move at any given position, this is the main reason strong chess engines tend to go as deep as possible in their search of possible moves, because the correctness of a score improves.
- 
- 
- 
-The engine
-As mentioned above, the most important data in the chess program is the board, it is represented using a 2d array.
-int board[8][8] = {
-{-4,-3,-2,-5,-6,-2,-3,-4},
-{-1,-1,-1,-1,-1,-1,-1,-1},
-{ 0, 0, 0, 0, 0, 0, 0, 0},
-{ 0, 0, 0, 0, 0, 0, 0, 0},
-{ 0, 0, 0, 0, 0, 0, 0, 0},
-{ 0, 0, 0, 0, 0, 0, 0, 0},
-{ 1, 1, 1, 1, 1, 1, 1, 1},
-{ 4, 3, 2, 5, 6, 2, 3, 4}
-};
-A value of 0 represents empty square, while positive numbers represents squares occupied by white pieces, negative numbers represent squares occupied by black pieces, in this case its 1 for pawns, 2 for bishop, 3 for knight, 4 for rook, 5 for queen, 6 for kin, -1 for black pawn and so on.
-Sconvolt represents a move using 4 variables:
-static int j1,j2,j3,j4; //situated in Sconvolt.cpp
-j1 and j2 are the x and y coordinates on the board of the starting square, j3 and j4 are the x and y coordinates of the square where the pawn situated in [j1][j2] is situated
-Sconvolt does move one piece in the board using the following code:
-board[j3][j4]= board[j1][j2]; //situated in Sconvolt.cpp board[j1][j2] = 0;
-So transfer the content of the variable with coordinates j1, j2 (starting position) to the new square (j3,j4, ending position), now empty the starting position because the piece has moved. It doesn't matter if board[j3][j4] contains a negative number or a positive one (a black piece) because this 2 lines of code will be executed only in the case the move proposed is respecting the rules of chess, a function is created for this purpose.
-bool is_move_allowed(int sx, int sy, int ex, int ey, int pboard[][8]) //situated in engine.h
-{
-Is_Move_allowed, a function that returns true or false, takes as parameter sx, sy, ex, ey, and the board, the 4 integer variables again represent the starting point and the ending point required, given the board as parameter too, the function will do its computations and will return whether the move is allowed or not. This function is the core of the chess program, as it gives a shape to the search functions, because it defines the rules of chess in a logical way for the machine. Lets see in more detail an example of how it works internally
-if (pboard[sx][sy] == 0) return false; //if starting point is empty return false immediately
-if (sx == ex &amp;amp;&amp;amp; sy == ey) return false; //if starting point equals ending point return false immediately
-This piece of code is situated inside the is_move_allowed function, In the first case it is never allowed a move where the starting square is not owned by a piece, the second line checks the respective x and y coordinates of both starting and ending points, if they are the same then don't allow the move and return false.
-bool keep = true;
-The function makes large use of the boolean variable "keep" initialized to true, if one of the conditions will not be met, "keep" will turn false and the function will return false so the move is not allowed, the commodity of this variable is that the function will initially assume the move is allowed until a check finds out one or more rules of the chess have been broken, so turn it to false, keep will be returned at the end of the function if no returns are detected before that stage.
-if(pboard[sx][sy]==1) //check in case of white pawn {
-There will be an if condition for every different piece, because since in the game of chess rooks have different mobility options than bishops for example, even the program must understand those differences logically.
-Sx and sy are the x and y coordinates of the starting position, the condition is extracting the value contained in this position and its checking if its 1, so in this case if it is a white pawn.
-//allow moving 2 squares forward only if the sx is 6
-(so starting from its initial position) and the desired
-square is empty)
-if (sx == ex+2 &amp;amp;&amp;amp; pboard[ex][ey]==0 &amp;amp;&amp;amp; sx == 6 &amp;amp;&amp;amp; ey == sy) return true;
-This, for example, checks if the player is trying to move 2 squares ahead, a condition that is possible only if the pawn is in its original position and the arriving square is empty and ey==sy, the Y coordinates compared, they have to be the same because the pawn can move only forward, while the number of squares to move forward has to be +2, if all these conditions are accepted return true, allow move. This is an example of one of the checks the section of code if(pboard[sx][sy]==1) is doing before returning true.
-if (y1==y2 &amp;amp;&amp;amp; x1!=x2)
-{
-if (x1&amp;lt;x2) Black="" rook="" is="" moving="" right,="" so="" check="" if="" the="" -"road"="" is="" free,="" so="" if="" found="" any="" value="" different="" than="" 0="" the="" road="" to="" the="" destination="" is="" not="" free="" -{="" -for="" (int="" ji="sy+1;" ji&amp;lt;="ey;" ji++)="" {="" -="" cout&amp;lt;&amp;lt;"RIGHT:checking="" pboard["&amp;lt;&amp;lt;y1-1&amp;lt;&amp;lt;"]["&amp;lt;&amp;lt;ji&amp;lt;&amp;lt;"]="-"&amp;amp;lt;&amp;amp;lt;" pboard[y1-1][ji]&amp;lt;&amp;lt;endl;="" -if="" (pboard[y1-1][ji]=""&amp;gt;0 &amp;amp;&amp;amp; ji == ey ) {return true;} //allow capture only if the opponent is white and the rook is at its last move
-if (pboard[y1-1][ji]!=0) {return false;} //if != 0 it means theres something on the road, return false immediately
-}
-}
-This particular section of code, for example, is checking the case where the black rook is trying to move on the right, a for loop is required because all the squares have to be checked and have to be free in the squares between the starting square and the ending one. if (y1==y2 &amp;amp;&amp;amp; x1!=x2) is checking the direction x1,x2,y1,y2, 4 new variables have been introduced, they still represent starting and ending point but in a cross way, they have been used to better understand x and y positions on the 2d array related to the x and y position of the mouse given from allegro, the conversion in the GUI between mouse coordinates and array is done automatically,
-board[(mouse_y/(chessb_y/8))][(mouse_x/(chessb_x/8))];
-To explain this better, that line of code is the current value of a piece where the mouse is pointing,its the coordinate of the 2d array pointed by modified values of the mouse, where mouse_x and mouse_y are global variables given by allegro representing the mouse position, and chessb_x, chessb_y are the defined height and width in pixels of the screen
-Note: The graphical interface will initialize using chessb_x and chessb_y as coordinates to draw on the screen the board, so if the size of the board is changed the drag and drop functionality still works for the purpose of moving pieces on the screen.
-The function is_move_allowed keeps doing checks for all the type of pieces and returns the final bool resulting in the move being allowed or not.
- 
- 
- 
-//------------------
- 
-That's The General pseudo-code of the alpha beta pruning:
-int alphaBetaMax( int alpha, int beta, int depthleft ) { if ( depthleft == 0 ) return evaluate(); for ( all moves) { score = alphaBetaMin( alpha, beta, depthleft - 1 ); if( score &amp;gt;= beta ) return beta; // fail hard beta-cutoff
-if( score &amp;gt; alpha )
-alpha = score; // alpha acts like max in MiniMax
-} return alpha;
-}
-int alphaBetaMin( int alpha, int beta, int depthleft ) { if ( depthleft == 0 ) return -evaluate(); for ( all moves) { score = alphaBetaMax( alpha, beta, depthleft - 1 ); if( score &amp;lt;= alpha ) return alpha; // fail hard alpha-cutoff if( score &amp;lt; beta )
-beta = score; // beta acts like min in MiniMax
-} return beta;
-}
-Sconvolt follows this methodology, lets go in more detail to see the differences between the pseudo-code and the actual implementation of it. (the function Alpha beta pruning is contained in the file engine2.h)
-int lista[250]; int listb[250]; int listc[250]; int listd[250]; int n_moves = -1; int val = 0;
-4 arrays are being created, they are used for the purpose of memorizing the starting and ending positions of all the legal moves that will be found, the final number of n_moves will represent the number of moves that have been found, val is the score that will be extracted when the function will recall itself in the inverse manner.
-if (depth&amp;lt;=0) { return evaluate(bb);}
-This is the first check, if the reached depth is 0, it means we returned all values and we are in the root.
-for (int i = 0; i&amp;lt;=7 ; i++){ for (int j = 0; j&amp;lt;= 7 ; j++){ for (int i2 = 0; i2&amp;lt;=7; i2++){ for (int j2 = 0; j2&amp;lt;= 7; j2++){
-// counter++;
-if(bb[i][j]&amp;gt;0)
-if (is_move_allowed(i,j,i2,j2, bb)) {
-This is the code generator, kept very basic, 4 loops will go thorough all the board checking if
-the possible moves are allowed, and if they are
-n_moves++; lista[n_moves] = i; listb[n_moves] = j; listc[n_moves] = i2; listd[n_moves] = j2;
-increment the number of moves found and save them, the way the alpha beta works is kept open for future implementations.
-for (int k = 0; k &amp;lt;= n_moves; k++)
-{
-//MakeNextMove();
-temp = bb[listc[k]][listd[k]];
-bb[listc[k]][listd[k]] = bb[lista[k]][listb[k]]; bb[lista[k]][listb[k]] = 0;
-val = AlphaBetaMin(alpha, beta, depth - 1, bb, false);
-//UnmakeMove();
-bb[lista[k]][listb[k]] = bb[listc[k]][listd[k]]; bb[listc[k]][listd[k]] = temp;
-This is the core of the function, it loops all the legal moves that have been found, it tries each of them and it recalls itself giving as a parameter the modified board, after the val is being requested, undo the move.
-if (val &amp;gt;= beta) //if score &amp;gt;= beta then return beta
-{
-return beta; //beta cut off
-}
-if (val&amp;gt; alpha)
-{
-alpha = val;
-if (depth==user_depth &amp;amp;&amp;amp; sid==true) {
-j1 = lista[k]; j2 = listb[k]; j3 = listc[k]; j4 = listd[k];
-}
-// cout&amp;lt;&amp;lt;"found a better move, depth reached:"&amp;lt;&amp;lt;depth&amp;lt;&amp;lt;endl; -}="" -Alpha="" and="" beta="" are="" constantly="" being="" updated="" to="" cut="" branches="" of="" the="" tree="" that="" can="" not="" possibly="" affect="" the="" final="" result,="" j1,j2,j3,j4,="" the="" 4="" global="" variables="" used="" to="" represent="" a="" move,="" will="" be="" update="" if="" a="" better="" move="" is="" found,="" but="" only="" if="" we="" are="" in="" the="" root="" position,="" that="" means="" restrict="" the="" update="" to="" only="" the="" moves="" that="" can="" be="" done="" from="" the="" starting="" position.="" -Alpha="" beta="" has="" shown="" to="" be="" better="" than="" Minimax="" in="" terms="" of="" computational="" speed="" even="" if="" the="" move="" generator="" in="" this="" case="" generates="" moves="" in="" a="" random="" manner.="" -The="" GUI="" -From="" the="" programming="" point="" of="" view,="" the="" GUI="" is="" situated="" in="" the="" file="" “Sconvolt.cpp”,="" it="" is="" mostly="" composed="" of="" allegro="" commands="" and="" it="" creates="" a="" for="" loop="" constantly="" updating="" the="" current="" state="" of="" the="" board="" draw_sprite(buffer,="" five,="" 800="" ,="" 70);="" -This,="" for="" example,="" is="" a="" command="" used="" to="" draw="" images="" on="" the="" buffer="" (that="" will="" be="" drawn="" on="" the="" screen).="" -Mouse="" events="" routines="" such="" as="" drag,="" release="" mouse="" are="" used="" to="" deal="" with="" the="" engine,="" and="" textprintf_ex="" is="" a="" function="" used="" to="" display="" text="" on="" the="" screen.="" -Results="" -In="" Its="" standard="" configuration,="" the="" program="" is="" able="" to="" think="" 6="" moves="" ahead,="" and="" the="" evaluation="" function="" sums="" a="" material="" score="" with="" a="" positional="" score,="" the="" material="" score="" has="" been="" decided="" according="" to="" chess="" literature,="" it="" gives="" importance="" to="" the="" pieces="" in="" the="" following="" manner:="" +In="" Its="" standard="" configuration,="" the="" program="" is="" able="" to="" think="" 5="" moves="" ahead="" relatively="" fast="" (less="" than="" a="" second="" for="" depth="" 5),="" and="" the="" evaluation="" function="" sums="" a="" material="" score="" with="" a="" positional="" score,="" the="" material="" score="" has="" been="" decided="" according="" to="" chess="" literature,="" it="" gives="" importance="" to="" the="" pieces="" in="" the="" following="" manner:="" –="" Pawn="" equals="" 100="" –="" Bishop="" equals="" 325="" –="" Knight="" equals="" 320="" &amp;lt;="" pre=""&amp;gt;
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Orest</dc:creator><pubDate>Mon, 29 Dec 2014 21:00:32 -0000</pubDate><guid>https://sourceforge.net9df6dfce0ca7a69bd682efef2613dce37f0815af</guid></item><item><title>Home modified by Orest</title><link>https://sourceforge.net/p/sconvolt/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,8 +1,149 @@
-Welcome to your wiki!
-
-This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
-
-The wiki uses [Markdown](/p/sconvolt/wiki/markdown_syntax/) syntax.
-
-[[members limit=20]]
-[[download_button]]
+Design and specification of the program built to solve the problem
+“sconvolt” is the name of the program created for this work, it is built using c/c++ (GNU GCC compiler is used to compile it), the graphical part uses the A.L.L.E.G.R.O programming libraries, a set of open source libraries used to simplify programming of graphics, the program is cross-platform and currently compiles and runs on Windows and Linux platforms (tested on windows xp, vista, 7, Ubuntu) on the x86 architecture
+ 
+ 
+ 
+The Engine
+ 
+Sconvolt represents the current board state using a 2 dimensional array of size 8.
+ 
+“Board [8][8]” is a global variable, and the GUI uses it to display the corresponding values on the computer screen. The 2D array is kept as a global variable, and various functions take it as input or as parameter when computing calculations and making decisions about outputs. The engine is structured in memory as a set of functions that can manipulate the board state (the 2D array) and can return values that represent decisions.
+ 
+A Chess engine consists usually of 3 parts:
+ 
+– Move generator
+ 
+– Search Function
+ 
+– Position Evaluator
+ 
+The utility of the move generator is to generate all possible moves given a current position of the board and a side to move, a Search Function looks at all possible moves and replies and finds the best continuation according to the Position Evaluator which gives scores to positions. The faster is the search function, the better the chess engine will play chess, and a good position evaluator again can improve drastically the way the program plays chess. Sconvolt has 2 search algorithms implemented, Minimax and Alpha-Beta Pruning, Minimax is a recursive algorithm that computes the value of successors in logical trees, the algorithm explores all the leaves of the tree given a required depth and when the bottom is reached it returns the scores, that can represent decisions as to what moves are better to do . The most popular approach to building chess engines is by using enhanced alpha beta pruning search algorithms [6], pruning allows us to ignore portions of the game search tree that make no difference to the final choice [6] , it returns the same score as Minimax would, but
+ 
+eliminating the branches that cannot change the outcome of the value to be returned. Alpha beta takes as parameter 2 values, that are alpha and beta, representing the minimum and the maximum value, and keeps updating them during the exploration of the tree, when a branch that cannot influence any more the result is found it cuts it off saving time.
+ 
+Alpha beta can be significantly faster than a Minimax search algorithm, and it relies its speed on the way the moves to examine are ordered, if the best moves are selected first the algorithm will largely benefit in terms of computational speed because larger parts of the tree are excluded from consideration.
+ 
+ 
+If we assume the move generator generates the best moves first, and considering m as the depth of the tree to be searched, and b the legal moves at each point, the complexity results O( b m/2) differently from the complexity of the minimax, that is O(bm ), resulting that alpha beta can look ahead twice as far if the best moves are generated first [6]
+An evaluation function is vital for a computer chess program to play, because it is the machine's way to define if a position is good or bad. Since such measure cannot be taken perfectly, a good evaluation function should be as close as possible to be able to communicate to the machine the rating of a move. If a perfect evaluation function existed, then no search depth would be needed, because the machine could tell mathematically what is the best move at any given position, this is the main reason strong chess engines tend to go as deep as possible in their search of possible moves, because the correctness of a score improves.
+ 
+ 
+ 
+The engine
+As mentioned above, the most important data in the chess program is the board, it is represented using a 2d array.
+int board[8][8] = {
+{-4,-3,-2,-5,-6,-2,-3,-4},
+{-1,-1,-1,-1,-1,-1,-1,-1},
+{ 0, 0, 0, 0, 0, 0, 0, 0},
+{ 0, 0, 0, 0, 0, 0, 0, 0},
+{ 0, 0, 0, 0, 0, 0, 0, 0},
+{ 0, 0, 0, 0, 0, 0, 0, 0},
+{ 1, 1, 1, 1, 1, 1, 1, 1},
+{ 4, 3, 2, 5, 6, 2, 3, 4}
+};
+A value of 0 represents empty square, while positive numbers represents squares occupied by white pieces, negative numbers represent squares occupied by black pieces, in this case its 1 for pawns, 2 for bishop, 3 for knight, 4 for rook, 5 for queen, 6 for kin, -1 for black pawn and so on.
+Sconvolt represents a move using 4 variables:
+static int j1,j2,j3,j4; //situated in Sconvolt.cpp
+j1 and j2 are the x and y coordinates on the board of the starting square, j3 and j4 are the x and y coordinates of the square where the pawn situated in [j1][j2] is situated
+Sconvolt does move one piece in the board using the following code:
+board[j3][j4]= board[j1][j2]; //situated in Sconvolt.cpp board[j1][j2] = 0;
+So transfer the content of the variable with coordinates j1, j2 (starting position) to the new square (j3,j4, ending position), now empty the starting position because the piece has moved. It doesn't matter if board[j3][j4] contains a negative number or a positive one (a black piece) because this 2 lines of code will be executed only in the case the move proposed is respecting the rules of chess, a function is created for this purpose.
+bool is_move_allowed(int sx, int sy, int ex, int ey, int pboard[][8]) //situated in engine.h
+{
+Is_Move_allowed, a function that returns true or false, takes as parameter sx, sy, ex, ey, and the board, the 4 integer variables again represent the starting point and the ending point required, given the board as parameter too, the function will do its computations and will return whether the move is allowed or not. This function is the core of the chess program, as it gives a shape to the search functions, because it defines the rules of chess in a logical way for the machine. Lets see in more detail an example of how it works internally
+if (pboard[sx][sy] == 0) return false; //if starting point is empty return false immediately
+if (sx == ex &amp;&amp; sy == ey) return false; //if starting point equals ending point return false immediately
+This piece of code is situated inside the is_move_allowed function, In the first case it is never allowed a move where the starting square is not owned by a piece, the second line checks the respective x and y coordinates of both starting and ending points, if they are the same then don't allow the move and return false.
+bool keep = true;
+The function makes large use of the boolean variable "keep" initialized to true, if one of the conditions will not be met, "keep" will turn false and the function will return false so the move is not allowed, the commodity of this variable is that the function will initially assume the move is allowed until a check finds out one or more rules of the chess have been broken, so turn it to false, keep will be returned at the end of the function if no returns are detected before that stage.
+if(pboard[sx][sy]==1) //check in case of white pawn {
+There will be an if condition for every different piece, because since in the game of chess rooks have different mobility options than bishops for example, even the program must understand those differences logically.
+Sx and sy are the x and y coordinates of the starting position, the condition is extracting the value contained in this position and its checking if its 1, so in this case if it is a white pawn.
+//allow moving 2 squares forward only if the sx is 6
+(so starting from its initial position) and the desired
+square is empty)
+if (sx == ex+2 &amp;&amp; pboard[ex][ey]==0 &amp;&amp; sx == 6 &amp;&amp; ey == sy) return true;
+This, for example, checks if the player is trying to move 2 squares ahead, a condition that is possible only if the pawn is in its original position and the arriving square is empty and ey==sy, the Y coordinates compared, they have to be the same because the pawn can move only forward, while the number of squares to move forward has to be +2, if all these conditions are accepted return true, allow move. This is an example of one of the checks the section of code if(pboard[sx][sy]==1) is doing before returning true.
+if (y1==y2 &amp;&amp; x1!=x2)
+{
+if (x1&lt;= ey; ji++) {
+//cout&lt;&lt;"RIGHT:checking pboard["&lt;&lt;&lt;"]["&lt;&lt;&lt;"] =
+"&lt;&lt; pboard[y1-1][ji]&lt;0 &amp;&amp; ji == ey ) {return true;} //allow capture only if the opponent is white and the rook is at its last move
+if (pboard[y1-1][ji]!=0) {return false;} //if != 0 it means theres something on the road, return false immediately
+}
+}
+This particular section of code, for example, is checking the case where the black rook is trying to move on the right, a for loop is required because all the squares have to be checked and have to be free in the squares between the starting square and the ending one. if (y1==y2 &amp;&amp; x1!=x2) is checking the direction x1,x2,y1,y2, 4 new variables have been introduced, they still represent starting and ending point but in a cross way, they have been used to better understand x and y positions on the 2d array related to the x and y position of the mouse given from allegro, the conversion in the GUI between mouse coordinates and array is done automatically,
+board[(mouse_y/(chessb_y/8))][(mouse_x/(chessb_x/8))];
+To explain this better, that line of code is the current value of a piece where the mouse is pointing,its the coordinate of the 2d array pointed by modified values of the mouse, where mouse_x and mouse_y are global variables given by allegro representing the mouse position, and chessb_x, chessb_y are the defined height and width in pixels of the screen
+Note: The graphical interface will initialize using chessb_x and chessb_y as coordinates to draw on the screen the board, so if the size of the board is changed the drag and drop functionality still works for the purpose of moving pieces on the screen.
+The function is_move_allowed keeps doing checks for all the type of pieces and returns the final bool resulting in the move being allowed or not.
+ 
+ 
+ 
+//------------------
+ 
+That's The General pseudo-code of the alpha beta pruning:
+int alphaBetaMax( int alpha, int beta, int depthleft ) { if ( depthleft == 0 ) return evaluate(); for ( all moves) { score = alphaBetaMin( alpha, beta, depthleft - 1 ); if( score &gt;= beta ) return beta; // fail hard beta-cutoff
+if( score &gt; alpha )
+alpha = score; // alpha acts like max in MiniMax
+} return alpha;
+}
+int alphaBetaMin( int alpha, int beta, int depthleft ) { if ( depthleft == 0 ) return -evaluate(); for ( all moves) { score = alphaBetaMax( alpha, beta, depthleft - 1 ); if( score &lt;= alpha ) return alpha; // fail hard alpha-cutoff if( score &lt; beta )
+beta = score; // beta acts like min in MiniMax
+} return beta;
+}
+Sconvolt follows this methodology, lets go in more detail to see the differences between the pseudo-code and the actual implementation of it. (the function Alpha beta pruning is contained in the file engine2.h)
+int lista[250]; int listb[250]; int listc[250]; int listd[250]; int n_moves = -1; int val = 0;
+4 arrays are being created, they are used for the purpose of memorizing the starting and ending positions of all the legal moves that will be found, the final number of n_moves will represent the number of moves that have been found, val is the score that will be extracted when the function will recall itself in the inverse manner.
+if (depth&lt;=0) { return evaluate(bb);}
+This is the first check, if the reached depth is 0, it means we returned all values and we are in the root.
+for (int i = 0; i&lt;=7 ; i++){ for (int j = 0; j&lt;= 7 ; j++){ for (int i2 = 0; i2&lt;=7; i2++){ for (int j2 = 0; j2&lt;= 7; j2++){
+// counter++;
+if(bb[i][j]&gt;0)
+if (is_move_allowed(i,j,i2,j2, bb)) {
+This is the code generator, kept very basic, 4 loops will go thorough all the board checking if
+the possible moves are allowed, and if they are
+n_moves++; lista[n_moves] = i; listb[n_moves] = j; listc[n_moves] = i2; listd[n_moves] = j2;
+increment the number of moves found and save them, the way the alpha beta works is kept open for future implementations.
+for (int k = 0; k &lt;= n_moves; k++)
+{
+//MakeNextMove();
+temp = bb[listc[k]][listd[k]];
+bb[listc[k]][listd[k]] = bb[lista[k]][listb[k]]; bb[lista[k]][listb[k]] = 0;
+val = AlphaBetaMin(alpha, beta, depth - 1, bb, false);
+//UnmakeMove();
+bb[lista[k]][listb[k]] = bb[listc[k]][listd[k]]; bb[listc[k]][listd[k]] = temp;
+This is the core of the function, it loops all the legal moves that have been found, it tries each of them and it recalls itself giving as a parameter the modified board, after the val is being requested, undo the move.
+if (val &gt;= beta) //if score &gt;= beta then return beta
+{
+return beta; //beta cut off
+}
+if (val&gt; alpha)
+{
+alpha = val;
+if (depth==user_depth &amp;&amp; sid==true) {
+j1 = lista[k]; j2 = listb[k]; j3 = listc[k]; j4 = listd[k];
+}
+// cout&lt;&lt;"found a better move, depth reached:"&lt;&lt;&lt;endl&gt;&lt;/endl&gt;&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Orest</dc:creator><pubDate>Wed, 21 May 2014 15:01:37 -0000</pubDate><guid>https://sourceforge.netfcc5fd66f78a2607b5d4930919360bf620d30023</guid></item><item><title>Home modified by Orest</title><link>https://sourceforge.net/p/sconvolt/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Welcome to your wiki!&lt;/p&gt;
&lt;p&gt;This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: &lt;span&gt;[SamplePage]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The wiki uses &lt;a class="" href="/p/sconvolt/wiki/markdown_syntax/"&gt;Markdown&lt;/a&gt; syntax.&lt;/p&gt;
&lt;p&gt;&lt;h6&gt;Project Members:&lt;/h6&gt;
&lt;ul class="md-users-list"&gt;
&lt;li&gt;&lt;a href="/u/ori553/"&gt;Orest&lt;/a&gt; (admin)&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;span class="download-button-537cbd89a02bb1128e32b9fb" style="margin-bottom: 1em; display: block;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Orest</dc:creator><pubDate>Wed, 21 May 2014 14:51:53 -0000</pubDate><guid>https://sourceforge.netab2987f1f86c0e15878ecfb19468e037f1532702</guid></item></channel></rss>