Forum > Third party

Mater, mate searching program by Valentin Albillo

(1/2) > >>

Roland57:
Hello!

Some years ago, I discovered an interesting program by Valentin Albillo, a simple but efficient mate searching program, written for Turbo Pascal.

I started to study it, and made some little modifications (like turning the program into unit, removing the dependency to Dos unit).

Here you can find the original source code and its documentation (which were no longer available), and the new version.

https://gitlab.com/rchastain/mater

Problem of the day: White plays and mates in three moves.  :)

Regards.

Roland

Roland57:
Hello! A new version of the program is available.

A little but important error has been fixed (in pawn move generation).

Mater for Free Pascal

Roland57:
The program solves 150 000 mate-in-two-moves problems in three seconds, which doesn't looks too bad.  :)


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// timetest.pas (*  Reads a large FEN file and tries to solve all the positions, without  printing the result, but only the number of positions solved and the  time elapsed.*) uses  SysUtils, Classes, MaterCore; const  CDefaultFile = '155078mi2.fen';{  El Arte del Mate en Dos  Eduardo Sadier  https://sites.google.com/site/edusadier/home}  CDefaultDepth = 2;  var  LLst: TStringList;  LIdx, LCnt: integer;  LTime: cardinal;  LFile: string;  LDepth: integer;  begin  LFile := CDefaultFile;  LDepth := CDefaultDepth;    if (ParamCount > 0) and FileExists(ParamStr(1)) then LFile := ParamStr(1);  if (ParamCount > 1) then LDepth := StrToIntDef(ParamStr(2), CDefaultDepth);    LLst := TStringList.Create;  LLst.LoadFromFile(LFile);    LCnt := 0;  LTime := GetTickCount64;  for LIdx := 0 to Pred(LLst.Count) do    if Length(SolveMate(LLst[LIdx], LDepth, smAllMoves)) > 0 then      Inc(LCnt);    LTime := GetTickCount64 - LTime;  WriteLn('Time elapsed ', FormatDateTime('hh:nn:ss:zzz', LTime / (1000 * SECSPERDAY)));  WriteLn('Found ', LCnt, '/', LLst.Count);    LLst.Free;end. 
The positions in FEN format have been extracted from the PGN file available here, using the following little program.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// extractfen.pas (*  Detects and prints all FEN strings found in standard input.  ./extractfen < "Mate en Dos.pgn" > 155078mi2.fen*) uses  SysUtils, RegExpr; const{  Regular expressions for the six fields of a FEN string.  https://kirill-kryukov.com/chess/doc/fen.html}  P = '[1-8BKNPQRbknpqr]+'; // Piece placement (for one rank)  A = '[wb]';               // Active color  C = '([KQkq]+|\-)';       // Castling availability  E = '([a-h][36]|\-)';     // En passant target square  H = '\d+';                // Halfmove clock  F = '[1-9]\d*';           // Fullmove number var  LLine: string;  LExpr: TRegExpr;  LPattern: string;  begin  LPattern := Format('%s/%s/%s/%s/%s/%s/%s/%s', [P, P, P, P, P, P, P, P]);  LPattern := Format('%s %s %s %s %s %s', [LPattern, A, C, E, H, F]);  LExpr := TRegExpr.Create(LPattern);  while not Eof do  begin    ReadLn(LLine);    if (Length(LLine) > 0) and LExpr.Exec(LLine) then      WriteLn(LExpr.Match[0]);  end;  LExpr.Free;end. 

Roland57:

--- Quote from: Roland57 on November 09, 2021, 12:51:43 pm ---The program solves 150 000 mate-in-two-moves problems in three seconds, which doesn't looks too bad.  :)

--- End quote ---

No, absurd man. There was a horrible mistake in the test program. The program used to test always the same position.  :-[

Now the program solves the 150 000 positions in three... minutes.

By the way, I uploaded a simple GUI made with Lazarus. Please take a look at it and tell me what you think. It has been tested only under Linux. It shoud work also under Windows but maybe with something to retouch. Don't forget to compile Mater first.

avra:

--- Quote from: Roland57 on November 11, 2021, 09:15:39 pm ---I uploaded a simple GUI made with Lazarus.
--- End quote ---
I am much more familiar with your new Lazarus GUI look of chess figures, so I see it as an improvement. If you are open for suggestions, then it would be much nicer to be able to point and click to setup board problem start position - having only clipboard ASCII notation is not too friendly. I would also suggest change of current board font to something more readable (like ARIAL or similar).

Navigation

[0] Message Index

[#] Next page

Go to full version