- Blind mode tutorial
lichess.org
Donate
GuineaBot3 playing chess

The developer (i.e me)

GuineaBot3Labs, where a developer can learn, create, and make quality code.

Software DevelopmentChess engineChess botOff topic
Join this community for free and learn from your mistakes!

Introduction

I have made @GuineaBot3, @GuineaBot2, which is decommissioned, and @GuineaBot which suffered the same fate as GuineaBot2, now I have made @GuineaBot3COMPACT, which is a very compact version of GuineaBot3 that can run on a itty bitty little CPU making moves every 1-3 seconds, now this is a very big acheivement for something that used to need a FREAKING 24 GB GPU which doesn't sound like much but may I remind you that GPUs usually come at most 24 GBs, so that is a really huge model.

Where it all happened

@GuineaBot was made in my computer, it started small, a 1 day challenge project if you will, my challenge was simple:
1: It can not use minimax algorithms externally OR internally.
2: It must be a neural network defined in PyTorch.
3: It must not use any type of tree algorithms or NNUEs to adjust these algorithms quickly.

I swiftly went to work, it was a success, 200 lines in one day, typing about 40 words per minute, I worked on it slowly, testing each function individually, and when I was done, a chess bot that made very simple moves as achieved, it wasn't the best but it was a chess bot, a DQN chess bot, over time, I wanted to improve it's algorithms and decision making, at the time I didn't have a GitHub account or a organization, it was grueling; however, eventually it started playing somewhat reasonable moves. Eventually it got to the point where it would not run on my tiny CPU anymore due to memory overflow, at this time GuineaBot was in second generation, running a DDQL (Double Deep Q Learning) algorithm, this halted my development for a couple weeks, but eventually, I found and scavenged a small NVIDIA GPU from a old computer. I tested, tinkered, failed, and learned. After this project I have seen improvement in my abilities in AI development. I used to be very horrible on this part, but eventually I learned to write decent AI models. This was a learning opportunity and I want to share that opportunity with others, anybody, even young learners who will one day make the world a better place.

I won't sugar coat it...

Now this may be super inspiring and everything, but I just want to let everyone out there know, it wasn't a very good start, I would have issues like this:

Traceback (most recent call last):
File "D:\Desktop\GuineaBot3\GuineaBot3.py", line 1822, in <module>
agent = DQNAgent()
^^^^^^^^^^
File "D:\Desktop\GuineaBot3\GuineaBot3.py", line 294, in __init__
self.target_model = TargetChessNet()
^^^^^^^^^^^^^^^^
File "D:\Desktop\GuineaBot3\GuineaBot3.py", line 183, in __init__
self.attention = Attention(92) # Assuming the input dimension is 4096
^^^^^^^^^^^^^
File "D:\Desktop\GuineaBot3\GuineaBot3.py", line 44, in __init__
self.attention1 = nn.MultiheadAttention(embed_dim=in_channels, num_heads=12)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\GuineaPigLord\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\activation.py", line 991, in __init__
assert self.head_dim * num_heads == self.embed_dim, "embed_dim must be divisible by num_heads"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: embed_dim must be divisible by num_heads
(Testing on different operating systems for cross compatibility)
or this:

Traceback (most recent call last):
File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 1111, in train self.replay_pgn_and_learn(q)
File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 586, in replay_pgn_and_learn self.simulate_self_play(numgames)
File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 549, in simulate_self_play move = self.choose_action(state, list(board2.legal_moves), board2, True, move_num)
File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 806, in choose_action reward = self.get_reward(board, self.color, move, original_piece_type, selfplay, move_num)
File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 1641, in get_reward if not any(board.pieces(chess.PAWN, color) & chess.BB_FILES[f] for f in [file - 1, file + 1]): File "/home/guineapiglord/Desktop/ChessAI4/chessAI/agenttwo.py", line 1641, in <genexpr> if not any(board.pieces(chess.PAWN, color) & chess.BB_FILES[f] for f in [file - 1, file + 1]): IndexError: list index out of range

And the list just goes on. as shown above, you can see I have 'IndexErrors', and even problems in my calculations, these were past incidents, however, we can still learn and improve from them. I fixed the IndexError by just going from 0 to 7 not 1 to 8 which is equal to if I was to do surgery on a person, then I leave a scalpel in them and patched them up, and later the patient has severe problems. The real reason why minimax is so inefficient is because it goes through every single game state there is. However, this is impossible (without alpha-beta pruning anyways) because the amount of legal game states, terminated or ongoing, is comparable to the amount of water molecules on earth, yikes... Learn from your mistakes and if you do, you will make great code.

Invitation

Now I am going to invite you to GuineaBot3Labs! Where you can experiment, succeed, remember everyone, failure is only a new milestone, if it wasn't for failure, Nikolas Tesla wouldn't have come up with the brushless AC motor, his BEST invention, now I want you to learn, GuineaBot3Labs is a safe place for you to experiment, fail, and finally IMPROVE, and when you become a master, you get to work on bigger projects, potentially even join NVIDIA as an Deep Learning researcher. This is an invitation to those who want to learn, experiment, and make the world a better place, remember, we all fail at least once, and if you never made a mistake you have never learned, so now let's make the most mistakes, fix them, and learn!