Recreating DeepMind's AlphaZero - AI Plays Connect 4 - Part 1: Building the Game Environment

Поділитися
Вставка
  • Опубліковано 17 жов 2024
  • In this series we re-create DeepMind's AlphaZero to create an Artificial Intelligence Reinforcement Learning algorithm that plays Connect 4 using Python.
    View the rest of the series: • AlphaConnect
    Full Code: github.com/The...
    AI, Deep Learning, Reinforcement Learning, DeepMind, Convolutional Neural Networks, Monte Carlo Tree Search, AlphaGo, AlphaZero, Connect4
    pygame code developed from source: github.com/mah...
  • Наука та технологія

КОМЕНТАРІ • 3

  • @mathmo
    @mathmo Рік тому

    Nice! I think you can simplify the code a little though. You can get the valid moves as just
    board.all(axis=0).astype(int) (or just leave out the astype(int), you probably won't need ints instead of bools anyway...)
    with
    and is_board_full as
    board.all()
    For checking the columns and rows in is_win you can use slices instead of the four equalities, e.g. to check the columns inside the double for loop you can just write
    board[column,range(row, row+4)] == player
    but here you can even remove the outer loop over the columns since you can do something like
    (board[:,range(row, row+4)] == player).all(axis=0).any()
    this way you can get rid of at least some of the code duplication. Also instead of checking the rows, columns, and both diagonal directions, you could get by having a nested helper function that checks only the columns and one of the diagonal directions and call it twice, once on board and once on board.transpose().
    A good question to ask oneself would be how the code would generalize to accept not just more general board sizes, but an integer n instead of 4, and maybe even a board of dimension m.

  • @discordraburg9988
    @discordraburg9988 2 роки тому

    whats happening, isnt it the 3rd upload now?

    • @theprincipalcomponent
      @theprincipalcomponent  2 роки тому +1

      just the 2nd, realized there was a clip out of order and had to delete and re-upload it correctly. same content though, sorry for the confusion :)