From: Svjatoslav Agejenko Date: Mon, 28 Jul 2025 15:30:59 +0000 (+0300) Subject: Improve application listing on the web X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=7a345c111692f25b9ca771c6e6387a3c8de760ff;p=qbasicapps.git Improve application listing on the web --- diff --git a/Games/checkers.bas b/Games/checkers.bas index ce99d90..1662722 100755 --- a/Games/checkers.bas +++ b/Games/checkers.bas @@ -1,534 +1,539 @@ -' Game of checkers. -' -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 1998, Initial version -' 2025, Improved program readability -' -' Usage: -' keys: w a z s - move around -' ENTER key - pick piece on the desk and place it to new location - -DECLARE SUB CheckPossibleMoves() -DECLARE SUB HandleMovement() -DECLARE SUB GameLoop() -DECLARE SUB HandleInput() -DECLARE SUB UpdateDisplay() -DEFINT A-Z - -DIM SHARED boardState(-100 TO 300) AS INTEGER -' 0 - black piece -' 1 - white piece -' 3 - Empty square that piece is allowed to move to -' 4 - Empty square that is not reachable according to the game rules -' -' Cell address calculation (row 1--10, col 1--10): -' cell address = ((row - 1) * 20) + col - - -DIM SHARED moveMade AS INTEGER -DIM SHARED hasMove AS INTEGER -DIM SHARED cursorImage(1000) -DIM SHARED cursorX, cursorY -SCREEN 2 - - -CLS -' Draw cursor image and store it into array for quick drawing on the screen -LINE (1, 1)-(10, 1) -LINE (1, 1)-(1, 5) -LINE (10, 1)-(6, 2) -LINE (6, 2)-(10, 4) -LINE (10, 4)-(8, 5) -LINE (8, 5)-(4, 3) -LINE (4, 3)-(1, 5) -PAINT (2, 2), 1 -GET (1, 1)-(10, 5), cursorImage - -CLS -' Draw the checkerboard grid -FOR col = 0 TO 10 - LINE ((col * 40) + 20, 10)-((col * 40) + 20, 189), 1 -NEXT col - -FOR row = 0 TO 20 - LINE (20, (row * 18) + 9)-(420, (row * 18) + 9), 1 -NEXT row - -' Initialize the board state to empty squares -FOR cell = 1 TO 200 - boardState(cell) = 4 -NEXT cell - -' Draw the initial checkerboard pattern. -' (alternating squares to create the checkerboard) - -FOR row = 2 TO 10 STEP 2 - FOR col = 1 TO 10 STEP 2 - PAINT ((col * 40) + 5, (row * 18) + 5) - NEXT col -NEXT row - -FOR row = 1 TO 10 STEP 2 - FOR col = 2 TO 10 STEP 2 - PAINT ((col * 40) + 5, (row * 18) + 5) - NEXT col -NEXT row - -' Place the white pieces on the board -FOR row = 2 TO 4 STEP 2 - FOR col = 1 TO 10 STEP 2 - boardState(((row - 1) * 20) + col) = 1 - NEXT col -NEXT row - -FOR row = 1 TO 4 STEP 2 - FOR col = 2 TO 10 STEP 2 - boardState(((row - 1) * 20) + col) = 1 - NEXT col -NEXT row - -' Place the black pieces on the board -FOR row = 8 TO 10 STEP 2 - FOR col = 1 TO 10 STEP 2 - boardState(((row - 1) * 20) + col) = 0 - NEXT col -NEXT row - -FOR row = 7 TO 10 STEP 2 - FOR col = 2 TO 10 STEP 2 - boardState(((row - 1) * 20) + col) = 0 - NEXT col -NEXT row - -FOR col = 2 TO 10 STEP 2 - boardState(80 + col) = 3 -NEXT col - -FOR col = 1 TO 10 STEP 2 - boardState(100 + col) = 3 -NEXT col - -UpdateDisplay -moveMade = 1 -GameLoop - -SUB UpdateDisplay - ' Draw the pieces on the board - FOR row = 1 TO 10 - FOR col = 1 TO 10 - pieceType = boardState(((row - 1) * 20) + col) - SELECT CASE pieceType - CASE 1 - CIRCLE (col * 40, row * 18), 17, 1 - PAINT (col * 40, row * 18), 1 - CIRCLE (col * 40, row * 18), 17, 0 - CIRCLE (col * 40, row * 18), 16, 0 - LINE ((col * 40) - 16, row * 18)-((col * 40) + 16, row * 18), 0 - CASE 0 - CIRCLE (col * 40, row * 18), 17, 0 - PAINT (col * 40, row * 18), 0 - CIRCLE (col * 40, row * 18), 17, 1 - CIRCLE (col * 40, row * 18), 15, 1 - CIRCLE (col * 40, row * 18), 3, 1 - CIRCLE (col * 40, row * 18), 7, 1 - LINE ((col * 40) - 16, row * 18)-((col * 40) + 16, row * 18), 0 - CASE 3 - PAINT (col * 40, row * 18), 1 - END SELECT - NEXT col - NEXT row -END SUB - -SUB CheckPossibleMoves - ' Checks if there are any possible moves on the board - hasMove = 0 - FOR cell = 1 TO 200 - ' Check for possible jumps in all directions - IF boardState(cell) = 0 AND boardState(cell - 21) = 1 AND boardState(cell - 42) = 3 THEN hasMove = 1 - IF boardState(cell) = 0 AND boardState(cell - 19) = 1 AND boardState(cell - 38) = 3 THEN hasMove = 1 - IF boardState(cell) = 0 AND boardState(cell + 21) = 1 AND boardState(cell + 42) = 3 THEN hasMove = 1 - IF boardState(cell) = 0 AND boardState(cell + 19) = 1 AND boardState(cell + 38) = 3 THEN hasMove = 1 - NEXT cell -END SUB - -SUB GameLoop - 4 - HandleInput - HandleMovement - CheckPossibleMoves - IF hasMove = 1 THEN SOUND 1234, 2 - GOTO 4 -END SUB - -SUB HandleMovement -3 -' Check for possible jumps where a AI can eat 2 pieces at once -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 61) = 0 AND boardState(cell + 80) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 3: boardState(cell + 42) = 1 - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 23) = 0 AND boardState(cell + 4) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 3 : boardState(cell + 42) = 1 - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 59) = 0 AND boardState(cell + 80) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 3 : boardState(cell + 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 17) = 0 AND boardState(cell - 4) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 3 : boardState(cell + 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 63) = 0 AND boardState(cell + 84) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 3 : boardState(cell + 42) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 57) = 0 AND boardState(cell + 76) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 3 : boardState(cell + 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - - IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 61) = 0 AND boardState(cell - 80) = 3 THEN - boardState(cell) = 3: boardState(cell - 21) = 3 : boardState(cell - 42) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 23) = 0 AND boardState(cell - 4) = 3 THEN - boardState(cell) = 3: boardState(cell - 21) = 3 : boardState(cell - 42) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 59) = 0 AND boardState(cell - 80) = 3 THEN - boardState(cell) = 3: boardState(cell - 19) = 3 : boardState(cell - 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 17) = 0 AND boardState(cell + 4) = 3 THEN - boardState(cell) = 3: boardState(cell - 19) = 3 : boardState(cell - 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 63) = 0 AND boardState(cell - 84) = 3 THEN - boardState(cell) = 3: boardState(cell - 21) = 3 : boardState(cell - 42) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF - IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 57) = 0 AND boardState(cell - 76) = 3 THEN - boardState(cell) = 3: boardState(cell - 19) = 3 : boardState(cell - 38) = 1 - - moveMade = 1 - UpdateDisplay - GOTO 3 - END IF -NEXT cell - -' Check for possible single moves (single eating) -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 3 : boardState(cell + 42) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 3 : boardState(cell + 38) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 THEN - boardState(cell) = 3: boardState(cell - 21) = 3 : boardState(cell - 42) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 THEN - boardState(cell) = 3: boardState(cell - 19) = 3 : boardState(cell - 38) = 1 - - GOTO 2 - END IF -NEXT cell - -' Check for possible defensive moves (to protect own pieces) -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 0 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 0 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - - IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN - boardState(cell - 2) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 1 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN - boardState(cell - 2) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN - boardState(cell - 2) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 1 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN - boardState(cell - 2) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF -NEXT cell - -' Check for possible moves to the board edges (to protect own pieces) -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 2) = 4 AND boardState(cell + 21) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell - 2) = 4 AND boardState(cell + 19) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF -NEXT cell - -' Check for possible moves to the corner (safe moves) -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 3 AND boardState(cell + 40) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 3 AND boardState(cell + 40) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF - - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 1 AND boardState(cell + 40) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 1 AND boardState(cell + 40) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF - - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 3 AND boardState(cell + 40) = 1 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 3 AND boardState(cell + 40) = 1 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF - - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 1 AND boardState(cell + 40) = 1 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 1 AND boardState(cell + 40) = 1 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF -NEXT cell - -' Check for any remaining moves that can be made -FOR cell = 1 TO 200 - IF boardState(cell) = 1 AND boardState(cell + 21) = 3 THEN - boardState(cell) = 3: boardState(cell + 21) = 1 - - GOTO 2 - END IF - IF boardState(cell) = 1 AND boardState(cell + 19) = 3 THEN - boardState(cell) = 3: boardState(cell + 19) = 1 - - GOTO 2 - END IF -NEXT cell -LOCATE 4, 5 -PRINT " Y O U W O N !" -END -GOTO 3 -2 -UpdateDisplay -9 -END SUB - -SUB HandleInput - DIM tempImage(1000) - - inputPhase = 1 - - 5 - cursorX = ax1 - cursorY = ax2 - - 7 - IF inputPhase = 1 THEN - LOCATE 1, 60 - PRINT "From where ?" - END IF - IF inputPhase = 2 THEN - LOCATE 1, 60 - PRINT "To where ? " - END IF - - - selectedCell = (((cursorY \ 18) - 1) * 20) + (cursorX \ 40) - 'LOCATE 2, 60 - 'PRINT selectedCell - - GET (cursorX, cursorY)-(cursorX + 10, cursorY + 10), tempImage - PUT (cursorX, cursorY), cursorImage, PSET - - key$ = INPUT$(1) - PUT (cursorX, cursorY), tempImage, PSET - - IF inputPhase = 2 AND key$ = CHR$(13) THEN - destinationCell = selectedCell - cursorX = ax1 - cursorY = ax2 - GOTO 8 - END IF - IF inputPhase = 1 AND key$ = CHR$(13) THEN - sourceCell = selectedCell - inputPhase = 2 - END IF - - IF key$ = "q" THEN - END - END IF - IF key$ = "s" THEN - cursorX = cursorX + 40 - END IF - IF key$ = "a" THEN - cursorX = cursorX - 40 - END IF - IF key$ = "w" THEN - cursorY = cursorY - 18 - END IF - IF key$ = "z" THEN - cursorY = cursorY + 18 - END IF - - IF cursorX < 1 THEN - cursorX = 1 - END IF - - IF cursorY < 1 THEN - cursorY = 1 - END IF - - GOTO 7 - - 8 - moveMade = 1 - - 'LOCATE 3, 60 - 'PRINT sourceCell; "-"; destinationCell - - 10 - - ' This section controls the movement of pieces on the board - IF sourceCell = destinationCell + 19 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - END IF - IF sourceCell = destinationCell + 21 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - END IF - - captureMade = 0 - - IF sourceCell = destinationCell + 42 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell + 21) = 1 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - boardState(destinationCell + 21) = 3 - captureMade = 1 - END IF - IF sourceCell = destinationCell + 38 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell + 19) = 1 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - boardState(destinationCell + 19) = 3 - captureMade = 1 - END IF - IF sourceCell = destinationCell - 42 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell - 21) = 1 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - boardState(destinationCell - 21) = 3 - captureMade = 1 - END IF - IF sourceCell = destinationCell - 38 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell - 19) = 1 THEN - BEEP - SWAP boardState(sourceCell), boardState(destinationCell) - boardState(destinationCell - 19) = 3 - captureMade = 1 - END IF - - UpdateDisplay - - IF captureMade = 1 THEN - CheckPossibleMoves - IF hasMove = 1 THEN - SOUND 1234, 1 - inputPhase = 2 - sourceCell = destinationCell - GOTO 5 - END IF - END IF - - 6 -END SUB +' Game of checkers. +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 1998, Initial version +' 2025, Improved program readability +' +' Usage: +' arrow keys - move around +' ENTER key - pick piece on the desk and place it to new location +' q - quit game + +DECLARE SUB CheckPossibleMoves () +DECLARE SUB HandleMovement () +DECLARE SUB GameLoop () +DECLARE SUB HandleInput () +DECLARE SUB UpdateDisplay () +DEFINT A-Z + +DIM SHARED boardState(-100 TO 300) AS INTEGER +' 0 - black piece +' 1 - white piece +' 3 - Empty square that piece is allowed to move to +' 4 - Empty square that is not reachable according to the game rules +' +' Cell address calculation (row 1--10, col 1--10): +' cell address = ((row - 1) * 20) + col + + +DIM SHARED moveMade AS INTEGER +DIM SHARED hasMove AS INTEGER +DIM SHARED cursorImage(1000) +DIM SHARED cursorX, cursorY +SCREEN 2 + + +CLS +' Draw cursor image and store it into array for quick drawing on the screen +LINE (1, 1)-(10, 1) +LINE (1, 1)-(1, 5) +LINE (10, 1)-(6, 2) +LINE (6, 2)-(10, 4) +LINE (10, 4)-(8, 5) +LINE (8, 5)-(4, 3) +LINE (4, 3)-(1, 5) +PAINT (2, 2), 1 +GET (1, 1)-(10, 5), cursorImage + +CLS +' Draw the checkerboard grid +FOR col = 0 TO 10 + LINE ((col * 40) + 20, 10)-((col * 40) + 20, 189), 1 +NEXT col + +FOR row = 0 TO 20 + LINE (20, (row * 18) + 9)-(420, (row * 18) + 9), 1 +NEXT row + +' Initialize the board state to empty squares +FOR cell = 1 TO 200 + boardState(cell) = 4 +NEXT cell + +' Draw the initial checkerboard pattern. +' (alternating squares to create the checkerboard) + +FOR row = 2 TO 10 STEP 2 + FOR col = 1 TO 10 STEP 2 + PAINT ((col * 40) + 5, (row * 18) + 5) + NEXT col +NEXT row + +FOR row = 1 TO 10 STEP 2 + FOR col = 2 TO 10 STEP 2 + PAINT ((col * 40) + 5, (row * 18) + 5) + NEXT col +NEXT row + +' Place the white pieces on the board +FOR row = 2 TO 4 STEP 2 + FOR col = 1 TO 10 STEP 2 + boardState(((row - 1) * 20) + col) = 1 + NEXT col +NEXT row + +FOR row = 1 TO 4 STEP 2 + FOR col = 2 TO 10 STEP 2 + boardState(((row - 1) * 20) + col) = 1 + NEXT col +NEXT row + +' Place the black pieces on the board +FOR row = 8 TO 10 STEP 2 + FOR col = 1 TO 10 STEP 2 + boardState(((row - 1) * 20) + col) = 0 + NEXT col +NEXT row + +FOR row = 7 TO 10 STEP 2 + FOR col = 2 TO 10 STEP 2 + boardState(((row - 1) * 20) + col) = 0 + NEXT col +NEXT row + +FOR col = 2 TO 10 STEP 2 + boardState(80 + col) = 3 +NEXT col + +FOR col = 1 TO 10 STEP 2 + boardState(100 + col) = 3 +NEXT col + +UpdateDisplay +moveMade = 1 +GameLoop + +SUB CheckPossibleMoves + ' Checks if there are any possible moves on the board + hasMove = 0 + FOR cell = 1 TO 200 + ' Check for possible jumps in all directions + IF boardState(cell) = 0 AND boardState(cell - 21) = 1 AND boardState(cell - 42) = 3 THEN hasMove = 1 + IF boardState(cell) = 0 AND boardState(cell - 19) = 1 AND boardState(cell - 38) = 3 THEN hasMove = 1 + IF boardState(cell) = 0 AND boardState(cell + 21) = 1 AND boardState(cell + 42) = 3 THEN hasMove = 1 + IF boardState(cell) = 0 AND boardState(cell + 19) = 1 AND boardState(cell + 38) = 3 THEN hasMove = 1 + NEXT cell +END SUB + +SUB GameLoop +4 + HandleInput + HandleMovement + CheckPossibleMoves + IF hasMove = 1 THEN SOUND 1234, 2 + GOTO 4 +END SUB + +SUB HandleInput + DIM tempImage(1000) + + inputPhase = 1 + +5 + cursorX = ax1 + cursorY = ax2 + +7 + IF inputPhase = 1 THEN + LOCATE 1, 60 + PRINT "From where ?" + END IF + IF inputPhase = 2 THEN + LOCATE 1, 60 + PRINT "To where ? " + END IF + + + selectedCell = (((cursorY \ 18) - 1) * 20) + (cursorX \ 40) + 'LOCATE 2, 60 + 'PRINT selectedCell + + GET (cursorX, cursorY)-(cursorX + 10, cursorY + 10), tempImage + PUT (cursorX, cursorY), cursorImage, PSET + +getKey: + key$ = INKEY$ +IF key$ = "" THEN GOTO getKey + + PUT (cursorX, cursorY), tempImage, PSET + + IF inputPhase = 2 AND key$ = CHR$(13) THEN + destinationCell = selectedCell + cursorX = ax1 + cursorY = ax2 + GOTO 8 + END IF + IF inputPhase = 1 AND key$ = CHR$(13) THEN + sourceCell = selectedCell + inputPhase = 2 + END IF + + IF key$ = "q" THEN + END + END IF + IF key$ = CHR$(0) + "M" THEN ' Right arrow + cursorX = cursorX + 40 + END IF + IF key$ = CHR$(0) + "K" THEN ' Left arrow + cursorX = cursorX - 40 + END IF + IF key$ = CHR$(0) + "H" THEN ' Up arrow + cursorY = cursorY - 18 + END IF + IF key$ = CHR$(0) + "P" THEN ' Down arrow + cursorY = cursorY + 18 + END IF + + IF cursorX < 1 THEN + cursorX = 1 + END IF + + IF cursorY < 1 THEN + cursorY = 1 + END IF + + GOTO 7 + +8 + moveMade = 1 + + 'LOCATE 3, 60 + 'PRINT sourceCell; "-"; destinationCell + +10 + + ' This section controls the movement of pieces on the board + IF sourceCell = destinationCell + 19 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + END IF + IF sourceCell = destinationCell + 21 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + END IF + + captureMade = 0 + + IF sourceCell = destinationCell + 42 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell + 21) = 1 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + boardState(destinationCell + 21) = 3 + captureMade = 1 + END IF + IF sourceCell = destinationCell + 38 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell + 19) = 1 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + boardState(destinationCell + 19) = 3 + captureMade = 1 + END IF + IF sourceCell = destinationCell - 42 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell - 21) = 1 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + boardState(destinationCell - 21) = 3 + captureMade = 1 + END IF + IF sourceCell = destinationCell - 38 AND boardState(sourceCell) = 0 AND boardState(destinationCell) = 3 AND boardState(destinationCell - 19) = 1 THEN + BEEP + SWAP boardState(sourceCell), boardState(destinationCell) + boardState(destinationCell - 19) = 3 + captureMade = 1 + END IF + + UpdateDisplay + + IF captureMade = 1 THEN + CheckPossibleMoves + IF hasMove = 1 THEN + SOUND 1234, 1 + inputPhase = 2 + sourceCell = destinationCell + GOTO 5 + END IF + END IF + +6 +END SUB + +SUB HandleMovement +3 +' Check for possible jumps where a AI can eat 2 pieces at once +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 61) = 0 AND boardState(cell + 80) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 3: boardState(cell + 42) = 1 + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 23) = 0 AND boardState(cell + 4) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 3: boardState(cell + 42) = 1 + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 59) = 0 AND boardState(cell + 80) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 3: boardState(cell + 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 17) = 0 AND boardState(cell - 4) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 3: boardState(cell + 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 AND boardState(cell + 63) = 0 AND boardState(cell + 84) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 3: boardState(cell + 42) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 AND boardState(cell + 57) = 0 AND boardState(cell + 76) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 3: boardState(cell + 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + + IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 61) = 0 AND boardState(cell - 80) = 3 THEN + boardState(cell) = 3: boardState(cell - 21) = 3: boardState(cell - 42) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 23) = 0 AND boardState(cell - 4) = 3 THEN + boardState(cell) = 3: boardState(cell - 21) = 3: boardState(cell - 42) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 59) = 0 AND boardState(cell - 80) = 3 THEN + boardState(cell) = 3: boardState(cell - 19) = 3: boardState(cell - 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 17) = 0 AND boardState(cell + 4) = 3 THEN + boardState(cell) = 3: boardState(cell - 19) = 3: boardState(cell - 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 AND boardState(cell - 63) = 0 AND boardState(cell - 84) = 3 THEN + boardState(cell) = 3: boardState(cell - 21) = 3: boardState(cell - 42) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF + IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 AND boardState(cell - 57) = 0 AND boardState(cell - 76) = 3 THEN + boardState(cell) = 3: boardState(cell - 19) = 3: boardState(cell - 38) = 1 + + moveMade = 1 + UpdateDisplay + GOTO 3 + END IF +NEXT cell + +' Check for possible single moves (single eating) +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 21) = 0 AND boardState(cell + 42) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 3: boardState(cell + 42) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 0 AND boardState(cell + 38) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 3: boardState(cell + 38) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell - 21) = 0 AND boardState(cell - 42) = 3 THEN + boardState(cell) = 3: boardState(cell - 21) = 3: boardState(cell - 42) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell - 19) = 0 AND boardState(cell - 38) = 3 THEN + boardState(cell) = 3: boardState(cell - 19) = 3: boardState(cell - 38) = 1 + + GOTO 2 + END IF +NEXT cell + +' Check for possible defensive moves (to protect own pieces) +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 0 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 21) = 0 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + + IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN + boardState(cell - 2) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 1 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 3 AND boardState(cell + 61) = 0 THEN + boardState(cell - 2) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 3 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN + boardState(cell - 2) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell - 2) = 1 AND boardState(cell + 19) = 3 AND boardState(cell) = 1 AND boardState(cell + 40) = 1 AND boardState(cell + 38) = 1 AND boardState(cell + 61) = 0 THEN + boardState(cell - 2) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF +NEXT cell + +' Check for possible moves to the board edges (to protect own pieces) +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 2) = 4 AND boardState(cell + 21) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell - 2) = 4 AND boardState(cell + 19) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF +NEXT cell + +' Check for possible moves to the corner (safe moves) +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 3 AND boardState(cell + 40) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 3 AND boardState(cell + 40) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF + + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 1 AND boardState(cell + 40) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 1 AND boardState(cell + 40) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF + + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 3 AND boardState(cell + 40) = 1 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 3 AND boardState(cell + 40) = 1 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF + + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 AND boardState(cell + 38) = 1 AND boardState(cell + 40) = 1 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 21) = 3 AND boardState(cell + 42) = 1 AND boardState(cell + 40) = 1 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF +NEXT cell + +' Check for any remaining moves that can be made +FOR cell = 1 TO 200 + IF boardState(cell) = 1 AND boardState(cell + 21) = 3 THEN + boardState(cell) = 3: boardState(cell + 21) = 1 + + GOTO 2 + END IF + IF boardState(cell) = 1 AND boardState(cell + 19) = 3 THEN + boardState(cell) = 3: boardState(cell + 19) = 1 + + GOTO 2 + END IF +NEXT cell +LOCATE 4, 5 +PRINT " Y O U W O N !" +END +GOTO 3 +2 +UpdateDisplay +9 +END SUB + +SUB UpdateDisplay + ' Draw the pieces on the board + FOR row = 1 TO 10 + FOR col = 1 TO 10 + pieceType = boardState(((row - 1) * 20) + col) + SELECT CASE pieceType + CASE 1 + CIRCLE (col * 40, row * 18), 17, 1 + PAINT (col * 40, row * 18), 1 + CIRCLE (col * 40, row * 18), 17, 0 + CIRCLE (col * 40, row * 18), 16, 0 + LINE ((col * 40) - 16, row * 18)-((col * 40) + 16, row * 18), 0 + CASE 0 + CIRCLE (col * 40, row * 18), 17, 0 + PAINT (col * 40, row * 18), 0 + CIRCLE (col * 40, row * 18), 17, 1 + CIRCLE (col * 40, row * 18), 15, 1 + CIRCLE (col * 40, row * 18), 3, 1 + CIRCLE (col * 40, row * 18), 7, 1 + LINE ((col * 40) - 16, row * 18)-((col * 40) + 16, row * 18), 0 + CASE 3 + PAINT (col * 40, row * 18), 1 + END SELECT + NEXT col + NEXT row +END SUB + diff --git a/Games/checkers.png b/Games/checkers.png new file mode 100644 index 0000000..2933880 Binary files /dev/null and b/Games/checkers.png differ diff --git a/Math/Plotting/logo.png b/Math/Plotting/logo.png new file mode 100644 index 0000000..b07f063 Binary files /dev/null and b/Math/Plotting/logo.png differ diff --git a/Math/Simulation/logo.png b/Math/Simulation/logo.png new file mode 100644 index 0000000..b7e4b8b Binary files /dev/null and b/Math/Simulation/logo.png differ diff --git a/Math/Truth table calculator/img/screenshot, 1.png b/Math/Truth table calculator/img/screenshot, 1.png deleted file mode 100644 index b2a4218..0000000 Binary files a/Math/Truth table calculator/img/screenshot, 1.png and /dev/null differ diff --git a/Math/Truth table calculator/img/screenshot, 2.png b/Math/Truth table calculator/img/screenshot, 2.png deleted file mode 100644 index e64bc42..0000000 Binary files a/Math/Truth table calculator/img/screenshot, 2.png and /dev/null differ diff --git a/Math/Truth table calculator/img/screenshot, 3.png b/Math/Truth table calculator/img/screenshot, 3.png deleted file mode 100644 index c5b9612..0000000 Binary files a/Math/Truth table calculator/img/screenshot, 3.png and /dev/null differ diff --git a/Math/Truth table calculator/index.html b/Math/Truth table calculator/index.html deleted file mode 100644 index 89a2606..0000000 --- a/Math/Truth table calculator/index.html +++ /dev/null @@ -1,1683 +0,0 @@ - - - - - - - -Truth table calculator - - - - - - - - - - - - - - - - - - -
-

