AI Learns to Play and CONQUER 2048
Автор: Programmetry
Загружено: 2025-10-18
Просмотров: 100
In this video, I teach an AI how to play and eventually win the classic 2048 game from scratch. We’ll build everything step by step in pure HTML, CSS, and JavaScript, and explore how the AI actually “thinks” about its next move.
This isn’t just a code-along; it’s a full walkthrough of how to design and code the AI algorithm, the decision-making logic behind many game AIs. You’ll see the full process, from setting up the board to teaching the AI to evaluate moves using heuristics like smoothness, empty tiles, and monotonicity.
If you’ve ever wondered how an AI decides what to do in a game, or how algorithms like Expectimax differ from Minimax, this is the perfect project to learn from — with real code, real results, and a few funny trial-and-error moments along the way.
We’ll cover everything step by step:
• Setting up the 2048 board and movement logic
• Creating helper functions to simulate tile slides and merges
• Designing heuristics for the AI to “measure” good moves
• Implementing the Expectimax algorithm for smarter play
• Watching the AI improve and finally win the game
By the end, you’ll understand how to code your own simple game AI, how Expectimax works, and how small changes in heuristics can dramatically affect performance.
Thanks for watching — and if you enjoy AI coding projects, programming tutorials, or just seeing what happens when code starts to think for itself, subscribe to Programmetry for more videos like this.
🎥 Subscribe for more videos like this: / @programmetry
🤖 AI Experiments Playlist: • AI Experiments
Timestamps:
00:00 Introduction
00:14 Phase 1: Coding 2048 From Scratch
00:49 Game Grid
01:03 Game Tiles
01:34 Movement and Score Tracking
02:23 New Game Button and High Score Tracking
03:17 Game Over Menu
03:36 Phase 2: Coding the AI (Max)
04:20 Max Plays with Random Moves
04:59 Adding Helpers
05:32 Creating Basic Heuristics
05:49 Smoothness
06:45 Expectimax Function
07:45 Max Plays with Expectimax AI Algorithm
09:12 Monotonicity
10:04 Max In Corner Strategy
10:58 Max Plays with New Heuristics
12:07 Merge Potential
13:03 Adjusting Heuristic Coefficients
15:05 Max Fumbles an Easy Win LOL
16:00 Max Finally Wins...?
Song: Fragments
Composer: AERØHEAD
Website: / @aero_head
License: Creative Commons (BY-NC 3.0) https://creativecommons.org/licenses/...
Music powered by BreakingCopyright: https://breakingcopyright.com
#ai #coding #programming #artificialintelligence #machinelearning #javascript #webdevelopment #codewithme #programmetry #codingproject #codingtutorial #creativecoding #beginnercoding #codingforbeginners #2048 #browsergame #codingai #machinelearningalgorithms #aialgorithms #gamedevelopment #gamedev #aiprogramming #code #aicode #aitutorial #aiforbeginners #machinelearningtutorial #codetutorial #algorithm #algorithms #aiagents #ailearning #neuralnetworks #reinforcementlearning
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: