28.- Trying to play with Arena

Una vegada dominat el moviment lo únic que haig de fer és mirar la matriu inicial i la final i quins elements d'aquestes són els que han canviat, evidentment, si no hi ha hagut moviment senzillament segueixo escanejant el taulell i res més. Els digits de les matrius els associo amb una casella amb el format de referència dels taulells (a1,...,h8) obtenint la casella de sortida i la d'arribada. Aquestes dues caselles formaran l'ordre que enviaré pel port serie amb la llibreria Keyboard que emularà una entrada per teclat de la jugada al programa de l'ordinador.



Una vez dominado el movimiento lo único que tengo que hacer es mirar la matriz inicial y la final y qué elementos de estas son los que han cambiado, evidentemente, si no ha habido movimiento sencillamente sigo escaneando el mostrador y nada más. Los digitos de las matrices los asocio con una casilla con el formato de referencia de los azulejos (a1, ..., h8) obteniendo la casilla de salida y la de llegada. Estas dos casillas formarán el orden que enviaré por el puerto serie con la librería Keyboard que emulará una entrada para teclado de la jugada en el programa del ordenador

Once I have mastered the movement all I have to do is look at the initial and final matrix and which elements of these are the ones that have changed, obviously if there has been no movement I just keep scanning the board and nothing else. I associate the digits of the matrices with a square with the reference format of the chessboards (a1, ..., h8) obtaining the exit box and the arrival one. These two boxes will form the order that I will send through the serial port with the Keyboard library that will emulate a keyboard input of the play in the computer program.

void comparaMatrius()
{
bool valorM3=0;
bool valorM1=0;
bool valorM2=0;

String casellaSortida[2]="";
String casellaArribada[2]="";

        //I count the '1' of each array and look at which box has already gone
        //from '1' to '0' getting the output box.
for (int col =0;col<4;col++)
{
for(int fila=0;fila<4;fila++)
{
valorM3=matriu3[col][fila];
valorM1=matriu1[col][fila];
valorM2=matriu2[col][fila];

if(valorM3==1 && valorM1==0) //Geting the exit square
{switch (col)

                  //
Associating digit from the array to the counter column in the row we are inspecting
                  {case 0:casellaSortida[0]='e';casellaSortida[1]=(fila)+1;break;
case 1:casellaSortida[0]='f';casellaSortida[1]=(fila)+1;break;
case 2:casellaSortida[0]='g';casellaSortida[1]=(fila)+1;break;
case 3:casellaSortida[0]='h';casellaSortida[1]=(fila)+1;break;}}
if (!casellaSortTrobada)

                .
                .
                .
                .



En el video es veu com jugo sense clicar el botó del temps, això és degut a que vaig
posar un delay de temps d'uns 4 ó 5 segons que és el que triga en moure les peces
quan se li envia la jugada, això NO m'agrada, voldria que el temps de resposta fos
més ràpid, per això, primer em dedicaré a codificar basant-me en el clic del botó dels
jugadors i després ja miraré la possibilitat de jugar sense temps. A sota un video amb
temps de resposta com a mi m'agrada, fixeu-vos que, jugant contra l'ordinador, se li ha
de clicar el seu botó de temps.

En el video se ve como juego sin pulsar el botón del tiempo, esto se debe a que
puse un delay de tiempo de unos 4 ó 5 segundos que es lo que tarda en mover las piezas cuando se le envía la jugada, esto NO me gusta, quisiera que el tiempo de respuesta fuera más rápido, por eso, primero me dedicaré a codificar basándome en el clic del botón de los jugadores y luego ya miraré la posibilidad de jugar sin tiempo.
Debajo un tiempo de respuesta como a mi me gusta, fijaros que jugando contra el ordenador se tiene que clicar el botón de tiempo cuando tira él.

In the video you see how I play without clicking the time button, this is because I put a time delay of about 4 or 5 seconds which is what it takes to move the pieces
when the play is sent to the chess progrma, this I do NOT like, I would like the response time to be faster, so I'll first code based on the click of the players and then I will look at the possibility of playing without time.
Below is a video with
response time as I like, notice that, playing against the computer, you have to
by clicking your time button.



Aprofito per recomanar aquesta GUI d'escacs que també és lliure i gratuita:


www.playwitharena.de

Comentaris

Entrades populars d'aquest blog

45.- Weighting the pieces

3.- Sensors II

21.- Electronic scheme (updated 26/08/2020)