Truth table calculator

- - - -

-A truth table is a mathematical table used to determine the output of a logic function -based on all possible combinations of inputs. Each row represents a possible state of -the input variables, with the corresponding output value. Truth tables are crucial in -designing and understanding digital circuits, Boolean algebra, and logical expressions. -

- -
-

1. Implemented logical operations

-
-
-
-

1.1. Equivalent ( ⇔ , 1 )

-
-

-The equivalent operation, also known as logical biconditional, is true if and only if -both inputs are the same. In other words, it asserts that both propositions are -either both true or both false. It is often represented by the symbol ⇔. -

- -

-Truth Table: -

- - - - --- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABA ⇔ B
TTT
TFF
FTF
FFT
-
-
- -
-

1.2. Implies ( ⇒ , 2 )

-
-

-An implication asserts that if the first proposition is true, the -second must be true as well. If the first is false, the implication -holds regardless of the second proposition's value. -

- -

-Truth table: -

- - - - --- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABA ⇒ B
TTT
TFF
FTT
FFT
-
-
- -
-

1.3. OR ( ∨ , 3 )

-
-

-The OR operation, also known as logical disjunction, is true if at -least one of the inputs is true. It asserts that if either proposition -is true, the entire expression is true. -

- -

-Truth table: -

- - - - --- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABA ∨ B
TTT
TFT
FTT
FFF
-
-
- -
-

