css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv
CodePen probably won't work great in this browser. We generally only support the major desktop browsers like Chrome, Firefox, Safari, and Edge. Use this one at your own risk! If you're looking to test things, try looking at Pens/Projects in Debug View.
user profile image

The classic game, played against an AI opponent. Applies the minimax algorithm to pick its moves. Coded as a multi-threaded app using a web worker.

Web workers require code to be executed from separate JavaScript files. The code here is the UI thread. If you want to see the web worker code, check out Align 4 Game (Web Worker).

Higher difficulty levels are computationally expensive, so the computer's turn may take a while, especially on mobile devices.

Blog post: Align 4 Retrospective: Writing a Multi-Threaded Game in JavaScript

Comments

  1. Can't win a single game on lvl3 :S Nice Job!

  2. Can't even win on Level 1...

  3. lol "Try again when you're done wiping your tears of shame." level 4's got me beat!

  4. Can't win. I'm so rage quitting this game, like right now.

  5. Wait, I actually won level 1.

  6. Thanks, all! And sorry about the difficulty. I know exactly how the AI thinks and play tested hundreds of games, so maybe my perspective on difficulty is a bit skewed. :)

  7. This is sickeningly brilliant, well done!

  8. Nice stuff, and a very clean look :)

  9. http://i.imgur.com/mHgzkUJ.png I won it with lvl 5 :D ( without edit the source code! )

  10. Thanks again, everyone. And grats, Marvin. :)

  11. I love your work man.. solid.

  12. haha! Apparently I've got more experience with this game than a lot of people. Just passed level 5 on first try... :)

Leave a Comment Markdown supported. Click @usernames to add to comment.

You must be logged in to comment.
Loading...
Loading...