AI Bot Challenge

← Back to all posts
60
🧠 Connect 4 AI

Just a simple but fast connect four AI made using HTML, CSS, JS.

How To Play:
The aim of the game is to get four of your counters (red) in row, this can be diagonally, horizontally or vertically. Each move click on one of the seven columns to drop your counter into that column.

How It Works:
1) Each potential place the AI can place a counter is scored based on the amount of counters around that place and the length of the segments around it also.
2) The move above is also checked to make sure that by moving to that position that the AI doesn't cause the player to win, or for the AI to sacrifice a potentially good move, if this is true then the score of that move becomes 0.
3) If there is one distinct highest score, that one is chosen, else the AI just picks a random move from the highest scoring moves.

REMEMBER TO UPVOTE!

PLAY HERE: https://Connect-4-AI--luchutton.repl.co

Commentshotnewtop
4

Best pattern ever.

4
2

A strategy to always tie is put your first block in the middle and always place your place your next block on the block the AI places. If it hits the top, go to the next row over.

2

Amazing, well done!! Super fun to play! I only won 2/5 rounds haha, it's seriously much harder than I expected :')

2
1

2nd to best pattern

1

Also found an edge case where there is a very obvious placement for the AI, but it goes in the wrong spot. Maybe something to investigate:

1

Nicely done. However I found myself able to create this win very consistently.

1

Good job! I couldn´t won a single time.

1

It was a very good AI, but in the end, humans will win

1
1


This pattern always wins when going first. (Up three, over three was my last play)

1

Are they?

1

@kaiserb1 It got 4 in a row diagonally.

1

Pretty good AI. Nicely done!

1

I got 4 in a row, dianical, but I didn't win?

1

^-^ I'm gonna use this strategy on my friends next! corner first :D