1.4. AND ( ∧ , 4 )

-
-

-The AND operation, also known as logical conjunction, is true if and -only if both inputs are true. -

- -

-Truth table: -

- - - - --- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABA ∧ B
TTT
TFF
FTF
FFF
-
-
- -
-

1.5. NOT ( ¬ , 5 )

-
-

-The NOT operation, also known as logical negation, inverts the value -of the input. If the input is true, the output is false, and vice -versa. -

- -

-Truth Table: -

- - - - --- -- - - - - - - - - - - - - - - - - - -
A¬A
TF
FT
-
-
-
-
-

2. Examples

-
-
-
-

2.1. Example: (A ∧ B) ∨ ¬C

-
- - - --- -- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABC(A ∧ B) ∨ ¬C
TTTT
TTFT
TFTF
TFFT
FTTF
FTFT
FFTF
FFFT
-
-
- -
-

2.2. Example: A ⇒ (B ∨ ¬C)

-
- - - --- -- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABCA ⇒ (B ∨ ¬C)
TTTT
TTFT
TFTF
TFFT
FTTT
FTFT
FFTT
FFFT
-
-
- -
-

2.3. Example: (A ⇔ B) ∧ C

-
-

-Truth Table: -

- - - - --- -- -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ABC(A ⇔ B) ∧ C
TTTT
TTFF
TFTF
TFFF
FTTF
FTFF
FFTT
FFFF
-
-
-
-
-
-

Created: 2025-05-31 la 07:09

-

Validate

