## Inspiration

Originally I was going to build an AlphaZero based engine, but the RL was to hard so I made one using montecarlo tree search solely. The Monte Carlo Tree Search Algorithm is a decision making algorithm often used in board games, it utilises random decision making.

## What it does

It looks at each legal, possible move and runs 20,000 simulations with solely random moves (rollout) until a result or end is reached, it then backpropogates this value to inform the overall judgement of the move. the rollout function is used to get all the random moves and return the value of each "node" in the tree, i.e. each legal move ```def rollout(board,rolls,side): result = 0 fen = board.board_fen() for roll in range(rolls): board.set_board_fen(fen) while (board.is_game_over() == False): List = list(board.legal_moves) move = random.choice(List) board.push(move)

res = board.result()

res = res.split("-")[side]

if res == "1/2":
res = "0.5"
res = float(res)

result += res #appends result
c= 2
si = result+c*math.sqrt(numpy.log(rolls))
return si #calculates the value of the state to inform the search which is the best move to choose, uses a natural logarithm to inform this```

## How I built it

Using the following APIs Chess, Numpy Flask

## Challenges I ran into

The main challenge was using some sort of UI implementation, I am a backend developer and so it wasn't in my skillset, and my team had fallen apart, I decided as a proof of concept to show the final position of two games between engines using flask, as I was not able to figure out how to dynamically update the same object in flask (i.e. the board svg file).

## Accomplishments that I'm proud of

The rollout and the engine work succinctly and cleanly, and the terminal chess works well using the Chess API, the 20,000 simulations take some time to make a move, but are almost equally as fast as the normal player.

## What I learned

I developed an understanding of the Monte Carlo tree search algorithm, and was able to implement a simple version using almost pure python and the chess API.

## What's next for codedchess

Next is to put the chess api onto the domain codedchess.tech using the flask API I would also like to try and replicate MuZero or Am