MiniMaxing banner

MiniMaxing

6 devlogs
23h 43m 56s

MiniMaxing is a chess AI platform where instead of playing against other players and moving yourself, you code an AI bot and challenge other player’s AI. The inital project will have an optimized minimax algorithm in the backend with heuristics and alpha-beta pruning, and the player’s objective is to make this algorithm as good as possible by writing the point evaluator. In minimax it requires giving a number to each game state and then backtracking. In some games this is easy, like tic-tac-toe where the possibilities are small and you can just search until the winning state. But in chess since this is exponential growth, that would be too inefficient. So you have to assign point values to intermediate states. But how do you assign points? Chess isn’t just about raw point values of pieces and capturing them, position matters. That is the players job, given a set number of rules, they can write those rules in python such that they return a boolean, and give them a weight.

This project uses AI

Used ChatGPT (Codex) to help debug some of my code.

Zain Marshall

Ok so I haven’t worked on minimaxing properly in a while (over a month now). Anyways I still worked on it on and off for a few hours a week, so here is the devlog that summarizes all of those changes. Also this devlog was 3.7k chars over so i had to make it rly short now.

Ideas

First, I would like to link a few videos that I watched and got inspiration for this project from.

I have to give credit to these videos for helping me in building minimaxing.

Change 1: Users writing full scripts

  1. Users upload full python scripts that have a think method that takes in the board state as a python-chess object and returns a move in UCI format (a1b2 - starting square, final square).
  2. There is a token limit, right now 2000 tokens on all uploaded scripts using the tokenize method.

Change 2: Less bleak, sad, and depressing looking UI

I made the UI a lot more fun and playful, its a pastel color pallete now.

Change 3: Bots

This is a smaller change ig, but I spent a long time writing a good bot, cuz testing with the basic minimax with material advantage bot was getting boring so I wrote a good bot and now I can test the app with that.

A collection of minor changes

  • I added a makefile so you can run make run in the root and it will run the backend and frontend. I’m tryna add this to a bunch of my projects cuz its so clean and nice to use.
  • Added a docs page that somewhat tells the users what to do (more depth later)
  • Fixed the supabase backend which was broken for a bit

Anyways if you could comment on this post saying how you like the UI and what changes I should make that would be super helpful, thx.

Attachment
Attachment
Attachment
Attachment
0
Zain Marshall
  1. Updated the way the bots work and take rules to instead of using really long confusing eval statements you just write a method that returns an integer.
  2. Added a bunch of helper functions that are exposed to the bots, so that the users can add them to their rules. For example, my bots used to always stalemate, so there is a function that returns the number of repetitions so that you can add negative incentive for stalemates. Thats one example of a method I added.
  3. You can now see, edit, and delete the version history of bots.
  4. You can upload JSONs to upload bots and rules from files. You can also download old versions as JSON.

To Do:

  1. Add a new way to write bots, instead of just writing the evaluation function to a negamax algorithm, the users can write the full AI from scratch, they get the helper methods and board state as input, and need to output the next move in algebraic chess notation.
Attachment
Attachment
0
Zain Marshall

Added the ability to delete and edit bots.

Attachment
0
Zain Marshall

I added a lot to both the backend and the frontend. The backend works fully with supabase and all of the data tables are set up. There is also user authentication through email, and there should be through GitHub but thats still broken. Then after the backend as done I tested it and it worked, so I mocked up a rough frontend for creating bots, editing them and their rules and evaluations, and then for playing bots against each other. Right now its only your bots, but later I’ll add the multiplayer aspects.

Attachment
Attachment
Attachment
0
Zain Marshall

Switched to negamax as its computationally more efficent than minimax. Implemented the backend and supabase to handle the rules, the evaluation, the match making. Now to work on the frontend! The backend is a very rough draft, it’ll be improved with time.

Attachment
1

Comments

zliskovyi
zliskovyi about 2 months ago

holy tuff aura blud

Zain Marshall

Architected most of the project, got the plan done.

Frontend - Sveltekit
Backend - FastAPI

I started coding a bit of the backend like the minimax algorithm

Also I’m brainstorming security measures cuz if ppl are uploading their own code that is very dangerous.

Attachment
0