-
- - diff --git a/Math/Truth table calculator/index.org b/Math/Truth table calculator/index.org deleted file mode 100644 index cd58c50..0000000 --- a/Math/Truth table calculator/index.org +++ /dev/null @@ -1,131 +0,0 @@ -#+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme -#+TITLE: Truth table calculator -#+LANGUAGE: en -#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} -#+LATEX_HEADER: \usepackage{parskip} -#+LATEX_HEADER: \usepackage[none]{hyphenat} - -#+OPTIONS: H:20 num:20 -#+OPTIONS: author:nil - -- See also: https://en.wikipedia.org/wiki/Truth_table - -A truth table is a mathematical table used to determine the output of a logic function -based on all possible combinations of inputs. Each row represents a possible state of -the input variables, with the corresponding output value. Truth tables are crucial in -designing and understanding digital circuits, Boolean algebra, and logical expressions. - -* Implemented logical operations -** Equivalent ( ⇔ , 1 ) - -The equivalent operation, also known as logical biconditional, is true if and only if -both inputs are the same. In other words, it asserts that both propositions are -either both true or both false. It is often represented by the symbol *⇔*. - -Truth Table: - -| A | B | A ⇔ B | -|---+---+-------| -| T | T | T | -| T | F | F | -| F | T | F | -| F | F | T | - -** Implies ( ⇒ , 2 ) - -An implication asserts that if the first proposition is true, the -second must be true as well. If the first is false, the implication -holds regardless of the second proposition's value. - -Truth table: - -| A | B | A ⇒ B | -|---+---+-------| -| T | T | T | -| T | F | F | -| F | T | T | -| F | F | T | - -** OR ( ∨ , 3 ) - -The OR operation, also known as logical disjunction, is true if at -least one of the inputs is true. It asserts that if either proposition -is true, the entire expression is true. - -Truth table: - -| A | B | A ∨ B | -|---+---+-------| -| T | T | T | -| T | F | T | -| F | T | T | -| F | F | F | - -** AND ( ∧ , 4 ) - -The AND operation, also known as logical conjunction, is true if and -only if both inputs are true. - -Truth table: - -| A | B | A ∧ B | -|---+---+-------| -| T | T | T | -| T | F | F | -| F | T | F | -| F | F | F | - -** NOT ( ¬ , 5 ) - -The NOT operation, also known as logical negation, inverts the value -of the input. If the input is true, the output is false, and vice -versa. - -Truth Table: - -| A | ¬A | -|---+----| -| T | F | -| F | T | -* Examples - -** Example: (A ∧ B) ∨ ¬C - -| A | B | C | (A ∧ B) ∨ ¬C | -|---+---+---+--------------| -| T | T | T | T | -| T | T | F | T | -| T | F | T | F | -| T | F | F | T | -| F | T | T | F | -| F | T | F | T | -| F | F | T | F | -| F | F | F | T | - -** Example: A ⇒ (B ∨ ¬C) - -| A | B | C | A ⇒ (B ∨ ¬C) | -|---+---+---+--------------| -| T | T | T | T | -| T | T | F | T | -| T | F | T | F | -| T | F | F | T | -| F | T | T | T | -| F | T | F | T | -| F | F | T | T | -| F | F | F | T | - -** Example: (A ⇔ B) ∧ C - -Truth Table: - -| A | B | C | (A ⇔ B) ∧ C | -|---+---+---+-------------| -| T | T | T | T | -| T | T | F | F | -| T | F | T | F | -| T | F | F | F | -| F | T | T | F | -| F | T | F | F | -| F | F | T | T | -| F | F | F | F | diff --git a/Math/Truth table calculator/truth.bas b/Math/Truth table calculator/truth.bas deleted file mode 100755 index ee39e82..0000000 --- a/Math/Truth table calculator/truth.bas +++ /dev/null @@ -1,597 +0,0 @@ -' TRUTH TABLE CALCULATOR -' -' This program is free software: released under Creative Commons Zero (CC0) license -' by Svjatoslav Agejenko. -' Email: svjatoslav@svjatoslav.eu -' Homepage: http://www.svjatoslav.eu -' -' Changelog: -' 2002, Initial version -' 2024 - 2025, Improved program readability -' -' -' A truth table is a mathematical table used to determine the output of a -' logic function based on all possible combinations of inputs. Each row -' represents a possible state of the input variables, with the -' corresponding output value. Truth tables are crucial in designing and -' understanding digital circuits, Boolean algebra, and logical -' expressions. -' -' Implemented operations: -' Equivalent ( Keyboard shortcut: 1 ) -' Implies ( Keyboard shortcut: 2 ) -' OR ( Keyboard shortcut: 3 ) -' AND ( Keyboard shortcut: 4 ) -' NOT ( Keyboard shortcut: 5 ) - -DECLARE SUB removeRedundancies (startIndex!, endIndex!, removalCount!) -DECLARE SUB getOperatorPriority (a!, b!) -DECLARE SUB movM (x1!, n!) -DECLARE SUB clearScreenBuffer () -DECLARE SUB lendm (x1!, m!) -DECLARE SUB mov (x1!, n!) -DECLARE SUB lendp (x1!, m!) -DECLARE SUB teeslg (x1!, x2!, l!) -DECLARE SUB prepare () -DECLARE SUB tee (x1!, x2!) -DECLARE SUB lahend (x1, x2) -DECLARE SUB printText (x!, y!, c!, c1!, a$) -DECLARE SUB sist () -DECLARE SUB start () -DIM SHARED font(0 TO 7, 0 TO 7, 0 TO 122) - -' Logical expression storage and processing arrays -DIM SHARED logicalExpression(0 TO 79) ' Stores ASCII values of logical expression -DIM SHARED variableValues(1 TO 8, 1 TO 100) ' Stores variable values for each combination -DIM SHARED variableNames(1 TO 8) ' Stores ASCII values of variable names -DIM SHARED resultValues(1 TO 100) ' Stores computed result values -DIM SHARED expressionPosition(0 TO 79) ' Stores screen positions of expression characters -DIM SHARED xlahn -DIM SHARED tehl -DIM SHARED nm -DIM SHARED prnp - -start - -13 -sist -prepare -GOTO 13 - -SUB clearScreenBuffer -' Waits for user input to clear the screen buffer -FOR a = 1 TO 50 - a$ = INKEY$ -NEXT a -END SUB - -SUB getOperatorPriority (operator, priority) -' Determines the priority of logical operators -SELECT CASE operator - CASE 5 ' NOT - priority = 1 - CASE 3, 4 ' OR, AND - priority = 2 - CASE 2 ' Implies - priority = 3 - CASE 1 ' Equivalent - priority = 4 - CASE 40, 41 ' Parentheses - priority = 100 -END SELECT -END SUB - - -SUB lahend (x1, x2) -' Analyzes and prepares the logical equation for solving -DIM muu(65 TO 122) -FOR a = 65 TO 122 - muu(a) = 0 -NEXT a - -muu(116) = 1 ' t -muu(118) = 1 ' v - -nm = 0 -FOR a = x1 TO x2 - b = logicalExpression(a) - IF ((b >= 65) AND (b <= 90)) OR ((b >= 97) AND (b <= 122)) THEN - IF muu(b) = 0 THEN - nm = nm + 1 - variableNames(nm) = b - muu(b) = 1 - END IF - END IF -NEXT a - -variableNames(nm + 1) = 116 ' t -variableNames(nm + 2) = 118 ' v - -f = 2 ^ nm -tehl = f -FOR a = 1 TO nm - d = 1 - e = 1 - f = f / 2 - FOR b = 1 TO 2 ^ nm - IF e > f THEN d = -d: e = 1 - IF d = 1 THEN c = ASC("t") ELSE c = ASC("v") - variableValues(a, b) = c - e = e + 1 - NEXT b -NEXT a - -FOR a = 1 TO tehl - variableValues(nm + 1, a) = 116 ' t - variableValues(nm + 2, a) = 118 ' v -NEXT a - -nm = nm + 2 - -DIM bck(0 TO 79) -FOR a = 0 TO 79 - bck(a) = logicalExpression(a) - expressionPosition(a) = a -NEXT a - -LOCATE 5, 1 -teeslg x1, x2, a - -tee x1, x2 + a - -FOR a = 0 TO 79 - logicalExpression(a) = bck(a) -NEXT a - -FOR a = 1 TO tehl - printText x2 + 1, a, 14, 0, CHR$(resultValues(a)) -NEXT a - -END SUB - -SUB lendm (x1, m) -' Measures the length of a logical expression enclosed in parentheses -IF logicalExpression(x1) <> 41 THEN m = 1: GOTO 19 -c = x1 -d = 1 -20 -c = c - 1 -IF logicalExpression(c) = 40 THEN d = d - 1 -IF logicalExpression(c) = 41 THEN d = d + 1 -IF d > 0 THEN GOTO 20 -m = x1 - c -19 -END SUB - -SUB lendp (x1, m) -' Measures the length of a logical expression enclosed in parentheses -IF logicalExpression(x1) <> 40 THEN m = 1: GOTO 17 -c = x1 -d = 1 -18 -c = c + 1 -IF logicalExpression(c) = 40 THEN d = d + 1 -IF logicalExpression(c) = 41 THEN d = d - 1 -IF d > 0 THEN GOTO 18 -m = c - x1 + 1 -17 -END SUB - -SUB mov (x1, n) -' Moves a portion of the logical expression to the right -FOR a = 79 - n TO x1 STEP -1 - logicalExpression(a + n) = logicalExpression(a) - expressionPosition(a + n) = expressionPosition(a) -NEXT a -END SUB - -SUB movM (x1, n) -' Moves a portion of the logical expression to the left -FOR a = x1 TO 79 - n - logicalExpression(a) = logicalExpression(a + n) - expressionPosition(a) = expressionPosition(a + n) -NEXT a -END SUB - -SUB prepare -' Prepares the logical equation for processing -CLS - -ln = 79 -FOR a = 0 TO 79 -5 - IF logicalExpression(a) = 32 OR logicalExpression(a) = 0 THEN - FOR b = a TO 78 - logicalExpression(b) = logicalExpression(b + 1) - NEXT b - ln = ln - 1 - IF ln <= a - 1 THEN GOTO 6 - GOTO 5 - END IF -NEXT a -6 - -CLS - -FOR a = 0 TO ln - printText a, 0, 13, 1, CHR$(logicalExpression(a)) -NEXT a - -printText 0, 1, 7, 0, SPACE$(79) - -lahend 0, ln - -a$ = INPUT$(1) - -END SUB - -SUB printText (x, y, c, c1, a$) - ' Prints characters to the screen at location (x,y) with color c, background c1 - x1 = x * 8 - y1 = (y + prnp) * 8 - - FOR b = 1 TO LEN(a$) - LINE (x1, y1)-(x1 + 7, y1 + 7), c1, BF - d = ASC(RIGHT$(LEFT$(a$, b), 1)) - IF d > 122 THEN GOTO 22 - FOR y2 = 0 TO 7 - FOR x2 = 0 TO 7 - c2 = font(x2, y2, d) - IF c2 > 0 THEN PSET (x1 + x2, y1 + y2), c - NEXT x2 - NEXT y2 -22 x1 = x1 + 8 - NEXT b - -END SUB - -SUB removeRedundancies (startIndex, endIndex, removalCount) - ' This procedure scans for parentheses that can be safely removed - ' without changing the logic of the expression, then removes them. - - DIM currentEnd, parenthesesCount - currentEnd = endIndex - parenthesesCount = 0 - - a = startIndex -26 IF logicalExpression(a) = 40 THEN - ' We found an opening parenthesis. Now let's see if it can be removed. - IF a = startIndex THEN p1 = 100 ELSE getOperatorPriority logicalExpression(a - 1), p1 - - c = a - d = 1 - p2 = 0 - -25 c = c + 1 - IF logicalExpression(c) = 40 THEN d = d + 1 - IF logicalExpression(c) = 41 THEN d = d - 1 - - ' Once d returns to 1, we are back to one level of parentheses, - ' meaning we can check operator priority inside. - IF d = 1 THEN - IF (logicalExpression(c) > 0) AND (logicalExpression(c) <= 5) THEN - getOperatorPriority logicalExpression(c), b - IF b > p2 THEN p2 = b - END IF - END IF - - IF d > 0 THEN GOTO 25 - - IF c + 1 > currentEnd THEN p3 = 100 ELSE getOperatorPriority logicalExpression(c + 1), p3 - - ' If the operator outside is higher priority than what's inside, - ' we can safely remove the parentheses. - IF (p1 > p2) AND (p3 >= p2) THEN - movM c, 1 - movM a, 1 - parenthesesCount = parenthesesCount + 2 - currentEnd = currentEnd - 2 - a = a - 1 - END IF - END IF - - a = a + 1 - IF a <= currentEnd THEN GOTO 26 - - removalCount = parenthesesCount -END SUB - -SUB sist -' Interacts with the user to input a logical equation -CLS -printText 0, 0, 3, 0, "Enter equation (ESC to quit) keys: 1 - " + CHR$(1) + " 2 - " + CHR$(2) + " 3 - " + CHR$(3) + " 4 - " + CHR$(4) + " 5 - " + CHR$(5) -printText 0, 1, 3, 0, "Example: a" + CHR$(1) + "b" + CHR$(2) + "(g" + CHR$(3) + "b)" - -FOR a = 0 TO 79 - logicalExpression(a) = 0 -NEXT a - -x = 0 -1 -FOR a = 0 TO 79 - IF a = x THEN printText a, 2, 14, 1, CHR$(logicalExpression(a)) ELSE printText a, 2, 3, 0, CHR$(logicalExpression(a)) -NEXT a -2 -a$ = INKEY$ -IF a$ = "" THEN GOTO 2 - -IF a$ = CHR$(27) THEN SYSTEM -IF a$ = CHR$(0) + "M" THEN x = x + 1 -IF a$ = CHR$(0) + "K" THEN x = x - 1 -IF x < 0 THEN x = 0 -IF x > 79 THEN x = 79 - -IF LEN(a$) = 1 THEN - SELECT CASE ASC(a$) - CASE 32, 40, 41, 65 TO 90, 97 TO 122 -3 - FOR a = 78 TO x STEP -1 - logicalExpression(a + 1) = logicalExpression(a) - NEXT a - logicalExpression(x) = ASC(a$) - x = x + 1 - CASE 8 - IF x > 0 THEN - FOR a = x - 1 TO 78 - logicalExpression(a) = logicalExpression(a + 1) - NEXT a - x = x - 1 - END IF - CASE 49 TO 53 - a$ = CHR$(ASC(a$) - 48) - GOTO 3 - CASE 13 - GOTO 4 - END SELECT -END IF - -GOTO 1 -4 - -END SUB - -SUB start -' Initializes the screen and font -prnp = 0 - -SCREEN 7 - -FOR a = 0 TO 122 - LOCATE 1, 1 - SELECT CASE a - CASE 7 - CASE 1 - LINE (0, 0)-(7, 7), 0, BF - LINE (2, 1)-(0, 3), 15 - LINE (1, 4)-(2, 5), 15 - LINE (5, 1)-(7, 3), 15 - LINE (6, 4)-(5, 5), 15 - LINE (1, 2)-(5, 2), 15 - LINE (1, 4)-(5, 4), 15 - - CASE 2 - LINE (0, 0)-(7, 7), 0, BF - LINE (5, 1)-(7, 3), 15 - LINE (6, 4)-(5, 5), 15 - LINE (1, 2)-(5, 2), 15 - LINE (1, 4)-(5, 4), 15 - - CASE 3 - LINE (0, 0)-(7, 7), 0, BF - LINE (0, 0)-(3, 7), 15 - LINE (6, 0)-(3, 7), 15 - - CASE 4 - LINE (0, 0)-(7, 7), 0, BF - LINE (0, 7)-(3, 0), 15 - LINE (6, 7)-(3, 0), 15 - - CASE 5 - LINE (0, 0)-(7, 7), 0, BF - LINE (0, 0)-(4, 0), 15 - LINE (4, 1)-(4, 7), 15 - - CASE ELSE - PRINT CHR$(a) - END SELECT - - FOR y = 0 TO 7 - FOR x = 0 TO 7 - font(x, y, a) = POINT(x, y) - NEXT x - NEXT y -NEXT a - -SCREEN 12 - -END SUB - -SUB tee (x1, x2) -' Processes the logical equation and applies logical operations -DIM opr(1 TO 2, 1 TO tehl) -ng = 0 -ngx = 0 -oprm = 1 -oe = 0 -oex = 0 - -FOR a = x1 TO x2 - b = logicalExpression(a) - SELECT CASE b - CASE 40 - c = a - d = 1 -10 - c = c + 1 - IF logicalExpression(c) = ASC("(") THEN d = d + 1 - IF logicalExpression(c) = ASC(")") THEN d = d - 1 - IF d = 0 THEN GOTO 11 - GOTO 10 -11 - tee a + 1, c - 1 - a = c - FOR c = 1 TO tehl - opr(oprm, c) = resultValues(c) - NEXT c - GOTO 12 - CASE 5 - ng = 1 - ngx = a - CASE 1 TO 4 - oe = b - oex = a - CASE 65 TO 90, 97 TO 122 - FOR c = 1 TO nm - IF variableNames(c) = b THEN d = c: GOTO 8 - NEXT c -8 - FOR c = 1 TO tehl - opr(oprm, c) = variableValues(d, c) - printText expressionPosition(a), c, 3, 0, CHR$(variableValues(d, c)) - NEXT c -12 - IF ng = 1 THEN GOSUB mkneg - IF oprm = 2 THEN - SELECT CASE oe - CASE 1 - FOR c = 1 TO tehl - d = opr(1, c) - e = opr(2, c) - IF d = e THEN f = ASC("t") ELSE f = ASC("v") - opr(1, c) = f - printText expressionPosition(oex), c, 12, 0, CHR$(f) - NEXT c - CASE 2 - FOR c = 1 TO tehl - d = opr(1, c) - e = opr(2, c) - f = ASC("t") - IF (d = ASC("t")) AND (e = ASC("v")) THEN f = ASC("v") - opr(1, c) = f - printText expressionPosition(oex), c, 12, 0, CHR$(f) - NEXT c - CASE 3 - FOR c = 1 TO tehl - d = opr(1, c) - e = opr(2, c) - f = ASC("t") - IF (d = ASC("v")) AND (e = ASC("v")) THEN f = ASC("v") - opr(1, c) = f - printText expressionPosition(oex), c, 12, 0, CHR$(f) - NEXT c - CASE 4 - FOR c = 1 TO tehl - d = opr(1, c) - e = opr(2, c) - f = ASC("v") - IF (d = ASC("t")) AND (e = ASC("t")) THEN f = ASC("t") - opr(1, c) = f - printText expressionPosition(oex), c, 12, 0, CHR$(f) - NEXT c - END SELECT - ELSE - oprm = oprm + 1 - END IF - END SELECT -NEXT a - -GOTO 9 - -mkneg: - ' NOT operation (negation) is applied to the current operand - FOR c = 1 TO tehl - d = opr(oprm, c) - IF d = ASC("t") THEN d = ASC("v") ELSE d = ASC("t") - printText expressionPosition(ngx), c, 4, 0, CHR$(d) - opr(oprm, c) = d - NEXT c - ng = 0 -RETURN -9 - -FOR c = 1 TO tehl - resultValues(c) = opr(1, c) -NEXT c -END SUB - -SUB teeslg (x1, x4, l) -' Prepares the logical equation for solving by simplifying expressions within parentheses -x2 = x4 -h = 0 -FOR e = 1 TO 4 - g = 1 - a = x1 -21 - b = logicalExpression(a) - IF b = 40 THEN - c = a - d = 1 -14 - c = c + 1 - IF logicalExpression(c) = ASC("(") THEN d = d + 1 - IF logicalExpression(c) = ASC(")") THEN d = d - 1 - IF d = 0 THEN GOTO 15 - GOTO 14 -15 - IF e = 1 THEN teeslg a + 1, c - 1, l ELSE l = 0 - a = c + l - x2 = x2 + l - h = h + l - GOTO 16 - END IF - - IF (b = 5) AND (e = 1) AND (g > 1) THEN - mov a, 1 - logicalExpression(a) = 40 - lendp a + 2, f - mov a + 2 + f, 1 - logicalExpression(a + 2 + f) = 41 - h = h + 2 - x2 = x2 + 2 - a = a + 2 + f - GOTO 16 - END IF - - IF (b = 3 OR b = 4) AND (e = 2) AND (g > 2) THEN - lendm a - 1, f - mov a - f, 1 - logicalExpression(a - f) = 40 - lendp a + 2, f - mov a + 2 + f, 1 - logicalExpression(a + 2 + f) = 41 - h = h + 2 - x2 = x2 + 2 - a = a + 2 + f - GOTO 16 - END IF - - IF (b = 2) AND (e = 3) AND (g > 3) THEN - lendm a - 1, f - mov a - f, 1 - logicalExpression(a - f) = 40 - lendp a + 2, f - mov a + 2 + f, 1 - logicalExpression(a + 2 + f) = 41 - h = h + 2 - x2 = x2 + 2 - a = a + 2 + f - GOTO 16 - END IF - - SELECT CASE b - CASE 5 - g = 1 - CASE 3, 4 - g = 2 - CASE 2 - g = 3 - CASE 1 - g = 4 - END SELECT -16 - a = a + 1 - IF a <= x2 THEN GOTO 21 -NEXT e -l = h -END SUB - diff --git a/Math/Truth table/img/screenshot, 1.png b/Math/Truth table/img/screenshot, 1.png new file mode 100644 index 0000000..b2a4218 Binary files /dev/null and b/Math/Truth table/img/screenshot, 1.png differ diff --git a/Math/Truth table/img/screenshot, 2.png b/Math/Truth table/img/screenshot, 2.png new file mode 100644 index 0000000..e64bc42 Binary files /dev/null and b/Math/Truth table/img/screenshot, 2.png differ diff --git a/Math/Truth table/img/screenshot, 3.png b/Math/Truth table/img/screenshot, 3.png new file mode 100644 index 0000000..c5b9612 Binary files /dev/null and b/Math/Truth table/img/screenshot, 3.png differ diff --git a/Math/Truth table/index.html b/Math/Truth table/index.html new file mode 100644 index 0000000..89a2606 --- /dev/null +++ b/Math/Truth table/index.html @@ -0,0 +1,1683 @@ + + + + + + + +Truth table calculator + + + + + + + + + + + + + + + + + + +
+

