Chastity’s Chess Blog

  • Assembly Chaste Lib

    I have created two functions in x86 Assembly Language that allow me to output any zero terminated string or output any integer in any base from 2 to 36. I will show the full source so people can play with it. This uses system calls on Linux so it won’t work on Windows.

    first, the header file “chaste-lib.asm”

    ; This file is where I keep my function definitions.
    ; These are usually my string and integer output routines.
    
    putstring: ; function to print zero terminated string pointed to by register eax
    
    mov edx,eax ; copy eax to edx as well. Now both registers have the address of the main_string
    
    strlen_start: ; this loop finds the lenge of the string as part of the putstring function
    
    cmp [edx],byte 0 ; compare byte at address edx with 0
    jz strlen_end ; if comparison was zero, jump to loop end because we have found the length
    inc edx
    jmp strlen_start
    
    strlen_end:
    sub edx,eax ; edx will now have correct number of bytes when we use it for the system write call
    
    mov ecx,eax ; copy eax to ecx which must contain address of string to write
    mov eax, 4  ; invoke SYS_WRITE (kernel opcode 4)
    ;mov ebx, 1  ; ebx=1 means write to the STDOUT file
    int 80h     ; system call to write the message
    
    ret ; this is the end of the putstring function return to calling location
    
    
    
    
    
    
    radix dd 16 ;radix or base for integer output. 2=binary, 16=hexadecimal, 10=decimal
    
    putint: ; function to output decimal form of whatever integer is in eax
    
    push eax ;save eax on the stack to restore later
    
    mov ebp,int_string+31 ;address of start digits
    
    digits_start:
    
    mov edx,0;
    mov esi,[radix] ;radix is from memory location just before this function
    div esi
    cmp edx,10
    jb decimal_digit
    jge hexadecimal_digit
    
    decimal_digit: ;we go here if it is only a digit 0 to 9
    add edx,'0'
    jmp save_digit
    
    hexadecimal_digit:
    sub edx,10
    add edx,'A'
    
    
    save_digit:
    
    mov [ebp],dl
    cmp eax,0
    jz digits_end
    dec ebp
    jmp digits_start
    
    digits_end:
    
    mov eax,ebp ; now that the digits have been written to the string, display it!
    call putstring
    
    pop eax  ;load eax from the stack so it will be as it was before this function was called
    ret
    

    next, the main source that includes the header: “main.asm”

    format ELF executable
    entry main
    
    include 'chaste-lib.asm'
    
    main: ; the main function of our assembly function, just as if I were writing C.
    
    ; I can load any string address into eax and print it!
    
    mov ebx, 1 ;ebx must be 1 to write to standard output
    
    mov eax,msg
    call putstring
    mov eax,main_string ; move the address of main_string into eax register
    call putstring
    
    mov [radix],2 ; can choose radix for integer output!
    
    mov eax,0
    loop1:
    call putint
    inc eax
    cmp eax,100h;
    jnz loop1
    
    mov eax, 1  ; invoke SYS_EXIT (kernel opcode 1)
    mov ebx, 0  ; return 0 status on exit - 'No Errors'
    int 80h
    
    ; this is where I keep my string variables
    
    msg db 'Hello World!', 0Ah,0     ; assign msg variable with your message string
    main_string db "This is Chastity's Assembly Language counting program!",0Ah,0
    int_string db 32 dup '?',0Ah,0
    
    
    
    ; This Assembly source file has been formatted for the FASM assembler.
    ; The following 3 commands assemble, give executable permissions, and run the program
    ;
    ;	fasm main.asm
    ;	chmod +x main
    ;	./main
    
    

    If you have the fasm compiler, you can assemble this source on any Linux distribution running on an intel CPU. Assembly is platform specific but it runs really fast and the process of programming with it is enjoyable for me.

  • Assembly Language Counting Program

    I have been learning x86 assembly language. I know a little bit from years ago but now it is coming back to me. I formerly did 16 bit DOS hobby programs. This is 32 bit Linux programming in assembly using FASM as my assembler.

    format ELF executable
    entry main
    
    main: ; the main function of our assembly function, just as if I were writing C.
    
    ; I can load any string address into eax and print it!
    
    mov eax,msg
    call putstring
    mov eax,main_string ; move the address of main_string into eax register
    call putstring
    
    
    mov eax,0
    loop1:
    call putint
    inc eax
    cmp eax,16;
    jnz loop1
    
    mov eax, 1  ; invoke SYS_EXIT (kernel opcode 1)
    mov ebx, 0  ; return 0 status on exit - 'No Errors'
    int 80h
    
    ; this is where I keep my string variables
    
    msg: db 'Hello World!', 0Ah,0     ; assign msg variable with your message string
    main_string db 'This is the assembly counting program!',0Ah,0
    int_string db 32 dup '?',0Ah,0
    
    ; this is where I keep my function definitions
    
    putstring: ; function to print zero terminated string pointed to by register eax
    
    mov edx,eax ; copy eax to edx as well. Now both registers have the address of the main_string
    
    strlen_start: ; this loop finds the lenge of the string as part of the putstring function
    
    cmp [edx],byte 0 ; compare byte at address edx with 0
    jz strlen_end ; if comparison was zero, jump to loop end because we have found the length
    inc edx
    jmp strlen_start
    
    strlen_end:
    sub edx,eax ; edx will now have correct number of bytes when we use it for the system write call
    
    mov ecx,eax ; copy eax to ecx which must contain address of string to write
    mov eax, 4  ; invoke SYS_WRITE (kernel opcode 4)
    mov ebx, 1  ; write to the STDOUT file
    int 80h     ; system call to write the message
    
    ret ; this is the end of the putstring function return to calling location
    
    putint: ; function to output decimal form of whatever integer is in eax
    
    push eax ;save eax on the stack to restore later
    
    mov ebx,int_string+31 ;address of start digits
    
    digits_start:
    
    mov edx,0;
    mov esi,10
    div esi
    add edx,'0'
    mov [ebx],dl
    cmp eax,0
    jz digits_end
    dec ebx
    jmp digits_start
    
    digits_end:
    
    mov eax,ebx ; now that the digits have been written to the string, display it!
    call putstring
    
    pop eax  ;load eax from the stack so it will be as it was before this function was called
    ret
    
    ; This Assembly source file has been formatted for the FASM assembler.
    ; The following 3 commands assemble, give executable permissions, and run the program
    ;
    ;	fasm main.asm
    ;	chmod +x main
    ;	./main
    

    This program only works on computers with Intel x86 CPUs and running a Linux distribution. the “int 80h” instructions mean interrupt 128. For some reason, this calls the Linux kernel. I don’t know why it works this way but I do know enough assembly to write my own string and integer routines to replace printf since it is not available in pure assembly like I could in the C programming language.

  • The Negative Powers of Two

    The negative powers of two are what happens when you start at 1 and keep dividing by 2. Although normally fractional numbers of this sort can’t exist for the integer type, I can simulate it using an array of decimal digits and my pattern recognition to write the small program below which gives the correct digits.

    /*negative powers of two*/
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
     /*most important variable: number of digits*/
     int length=64;
    
     char *a;
     int alength=2,x,y,temp;
    
     a=(char*)malloc(length*sizeof(*a));if(a==NULL){printf("Failed to create array a\n");return(1);}
    
     x=0;
     while(x<length)
     {
      a[x]=0;
      x++;
     }
     a[0]=1;
    
     while(alength<length)
     {
      printf("%i.",a[0]);
    
      x=1;
      while(x<alength)
      {
       printf("%d",a[x]);
       x++;
      }
      printf("\n");
    
      y=0;
      x=0;
      while(x<length)
      {
       if( (a[x]&1)==1 ){temp=5;}else{temp=0;} 
       a[x]>>=1;
       a[x]+=y;
       y=temp;
       x++;
      }
      if(a[alength]>0){alength++;}
    
     }
    
     if(a!=NULL){free(a); a=NULL;}
    
     return 0;
    }
    

    The output of the above program is:

    1.0
    0.5
    0.25
    0.125
    0.0625
    0.03125
    0.015625
    0.0078125
    0.00390625
    0.001953125
    0.0009765625
    0.00048828125
    0.000244140625
    0.0001220703125
    0.00006103515625
    0.000030517578125
    0.0000152587890625
    0.00000762939453125
    0.000003814697265625
    0.0000019073486328125
    0.00000095367431640625
    0.000000476837158203125
    0.0000002384185791015625
    0.00000011920928955078125
    0.000000059604644775390625
    0.0000000298023223876953125
    0.00000001490116119384765625
    0.000000007450580596923828125
    0.0000000037252902984619140625
    0.00000000186264514923095703125
    0.000000000931322574615478515625
    0.0000000004656612873077392578125
    0.00000000023283064365386962890625
    0.000000000116415321826934814453125
    0.0000000000582076609134674072265625
    0.00000000002910383045673370361328125
    0.000000000014551915228366851806640625
    0.0000000000072759576141834259033203125
    0.00000000000363797880709171295166015625
    0.000000000001818989403545856475830078125
    0.0000000000009094947017729282379150390625
    0.00000000000045474735088646411895751953125
    0.000000000000227373675443232059478759765625
    0.0000000000001136868377216160297393798828125
    0.00000000000005684341886080801486968994140625
    0.000000000000028421709430404007434844970703125
    0.0000000000000142108547152020037174224853515625
    0.00000000000000710542735760100185871124267578125
    0.000000000000003552713678800500929355621337890625
    0.0000000000000017763568394002504646778106689453125
    0.00000000000000088817841970012523233890533447265625
    0.000000000000000444089209850062616169452667236328125
    0.0000000000000002220446049250313080847263336181640625
    0.00000000000000011102230246251565404236316680908203125
    0.000000000000000055511151231257827021181583404541015625
    0.0000000000000000277555756156289135105907917022705078125
    0.00000000000000001387778780781445675529539585113525390625
    0.000000000000000006938893903907228377647697925567626953125
    0.0000000000000000034694469519536141888238489627838134765625
    0.00000000000000000173472347597680709441192448139190673828125
    0.000000000000000000867361737988403547205962240695953369140625
    0.0000000000000000004336808689942017736029811203479766845703125
    0.00000000000000000021684043449710088680149056017398834228515625

    I know this post is not exactly Chess related but I am thinking of using this site to double as a way to share some of my computer programming code too. I also may be able to create mathematical data structures to represent the game of Chess in some way.

    I am writing a book about Chess and so I may sometimes share cool programs like this that are heavily math related. My obsession with numbers is how I got my start in programming originally.

  • Installing SDL2 on Debian Linux

    The commands I used to install SDL version 2.32.8 from the source archive on my Debian Linux system.

    ./configure –prefix=/usr make sudo make install


    Sources I read

    Linux and other UNIX systems: * Run ‘./configure; make; make install’

    https://wiki.libsdl.org/SDL2/Installation


    At first I forgot to specify the /usr prefix. I messed up my system and nothing was compiling because the default /usr/local was where the new install was whereas all the other libraries were installed in subdirectories of /usr.

    Therefore I had to repead the command and then remove the sdl2-config file from the /usr/local/bin directory.

    Then everything compiled as before, even my Tetris game and my new LGBT font library.

    Technically I did not need the latest SDL2 version available but I wanted to learn how to install updates from source rather than only relying on the Debian repositories.

    This is because I am considering making my own Linux distribution.

  • 3 SDL Examples

    This post isn’t Chess related but it is still very nerdy. I have made 3 different SDL programs that all do the exact same thing. However they are written using different SDL versions over time as the API has changed. Therefore, SDL version 1,2, and 3 source code is provided as well as the commands to compile them!

    SDL Version 1

    #include <stdio.h>
    #include <SDL.h>
    int width=1280,height=720;
    int loop=1;
    SDL_Surface *surface;
    SDL_Event e;
    int main(int argc, char **argv)
    {
     if(SDL_Init(SDL_INIT_EVERYTHING)){return 1;}
    
     SDL_putenv("SDL_VIDEO_WINDOW_POS=center");
     SDL_WM_SetCaption("SDL1 Program",NULL);
     surface=SDL_SetVideoMode(width,height,32,SDL_SWSURFACE);
     if(surface==NULL){return 1;}
    
     SDL_FillRect(surface,NULL,0xFF00FF);
    
     while(loop)
     {
      while(SDL_PollEvent(&e))
      {
       if(e.type==SDL_QUIT){loop=0;}
       if(e.type==SDL_KEYUP){if(e.key.keysym.sym==SDLK_ESCAPE){loop=0;}}
      }
      SDL_Flip(surface);
     }
    
     SDL_Quit();
     return 0;    
    }
    
    /*
    SDL1 program that creates a window but nothing else.
    Closes when user presses Esc or clicks the X of the window.
    This is to test whether SDL1 programs can be compiled.
    
     With the sdl-config script:
     gcc -Wall -ansi -pedantic sdl1-test.c -o sdl1-test `sdl-config --cflags --libs` && ./sdl1-test
    
     Without the sdl-config script:
     gcc -Wall -ansi -pedantic sdl1-test.c -o sdl1-test -I/usr/include/SDL -D_GNU_SOURCE=1 -L/usr/lib/x86_64-linux-gnu -lSDL && ./sdl1-test
    */
    

    SDL Version 2

    #include <stdio.h>
    #include <SDL.h>
    int width=1280,height=720;
    int loop=1;
    SDL_Window *window;
    SDL_Surface *surface;
    SDL_Event e;
    int main(int argc, char **argv)
    {
     if(SDL_Init(SDL_INIT_VIDEO))
     {
      printf( "SDL could not initialize! SDL_Error: %s\n",SDL_GetError());return -1;
     }
     window=SDL_CreateWindow("SDL2 Program",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,width,height,SDL_WINDOW_SHOWN );
     if(window==NULL){printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );return -1;}
     surface = SDL_GetWindowSurface( window ); /*get surface for this window*/
     SDL_FillRect(surface,NULL,0xFF00FF);
     SDL_UpdateWindowSurface(window);
     printf("SDL Program Compiled Correctly\n");
     while(loop)
     {
      while(SDL_PollEvent(&e))
      {
       if(e.type == SDL_QUIT){loop=0;}
       if(e.type == SDL_KEYUP)
       {
        if(e.key.keysym.sym==SDLK_ESCAPE){loop=0;}
       }
      }
     }
     SDL_DestroyWindow(window);
     SDL_Quit();
     return 0;
    }
    
    /*
     This source file is an example to be included in Chastity's Code Cookbook. This example follows the SDL version 2 which works differently than the most up to date version (version 3 at this time). There is also an updated version in the same repository that works with version 3.
    
     Linux Compile Command:
    
     With the sdl2-config script:
     gcc -Wall -ansi -pedantic sdl2-test.c -o sdl2-test `sdl2-config --cflags --libs` && ./sdl2-test
    
     Without the sdl2-config script:
     gcc -Wall -ansi -pedantic sdl2-test.c -o sdl2-test -I/usr/include/SDL2 -lSDL2 && ./sdl2-test
    */
    

    SDL Version 3

    #include <stdio.h>
    #include <SDL.h>
    int width=1280,height=720;
    int loop=1;
    SDL_Window *window;
    SDL_Surface *surface;
    SDL_Event e;
    int main(int argc, char **argv)
    {
     if(!SDL_Init(SDL_INIT_VIDEO))
     {
      printf( "SDL could not initialize! SDL_Error: %s\n",SDL_GetError());return -1;
     }
     window=SDL_CreateWindow("SDL3 Program",width,height,0);
     if(window==NULL){printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );return -1;}
     surface = SDL_GetWindowSurface( window ); /*get surface for this window*/
     SDL_FillSurfaceRect(surface,NULL,0xFF00FF);
     SDL_UpdateWindowSurface(window);
     printf("SDL Program Compiled Correctly\n");
     while(loop)
     {
      while(SDL_PollEvent(&e))
      {
       if(e.type == SDL_EVENT_QUIT){loop=0;}
       if(e.type == SDL_EVENT_KEY_UP)
       {
        if(e.key.key==SDLK_ESCAPE){loop=0;}
       }
      }
     }
     SDL_DestroyWindow(window);
     SDL_Quit();
     return 0;
    }
    
    /*
     This source file is an example to be included in Chastity's Code Cookbook. By following the migration guide, I converted the SDL2-test program to the changes in SDL3.
    
     https://wiki.libsdl.org/SDL3/README-migration
    
     Windows Compile Command:
    
     gcc -Wall -ansi -pedantic sdl3-test.c -o sdl3-test -IC:/w64devkit/include/SDL3 -lSDL3 && sdl3-test
    
     Linux Compile Command:
    
     gcc -Wall -ansi -pedantic sdl3-test.c -o sdl3-test -I/usr/include/SDL3 -lSDL3 && ./sdl3-test
    
    */
    

    No matter which of those I compile and run, I get the same result:

    All the programs do is create a window and fill the whole thing with Magenta. It’s not that exciting, but it is pretty, and it shows that all 3 versions of SDL work on my Debian Linux machine.

  • WordPress Friendly Chess Table

    a b c d e f g h
    8 r n b q k b n r
    7 p p p p p p p p
    6
    5
    4
    3
    2 P P P P P P P P
    1 R N B Q K B N R

    This is an example of custom written HTML for a table representing a Chessboard. This version does not use CSS and instead styles every single element individually. The reason is because I am unable to control the CSS of WordPress the way I want. This should work for embedding a table of a Chessboard into any WordPress post I want. Creating an HTML table is an idea I had to save disk space if I were to make a personal database of Chess positions and my thoughts on various moves.

    There are other ways to make a text form of a Chess board. For example, consider this table made using Markdown:

    a b c d e f g h
    8 r n b q k b n r
    7 p p p p p p p p
    6
    5
    4
    3
    2 P P P P P P P P
    1 R N B Q K B N R

    The Markdown code that makes the above table is:

    ||a|b|c|d|e|f|g|h|
    |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
    | 8 | r | n | b | q | k | b | n | r |
    | 7 | p | p | p | p | p | p | p | p |
    | 6 |   |   |   |   |   |   |   |   |
    | 5 |   |   |   |   |   |   |   |   |
    | 4 |   |   |   |   |   |   |   |   |
    | 3 |   |   |   |   |   |   |   |   |
    | 2 | P | P | P | P | P | P | P | P |
    | 1 | R | N | B | Q | K | B | N | R |
    

    However, the Markdown version, although it displays fine when viewed on Github, does not play well with WordPress. Therefore, the HTML version at the top of this post is much more reliable for WordPress posts.

    Reading the code on the other hand is another story! The following HTML code made the table at the very top of this post.

    <table style="width: 720px;height: 720px;border: 1px solid black;border-collapse: collapse">
    
    <tbody>
    
    <tr>
    <th style="text-align: center"></th>
    <th style="text-align: center">a</th>
    <th style="text-align: center">b</th>
    <th style="text-align: center">c</th>
    <th style="text-align: center">d</th>
    <th style="text-align: center">e</th>
    <th style="text-align: center">f</th>
    <th style="text-align: center">g</th>
    <th style="text-align: center">h</th>
    </tr>
    
    <tr>
    <th style="text-align: center">8</th>
    <td style="text-align: center;border: 1px solid black">r</td>
    <td style="text-align: center;border: 1px solid black">n</td>
    <td style="text-align: center;border: 1px solid black">b</td>
    <td style="text-align: center;border: 1px solid black">q</td>
    <td style="text-align: center;border: 1px solid black">k</td>
    <td style="text-align: center;border: 1px solid black">b</td>
    <td style="text-align: center;border: 1px solid black">n</td>
    <td style="text-align: center;border: 1px solid black">r</td>
    </tr>
    
    <tr>
    <th style="text-align: center">7</th>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    <td style="text-align: center;border: 1px solid black">p</td>
    </tr>
    
    <tr>
    <th style="text-align: center">6</th>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    </tr>
    
    <tr>
    <th style="text-align: center">5</th>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    </tr>
    
    <tr>
    <th style="text-align: center">4</th>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    </tr>
    
    <tr>
    <th style="text-align: center">3</th>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    <td style="text-align: center;border: 1px solid black"></td>
    </tr>
    
    <tr>
    <th style="text-align: center">2</th>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    <td style="text-align: center;border: 1px solid black">P</td>
    </tr>
    
    <tr>
    <th style="text-align: center">1</th>
    <td style="text-align: center;border: 1px solid black">R</td>
    <td style="text-align: center;border: 1px solid black">N</td>
    <td style="text-align: center;border: 1px solid black">B</td>
    <td style="text-align: center;border: 1px solid black">Q</td>
    <td style="text-align: center;border: 1px solid black">K</td>
    <td style="text-align: center;border: 1px solid black">B</td>
    <td style="text-align: center;border: 1px solid black">N</td>
    <td style="text-align: center;border: 1px solid black">R</td>
    </tr>
    
    </tbody>
    
    </table>
    

    When considering the difficulty of getting a workable table to display on my blog, you may wonder why I bother? Consider the following image which is the equivalent starting position of Chess.

    Obviously, this image looks better than the lame table at the top of this post, but it comes with a few downsides.

    First, the amount of time it takes to load up inkscape, move the pieces around for the image, choose a file name to save as, upload the file to my WordPress media account, and then write a Markdown link to the image is far more than the time it takes to edit the HTML code to mode the pieces of text around.

    Second, linking to image files adds the dependency of external files existing and the internet connection working. By keeping the table as plain text, it allows me to work offline and save time and space in the creation of the image and my explanations of that position.

    Therefore, I have decided to use the HTML table method for some time as I build content for my next Chess book. However, it will not be done any time soon. The first book was for beginners, but the next book will hopefully be for the more advanced and skilled player.

    Also, if you haven’t already, go read my first book, Chastity’s Chess Chapters.

  • Chess Start Position

    a b c d e f g h
    8 r n b q k b n r
    7 p p p p p p p p
    6
    5
    4
    3
    2 P P P P P P P P
    1 R N B Q K B N R

    What you see above is an HTML table representation of a Chess board. It is not perfect, but it is a convenient way to avoid the use of images when creating documentation on different Chess positions. Using plain text saves a lot of space compared to the space required to make millions of Chess images for every possible move. The white pieces are represented with capital letters and the black by lowercase letters.

    Of course, I don’t intend to document every move that could occur in every Chess game. Instead, I want to cover those that happen in real games with humans. The idea is approximately one blog post per day where I analyze the board from my human perspective and then write what I think the best move is.

    Unlike a Chess engine, I can explain the reason for my moves in a position. This could be used for future Chess books after I have written good explanations of why I recommend a move in a given position.

    In any case, my recommended move from the starting position will always be d4, which means move the pawn in front of the white queen to d4.

    Later on, I may cover openings starting with e4, but because they are too popular and overused, I will be sticking with my openings beginning with d4. The idea is one post per day because this is a small step that is easy to fit into my busy schedule.

    Unfortunately, my table does not display on WordPress the way it does on other sites like Github. I am working on ways to resolve this with HTML or CSS but my needs are very specific and this may take time.

  • I Will Survive

    Today’s post is not exactly Chess related other than the fact that this checkered dress I bought 7 years ago was purchased because I am obsessed with Chess and the pattern of the Chess board. My skills are not only limited to playing Chess and writing books. I also like to dance to all kinds of music. Enjoy this silly video of me dancing to “I Will Survive” by Gloria Gaynor.

  • How to Filter Chess Games by Checkmates and Length

    When I first began playing Chess, I was obsessed with the Scholar’s Mate, which is when white wins the game in only 4 moves. Such occurrences are quite rare when playing against experienced players. However, I recently began thinking about how checkmates in under a certain number of moves could be useful.

    If a game is won in very few moves, there is a high chance that the winning player did not make any mistakes. Also, in certain arena tournaments, the winning player of the tournament is who has the most points by winning more games. Those who know how to win games in fewer moves can simply get more wins in the same amount of time.

    Therefore, I have written some instructions for using pgn-extract to find games with a certain number of maximum moves. I have previously mentioned how useful this command line tool is. If you download your own database of games from lichess.org, you can use my example commands by simply changing the names of the files and your username in the commands to find the games you have won the fastest.

    How to Find Checkmates

    the “–checkmate” flag is used to only output games that end in a checkmate instead of a resignation or a stalemate. See the example commands here.

    This first command takes all of the games where chastitywhiterose was the white player and won the game by checkmate.

    pgn-extract -Twchastitywhiterose -Tr1-0 lichess_chastitywhiterose.pgn -ochastitywhiterose_white_wins_lichess.pgn --checkmate

    The second does the reverse and finds every time that chastitywhiterose played as black and then black won the game by checkmate.

    pgn-extract -Tbchastitywhiterose -Tr0-1 lichess_chastitywhiterose.pgn -ochastitywhiterose_black_wins_lichess.pgn --checkmate

    How to Find Quick Checkmates

    The documentation for pgn-extract shows that you can limit the length of games matched in database. By combining the “–checkmate” flag and the “–maxmoves” flag with a number as an option, you can find all the checkmates that happen up to that number of moves.

    https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#move-bounds

    For example, this command finds all my checkmates with white which happen in 10 moves or less.

    pgn-extract -Twchastitywhiterose -Tr1-0 lichess_chastitywhiterose.pgn -ochastitywhiterose_white_wins_lichess.pgn --checkmate --maxmoves 10

    And this does the same with black checkmates of 10 moves or less.

    pgn-extract -Tbchastitywhiterose -Tr0-1 lichess_chastitywhiterose.pgn -ochastitywhiterose_black_wins_lichess.pgn --checkmate --maxmoves 10

    Because I am someone who usually plays the Queen’s Gambit opening as white and the French Defense as black, very few of my games end this quickly. My play style is to slowly wear my opponent down in a long classical game. But perhaps your style is to take your opponents down quickly before they even know what happened!

    I suggest downloading and installing the pgn-extract tool and placing the path to it in your system settings so you can run commands to extract your best wins.

    My own purpose in this is to identify games that I have played which are high quality enough to include in a future Chess book. Fast wins are quite satisfying.

  • How The Chandler Caterpillar Evolved into a Chastity Butterfly

    Chastity’s Journey into a career in writing began in 2013 when she published a book titled “Confessions of a Confused Virgin”. This book project was intended to teach Chastity about the process of self-publishing a book so that she could help her mother, Judena Klebs, publish the books she had written.

    However, the people on Facebook enjoyed Chastity’s different points of view on dating, marriage, and sex. After that, Chastity started blogging on a WordPress blog about whatever she had on her mind at the time. Eventually, these small posts became content for future books she would publish.

    The majority of her writing was a series of conversations she had with a unicorn in a dream. The series remains forever published as “Chandler’s Honesty” because Chandler is her legal name even though she is known by her preferred name of Chastity White Rose. Unlike most transgender people, Chastity does not consider Chandler to be a “dead name” but instead a name of historical importance as she evolves from a caterpillar to a butterfly and yet remains the same person.

    butterfly.png

    Chastity is a simple person who prefers playing Tetris or Chess much more than writing. However, she began a project in Pride month of 2025 with a focus on educating the public about the LGBTQIA+ community that is different than the hype you would hear from mainstream media.

    Chastity graduated with a Creative Writing Degree in July of 2025 after attending Full Sail University as an online student while working full-time at Walmart in Lee’s Summit, Missouri.

    Her best paperback books and ebooks can be purchased from Amazon, Apple Books, Google Play books, and many others. These works cover a range of topics, such as opinions on politics or religion, her Journey as an Asexual Transgender woman (Chandler’s Honesty), and even a 100-page book about the board game of Chess (Chastity’s Chess Chapters).

    But beyond writing books and blog posts, Chastity is offering services to help others write and publish their books, blogs, and websites. Those who have a story to tell but who may not be as technologically inclined may benefit from her experience using Kindle Direct Publishing, Draft2Digital, WordPress, and writing content with Markdown and HTML.

    Chastity writes on two main websites that she pays to keep free of ads and distractions.

    You can also follow her author profiles for updates on the latest books she publishes.