I’ve got a Java chess app lying around with three AIs implemented - dumb, dumber and dumbest The game was called Tiny Chess because it was meant to be tiny - maybe I will enter it in the 4K competition.
If I recall correctly I modeled the board and the rules, so that for any board position I could get all possible moves.
The AIs then simply rank the moves according to various systems.
DUMBEST simply picks a move at random - it is officially the worst chess player in the world. You can play worse deliberately of course.
DUMBER is actually quite clever and can beat me. It loops through all its possible moves and scores the board: you get points for every move available to your pieces in the new position, you lose points for every possible move your enemy has, you get points for every piece you defend and every enemy piece you threaten (and vice-versa for the enemy). Then DUMBER simply takes the highest scoring move.
DUMB is exactly the same but looks two moves ahead and tries to instead of picking the move based on highest scoring position, it plays the next enemy move and scores its own move by the enemy’s score - I don’t know if it was an improvement, it was just too slow.