Truth table calculator

+ + + +

+A truth table is a mathematical table used to determine the output of a logic function +based on all possible combinations of inputs. Each row represents a possible state of +the input variables, with the corresponding output value. Truth tables are crucial in +designing and understanding digital circuits, Boolean algebra, and logical expressions. +

+ +
+

1. Implemented logical operations

+
+
+
+

1.1. Equivalent ( ⇔ , 1 )

+
+

+The equivalent operation, also known as logical biconditional, is true if and only if +both inputs are the same. In other words, it asserts that both propositions are +either both true or both false. It is often represented by the symbol ⇔. +

+ +

+Truth Table: +

+ + + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABA ⇔ B
TTT
TFF
FTF
FFT
+
+
+ +
+

1.2. Implies ( ⇒ , 2 )

+
+

+An implication asserts that if the first proposition is true, the +second must be true as well. If the first is false, the implication +holds regardless of the second proposition's value. +

+ +

+Truth table: +

+ + + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABA ⇒ B
TTT
TFF
FTT
FFT
+
+
+ +
+

1.3. OR ( ∨ , 3 )

+
+

+The OR operation, also known as logical disjunction, is true if at +least one of the inputs is true. It asserts that if either proposition +is true, the entire expression is true. +

+ +

+Truth table: +

+ + + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABA ∨ B
TTT
TFT
FTT
FFF
+
+
+ +
+

1.4. AND ( ∧ , 4 )

+
+

+The AND operation, also known as logical conjunction, is true if and +only if both inputs are true. +

+ +

+Truth table: +

+ + + + +++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABA ∧ B
TTT
TFF
FTF
FFF
+
+
+ +
+

1.5. NOT ( ¬ , 5 )

+
+

+The NOT operation, also known as logical negation, inverts the value +of the input. If the input is true, the output is false, and vice +versa. +

+ +

+Truth Table: +

+ + + + +++ ++ + + + + + + + + + + + + + + + + + +
A¬A
TF
FT
+
+
+
+
+

2. Examples

+
+
+
+

2.1. Example: (A ∧ B) ∨ ¬C

+
+ + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABC(A ∧ B) ∨ ¬C
TTTT
TTFT
TFTF
TFFT
FTTF
FTFT
FFTF
FFFT
+
+
+ +
+

2.2. Example: A ⇒ (B ∨ ¬C)

+
+ + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABCA ⇒ (B ∨ ¬C)
TTTT
TTFT
TFTF
TFFT
FTTT
FTFT
FFTT
FFFT
+
+
+ +
+

2.3. Example: (A ⇔ B) ∧ C

+
+

+Truth Table: +

+ + + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABC(A ⇔ B) ∧ C
TTTT
TTFF
TFTF
TFFF
FTTF
FTFF
FFTT
FFFF
+
+
+
+
+
+

Created: 2025-05-31 la 07:09

+

Validate

+
+ + diff --git a/Math/Truth table/index.org b/Math/Truth table/index.org new file mode 100644 index 0000000..cd58c50 --- /dev/null +++ b/Math/Truth table/index.org @@ -0,0 +1,131 @@ +#+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme +#+TITLE: Truth table calculator +#+LANGUAGE: en +#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} +#+LATEX_HEADER: \usepackage{parskip} +#+LATEX_HEADER: \usepackage[none]{hyphenat} + +#+OPTIONS: H:20 num:20 +#+OPTIONS: author:nil + +- See also: https://en.wikipedia.org/wiki/Truth_table + +A truth table is a mathematical table used to determine the output of a logic function +based on all possible combinations of inputs. Each row represents a possible state of +the input variables, with the corresponding output value. Truth tables are crucial in +designing and understanding digital circuits, Boolean algebra, and logical expressions. + +* Implemented logical operations +** Equivalent ( ⇔ , 1 ) + +The equivalent operation, also known as logical biconditional, is true if and only if +both inputs are the same. In other words, it asserts that both propositions are +either both true or both false. It is often represented by the symbol *⇔*. + +Truth Table: + +| A | B | A ⇔ B | +|---+---+-------| +| T | T | T | +| T | F | F | +| F | T | F | +| F | F | T | + +** Implies ( ⇒ , 2 ) + +An implication asserts that if the first proposition is true, the +second must be true as well. If the first is false, the implication +holds regardless of the second proposition's value. + +Truth table: + +| A | B | A ⇒ B | +|---+---+-------| +| T | T | T | +| T | F | F | +| F | T | T | +| F | F | T | + +** OR ( ∨ , 3 ) + +The OR operation, also known as logical disjunction, is true if at +least one of the inputs is true. It asserts that if either proposition +is true, the entire expression is true. + +Truth table: + +| A | B | A ∨ B | +|---+---+-------| +| T | T | T | +| T | F | T | +| F | T | T | +| F | F | F | + +** AND ( ∧ , 4 ) + +The AND operation, also known as logical conjunction, is true if and +only if both inputs are true. + +Truth table: + +| A | B | A ∧ B | +|---+---+-------| +| T | T | T | +| T | F | F | +| F | T | F | +| F | F | F | + +** NOT ( ¬ , 5 ) + +The NOT operation, also known as logical negation, inverts the value +of the input. If the input is true, the output is false, and vice +versa. + +Truth Table: + +| A | ¬A | +|---+----| +| T | F | +| F | T | +* Examples + +** Example: (A ∧ B) ∨ ¬C + +| A | B | C | (A ∧ B) ∨ ¬C | +|---+---+---+--------------| +| T | T | T | T | +| T | T | F | T | +| T | F | T | F | +| T | F | F | T | +| F | T | T | F | +| F | T | F | T | +| F | F | T | F | +| F | F | F | T | + +** Example: A ⇒ (B ∨ ¬C) + +| A | B | C | A ⇒ (B ∨ ¬C) | +|---+---+---+--------------| +| T | T | T | T | +| T | T | F | T | +| T | F | T | F | +| T | F | F | T | +| F | T | T | T | +| F | T | F | T | +| F | F | T | T | +| F | F | F | T | + +** Example: (A ⇔ B) ∧ C + +Truth Table: + +| A | B | C | (A ⇔ B) ∧ C | +|---+---+---+-------------| +| T | T | T | T | +| T | T | F | F | +| T | F | T | F | +| T | F | F | F | +| F | T | T | F | +| F | T | F | F | +| F | F | T | T | +| F | F | F | F | diff --git a/Math/Truth table/truth.bas b/Math/Truth table/truth.bas new file mode 100755 index 0000000..ee39e82 --- /dev/null +++ b/Math/Truth table/truth.bas @@ -0,0 +1,597 @@ +' TRUTH TABLE CALCULATOR +' +' This program is free software: released under Creative Commons Zero (CC0) license +' by Svjatoslav Agejenko. +' Email: svjatoslav@svjatoslav.eu +' Homepage: http://www.svjatoslav.eu +' +' Changelog: +' 2002, Initial version +' 2024 - 2025, Improved program readability +' +' +' A truth table is a mathematical table used to determine the output of a +' logic function based on all possible combinations of inputs. Each row +' represents a possible state of the input variables, with the +' corresponding output value. Truth tables are crucial in designing and +' understanding digital circuits, Boolean algebra, and logical +' expressions. +' +' Implemented operations: +' Equivalent ( Keyboard shortcut: 1 ) +' Implies ( Keyboard shortcut: 2 ) +' OR ( Keyboard shortcut: 3 ) +' AND ( Keyboard shortcut: 4 ) +' NOT ( Keyboard shortcut: 5 ) + +DECLARE SUB removeRedundancies (startIndex!, endIndex!, removalCount!) +DECLARE SUB getOperatorPriority (a!, b!) +DECLARE SUB movM (x1!, n!) +DECLARE SUB clearScreenBuffer () +DECLARE SUB lendm (x1!, m!) +DECLARE SUB mov (x1!, n!) +DECLARE SUB lendp (x1!, m!) +DECLARE SUB teeslg (x1!, x2!, l!) +DECLARE SUB prepare () +DECLARE SUB tee (x1!, x2!) +DECLARE SUB lahend (x1, x2) +DECLARE SUB printText (x!, y!, c!, c1!, a$) +DECLARE SUB sist () +DECLARE SUB start () +DIM SHARED font(0 TO 7, 0 TO 7, 0 TO 122) + +' Logical expression storage and processing arrays +DIM SHARED logicalExpression(0 TO 79) ' Stores ASCII values of logical expression +DIM SHARED variableValues(1 TO 8, 1 TO 100) ' Stores variable values for each combination +DIM SHARED variableNames(1 TO 8) ' Stores ASCII values of variable names +DIM SHARED resultValues(1 TO 100) ' Stores computed result values +DIM SHARED expressionPosition(0 TO 79) ' Stores screen positions of expression characters +DIM SHARED xlahn +DIM SHARED tehl +DIM SHARED nm +DIM SHARED prnp + +start + +13 +sist +prepare +GOTO 13 + +SUB clearScreenBuffer +' Waits for user input to clear the screen buffer +FOR a = 1 TO 50 + a$ = INKEY$ +NEXT a +END SUB + +SUB getOperatorPriority (operator, priority) +' Determines the priority of logical operators +SELECT CASE operator + CASE 5 ' NOT + priority = 1 + CASE 3, 4 ' OR, AND + priority = 2 + CASE 2 ' Implies + priority = 3 + CASE 1 ' Equivalent + priority = 4 + CASE 40, 41 ' Parentheses + priority = 100 +END SELECT +END SUB + + +SUB lahend (x1, x2) +' Analyzes and prepares the logical equation for solving +DIM muu(65 TO 122) +FOR a = 65 TO 122 + muu(a) = 0 +NEXT a + +muu(116) = 1 ' t +muu(118) = 1 ' v + +nm = 0 +FOR a = x1 TO x2 + b = logicalExpression(a) + IF ((b >= 65) AND (b <= 90)) OR ((b >= 97) AND (b <= 122)) THEN + IF muu(b) = 0 THEN + nm = nm + 1 + variableNames(nm) = b + muu(b) = 1 + END IF + END IF +NEXT a + +variableNames(nm + 1) = 116 ' t +variableNames(nm + 2) = 118 ' v + +f = 2 ^ nm +tehl = f +FOR a = 1 TO nm + d = 1 + e = 1 + f = f / 2 + FOR b = 1 TO 2 ^ nm + IF e > f THEN d = -d: e = 1 + IF d = 1 THEN c = ASC("t") ELSE c = ASC("v") + variableValues(a, b) = c + e = e + 1 + NEXT b +NEXT a + +FOR a = 1 TO tehl + variableValues(nm + 1, a) = 116 ' t + variableValues(nm + 2, a) = 118 ' v +NEXT a + +nm = nm + 2 + +DIM bck(0 TO 79) +FOR a = 0 TO 79 + bck(a) = logicalExpression(a) + expressionPosition(a) = a +NEXT a + +LOCATE 5, 1 +teeslg x1, x2, a + +tee x1, x2 + a + +FOR a = 0 TO 79 + logicalExpression(a) = bck(a) +NEXT a + +FOR a = 1 TO tehl + printText x2 + 1, a, 14, 0, CHR$(resultValues(a)) +NEXT a + +END SUB + +SUB lendm (x1, m) +' Measures the length of a logical expression enclosed in parentheses +IF logicalExpression(x1) <> 41 THEN m = 1: GOTO 19 +c = x1 +d = 1 +20 +c = c - 1 +IF logicalExpression(c) = 40 THEN d = d - 1 +IF logicalExpression(c) = 41 THEN d = d + 1 +IF d > 0 THEN GOTO 20 +m = x1 - c +19 +END SUB + +SUB lendp (x1, m) +' Measures the length of a logical expression enclosed in parentheses +IF logicalExpression(x1) <> 40 THEN m = 1: GOTO 17 +c = x1 +d = 1 +18 +c = c + 1 +IF logicalExpression(c) = 40 THEN d = d + 1 +IF logicalExpression(c) = 41 THEN d = d - 1 +IF d > 0 THEN GOTO 18 +m = c - x1 + 1 +17 +END SUB + +SUB mov (x1, n) +' Moves a portion of the logical expression to the right +FOR a = 79 - n TO x1 STEP -1 + logicalExpression(a + n) = logicalExpression(a) + expressionPosition(a + n) = expressionPosition(a) +NEXT a +END SUB + +SUB movM (x1, n) +' Moves a portion of the logical expression to the left +FOR a = x1 TO 79 - n + logicalExpression(a) = logicalExpression(a + n) + expressionPosition(a) = expressionPosition(a + n) +NEXT a +END SUB + +SUB prepare +' Prepares the logical equation for processing +CLS + +ln = 79 +FOR a = 0 TO 79 +5 + IF logicalExpression(a) = 32 OR logicalExpression(a) = 0 THEN + FOR b = a TO 78 + logicalExpression(b) = logicalExpression(b + 1) + NEXT b + ln = ln - 1 + IF ln <= a - 1 THEN GOTO 6 + GOTO 5 + END IF +NEXT a +6 + +CLS + +FOR a = 0 TO ln + printText a, 0, 13, 1, CHR$(logicalExpression(a)) +NEXT a + +printText 0, 1, 7, 0, SPACE$(79) + +lahend 0, ln + +a$ = INPUT$(1) + +END SUB + +SUB printText (x, y, c, c1, a$) + ' Prints characters to the screen at location (x,y) with color c, background c1 + x1 = x * 8 + y1 = (y + prnp) * 8 + + FOR b = 1 TO LEN(a$) + LINE (x1, y1)-(x1 + 7, y1 + 7), c1, BF + d = ASC(RIGHT$(LEFT$(a$, b), 1)) + IF d > 122 THEN GOTO 22 + FOR y2 = 0 TO 7 + FOR x2 = 0 TO 7 + c2 = font(x2, y2, d) + IF c2 > 0 THEN PSET (x1 + x2, y1 + y2), c + NEXT x2 + NEXT y2 +22 x1 = x1 + 8 + NEXT b + +END SUB + +SUB removeRedundancies (startIndex, endIndex, removalCount) + ' This procedure scans for parentheses that can be safely removed + ' without changing the logic of the expression, then removes them. + + DIM currentEnd, parenthesesCount + currentEnd = endIndex + parenthesesCount = 0 + + a = startIndex +26 IF logicalExpression(a) = 40 THEN + ' We found an opening parenthesis. Now let's see if it can be removed. + IF a = startIndex THEN p1 = 100 ELSE getOperatorPriority logicalExpression(a - 1), p1 + + c = a + d = 1 + p2 = 0 + +25 c = c + 1 + IF logicalExpression(c) = 40 THEN d = d + 1 + IF logicalExpression(c) = 41 THEN d = d - 1 + + ' Once d returns to 1, we are back to one level of parentheses, + ' meaning we can check operator priority inside. + IF d = 1 THEN + IF (logicalExpression(c) > 0) AND (logicalExpression(c) <= 5) THEN + getOperatorPriority logicalExpression(c), b + IF b > p2 THEN p2 = b + END IF + END IF + + IF d > 0 THEN GOTO 25 + + IF c + 1 > currentEnd THEN p3 = 100 ELSE getOperatorPriority logicalExpression(c + 1), p3 + + ' If the operator outside is higher priority than what's inside, + ' we can safely remove the parentheses. + IF (p1 > p2) AND (p3 >= p2) THEN + movM c, 1 + movM a, 1 + parenthesesCount = parenthesesCount + 2 + currentEnd = currentEnd - 2 + a = a - 1 + END IF + END IF + + a = a + 1 + IF a <= currentEnd THEN GOTO 26 + + removalCount = parenthesesCount +END SUB + +SUB sist +' Interacts with the user to input a logical equation +CLS +printText 0, 0, 3, 0, "Enter equation (ESC to quit) keys: 1 - " + CHR$(1) + " 2 - " + CHR$(2) + " 3 - " + CHR$(3) + " 4 - " + CHR$(4) + " 5 - " + CHR$(5) +printText 0, 1, 3, 0, "Example: a" + CHR$(1) + "b" + CHR$(2) + "(g" + CHR$(3) + "b)" + +FOR a = 0 TO 79 + logicalExpression(a) = 0 +NEXT a + +x = 0 +1 +FOR a = 0 TO 79 + IF a = x THEN printText a, 2, 14, 1, CHR$(logicalExpression(a)) ELSE printText a, 2, 3, 0, CHR$(logicalExpression(a)) +NEXT a +2 +a$ = INKEY$ +IF a$ = "" THEN GOTO 2 + +IF a$ = CHR$(27) THEN SYSTEM +IF a$ = CHR$(0) + "M" THEN x = x + 1 +IF a$ = CHR$(0) + "K" THEN x = x - 1 +IF x < 0 THEN x = 0 +IF x > 79 THEN x = 79 + +IF LEN(a$) = 1 THEN + SELECT CASE ASC(a$) + CASE 32, 40, 41, 65 TO 90, 97 TO 122 +3 + FOR a = 78 TO x STEP -1 + logicalExpression(a + 1) = logicalExpression(a) + NEXT a + logicalExpression(x) = ASC(a$) + x = x + 1 + CASE 8 + IF x > 0 THEN + FOR a = x - 1 TO 78 + logicalExpression(a) = logicalExpression(a + 1) + NEXT a + x = x - 1 + END IF + CASE 49 TO 53 + a$ = CHR$(ASC(a$) - 48) + GOTO 3 + CASE 13 + GOTO 4 + END SELECT +END IF + +GOTO 1 +4 + +END SUB + +SUB start +' Initializes the screen and font +prnp = 0 + +SCREEN 7 + +FOR a = 0 TO 122 + LOCATE 1, 1 + SELECT CASE a + CASE 7 + CASE 1 + LINE (0, 0)-(7, 7), 0, BF + LINE (2, 1)-(0, 3), 15 + LINE (1, 4)-(2, 5), 15 + LINE (5, 1)-(7, 3), 15 + LINE (6, 4)-(5, 5), 15 + LINE (1, 2)-(5, 2), 15 + LINE (1, 4)-(5, 4), 15 + + CASE 2 + LINE (0, 0)-(7, 7), 0, BF + LINE (5, 1)-(7, 3), 15 + LINE (6, 4)-(5, 5), 15 + LINE (1, 2)-(5, 2), 15 + LINE (1, 4)-(5, 4), 15 + + CASE 3 + LINE (0, 0)-(7, 7), 0, BF + LINE (0, 0)-(3, 7), 15 + LINE (6, 0)-(3, 7), 15 + + CASE 4 + LINE (0, 0)-(7, 7), 0, BF + LINE (0, 7)-(3, 0), 15 + LINE (6, 7)-(3, 0), 15 + + CASE 5 + LINE (0, 0)-(7, 7), 0, BF + LINE (0, 0)-(4, 0), 15 + LINE (4, 1)-(4, 7), 15 + + CASE ELSE + PRINT CHR$(a) + END SELECT + + FOR y = 0 TO 7 + FOR x = 0 TO 7 + font(x, y, a) = POINT(x, y) + NEXT x + NEXT y +NEXT a + +SCREEN 12 + +END SUB + +SUB tee (x1, x2) +' Processes the logical equation and applies logical operations +DIM opr(1 TO 2, 1 TO tehl) +ng = 0 +ngx = 0 +oprm = 1 +oe = 0 +oex = 0 + +FOR a = x1 TO x2 + b = logicalExpression(a) + SELECT CASE b + CASE 40 + c = a + d = 1 +10 + c = c + 1 + IF logicalExpression(c) = ASC("(") THEN d = d + 1 + IF logicalExpression(c) = ASC(")") THEN d = d - 1 + IF d = 0 THEN GOTO 11 + GOTO 10 +11 + tee a + 1, c - 1 + a = c + FOR c = 1 TO tehl + opr(oprm, c) = resultValues(c) + NEXT c + GOTO 12 + CASE 5 + ng = 1 + ngx = a + CASE 1 TO 4 + oe = b + oex = a + CASE 65 TO 90, 97 TO 122 + FOR c = 1 TO nm + IF variableNames(c) = b THEN d = c: GOTO 8 + NEXT c +8 + FOR c = 1 TO tehl + opr(oprm, c) = variableValues(d, c) + printText expressionPosition(a), c, 3, 0, CHR$(variableValues(d, c)) + NEXT c +12 + IF ng = 1 THEN GOSUB mkneg + IF oprm = 2 THEN + SELECT CASE oe + CASE 1 + FOR c = 1 TO tehl + d = opr(1, c) + e = opr(2, c) + IF d = e THEN f = ASC("t") ELSE f = ASC("v") + opr(1, c) = f + printText expressionPosition(oex), c, 12, 0, CHR$(f) + NEXT c + CASE 2 + FOR c = 1 TO tehl + d = opr(1, c) + e = opr(2, c) + f = ASC("t") + IF (d = ASC("t")) AND (e = ASC("v")) THEN f = ASC("v") + opr(1, c) = f + printText expressionPosition(oex), c, 12, 0, CHR$(f) + NEXT c + CASE 3 + FOR c = 1 TO tehl + d = opr(1, c) + e = opr(2, c) + f = ASC("t") + IF (d = ASC("v")) AND (e = ASC("v")) THEN f = ASC("v") + opr(1, c) = f + printText expressionPosition(oex), c, 12, 0, CHR$(f) + NEXT c + CASE 4 + FOR c = 1 TO tehl + d = opr(1, c) + e = opr(2, c) + f = ASC("v") + IF (d = ASC("t")) AND (e = ASC("t")) THEN f = ASC("t") + opr(1, c) = f + printText expressionPosition(oex), c, 12, 0, CHR$(f) + NEXT c + END SELECT + ELSE + oprm = oprm + 1 + END IF + END SELECT +NEXT a + +GOTO 9 + +mkneg: + ' NOT operation (negation) is applied to the current operand + FOR c = 1 TO tehl + d = opr(oprm, c) + IF d = ASC("t") THEN d = ASC("v") ELSE d = ASC("t") + printText expressionPosition(ngx), c, 4, 0, CHR$(d) + opr(oprm, c) = d + NEXT c + ng = 0 +RETURN +9 + +FOR c = 1 TO tehl + resultValues(c) = opr(1, c) +NEXT c +END SUB + +SUB teeslg (x1, x4, l) +' Prepares the logical equation for solving by simplifying expressions within parentheses +x2 = x4 +h = 0 +FOR e = 1 TO 4 + g = 1 + a = x1 +21 + b = logicalExpression(a) + IF b = 40 THEN + c = a + d = 1 +14 + c = c + 1 + IF logicalExpression(c) = ASC("(") THEN d = d + 1 + IF logicalExpression(c) = ASC(")") THEN d = d - 1 + IF d = 0 THEN GOTO 15 + GOTO 14 +15 + IF e = 1 THEN teeslg a + 1, c - 1, l ELSE l = 0 + a = c + l + x2 = x2 + l + h = h + l + GOTO 16 + END IF + + IF (b = 5) AND (e = 1) AND (g > 1) THEN + mov a, 1 + logicalExpression(a) = 40 + lendp a + 2, f + mov a + 2 + f, 1 + logicalExpression(a + 2 + f) = 41 + h = h + 2 + x2 = x2 + 2 + a = a + 2 + f + GOTO 16 + END IF + + IF (b = 3 OR b = 4) AND (e = 2) AND (g > 2) THEN + lendm a - 1, f + mov a - f, 1 + logicalExpression(a - f) = 40 + lendp a + 2, f + mov a + 2 + f, 1 + logicalExpression(a + 2 + f) = 41 + h = h + 2 + x2 = x2 + 2 + a = a + 2 + f + GOTO 16 + END IF + + IF (b = 2) AND (e = 3) AND (g > 3) THEN + lendm a - 1, f + mov a - f, 1 + logicalExpression(a - f) = 40 + lendp a + 2, f + mov a + 2 + f, 1 + logicalExpression(a + 2 + f) = 41 + h = h + 2 + x2 = x2 + 2 + a = a + 2 + f + GOTO 16 + END IF + + SELECT CASE b + CASE 5 + g = 1 + CASE 3, 4 + g = 2 + CASE 2 + g = 3 + CASE 1 + g = 4 + END SELECT +16 + a = a + 1 + IF a <= x2 THEN GOTO 21 +NEXT e +l = h +END SUB + diff --git a/index.org b/index.org index 239fef8..f4b82f2 100644 --- a/index.org +++ b/index.org @@ -241,10 +241,6 @@ TODO: description goes here ... [[file:3D%20GFX/Ray%20casting%20engine.bas][Ray casting engine.bas]] -* Misc -:PROPERTIES: -:ID: 3587240c-1d50-478d-b850-04ebc8dc63c7 -:END: * Games :PROPERTIES: :ID: aa195f33-6d69-48ff-9af5-3f761a51dcb2 @@ -268,11 +264,21 @@ it loses one life. [[file:Games/Worm/worm.bas][Source code]] -Levels are stored in [[https://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=tree;f=Games/Worm;h=644d30adafb2621f34f6d2f3e43e026084092f60;hb=HEAD]['lvl' files]] that are directly editable using text +Levels are stored in [[https://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=tree;f=Games/Worm;hb=HEAD]['lvl' files]] that are directly editable using text editor. ** Checkers +TODO: add description + +[[file:Games/checkers.bas][Source code]] + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Games/checkers.bas][file:Games/checkers.png]] + +** Checkers 2 + Play checkers against the computer with any board size and any amount of caps. Does thinking by recursively testing many possible scenarios with any depth. @@ -280,11 +286,141 @@ with any depth. Since it is slow QBasic implementation, it isn't practical to play with many caps or big thinking depth, for reasonable responce time. -[[file:Games/Checkers 2/checkers2.bas][Source code]] + +TODO: add description + +[[file:Games/checkers2.bas][Source code]] + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Games/checkers2.bas][file:Games/checkers2.png]] + +* Math +:PROPERTIES: +:ID: aa195f33-6d69-48ff-9af5-3f761a51dcb2 +:END: +** Game of life animation + +#+begin_export html +
+ +
+#+end_export + +[[file:Math/Game%20of%20life%20in%203D.bas][Source code]] + + +** Game of life studio + +TODO: add description + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Game%20of%20life/Game%20of%20life.bas][file:Math/Game%20of%20life/screenshot.png]] + +[[https://www2.svjatoslav.eu/gitweb/?p=qbasicapps.git;a=tree;f=Math/Game+of+life;hb=HEAD][Source code]] + + +** Math functions plot + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Plotting/index.html][file:Math/Plotting/logo.png]] + +[[file:Math/Plotting/index.html][See entire collection of mathematical plots]] + +** Simulations + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Simulation/index.html][file:Math/Simulation/logo.png]] + +[[file:Math/Simulation/index.html][See entire collection of simulations]] + + +** Truth table calculator + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Truth%20table/index.html][file:Math/Truth%20table/img/screenshot,%202.png]] + +[[file:Math/Truth%20table/index.html][Read more about truth table calculator]] + + +** Multiplication trainer + +TODO: add description + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Multiplication%20trainer.bas][file:Math/Multiplication%20trainer.png]] + +[[file:Math/Multiplication%20trainer.bas][Source code]] + + +** Alternative sine calculator + +Here simple and finite function was invented to compute sine +values. Custom sine values are shown alongside standard built-in sine +function to compare results. 1 pixel vertical shift is intentional. + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Sine%20computation.bas][file:Math/Sine%20computation.png]] + +[[file:Math/Multiplication%20trainer.bas][Source code]] + +** Lottery analysis + +TODO: add description + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Lottery/Lottery%20analysis.bas][file:Math/Lottery/screenshot,%201.png]] + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Math/Lottery/Lottery%20analysis.bas][file:Math/Lottery/screenshot,%202.png]] #+attr_html: :class responsive-img #+attr_latex: :width 1000px -[[file:Games/Checkers 2/checkers2.bas][file:Games/Checkers%202/screenshot.png]] +[[file:Math/Lottery/Lottery%20analysis.bas][file:Math/Lottery/screenshot,%203.png]] + +[[file:Math/Lottery/Lottery%20analysis.bas][Source code]] + + +* Misc +:PROPERTIES: +:ID: 3587240c-1d50-478d-b850-04ebc8dc63c7 +:END: + +** Alien font + +TODO: add description + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Miscellaneous/Alien%20font.bas][file:Miscellaneous/Alien%20font.png]] + +** Custom palette + +TODO: add description + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Miscellaneous/Custom%20palette.bas][file:Miscellaneous/Custom%20palette.png]] + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Miscellaneous/Custom%20palette.bas][file:Miscellaneous/Custom%20palette,%202.png]] + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:Miscellaneous/Custom%20palette.bas][file:Miscellaneous/Custom%20palette,%203.png]] + * Download ** Getting the source code