Тёмный

AI Destroys NES Tetris On A REAL Nintendo! 

CodingLikeMad
Подписаться 3,4 тыс.
Просмотров 5 тыс.
50% 1

I created an AI that demolishes Tetris 1989 in real time on an actual Nintendo Entertainment System from the 1980s. No random number manipulation, pre-programmed TAS moves, or emulation was used for the game play itself. This project originally dates from September of 2019, but it's taken forever to get out, so I'm proud to finally be done!
If you want to watch me make this stuff live, checkout my twitch:
/ spshkyros
Check out my other social media if you want to follow my work:
Twitter: / codinglikemad
Reddit: / codinglikemad
If you want more details on the algorithm, I posted an unlisted video with more details here:
• Tetris Bot AI Descript...

Наука

Опубликовано:

 

18 дек 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 97   
@ohhello9743
@ohhello9743 3 года назад
"If it looks like a fire risk, that's because its a fire risk"
@CodingLikeMad
@CodingLikeMad 3 года назад
Both funny AND true.
@TheKoloradoShow
@TheKoloradoShow 3 года назад
If you can train it to go for tetrises, I think that would be way more epic
@CodingLikeMad
@CodingLikeMad 3 года назад
Next step for sure!
@SeanGHOB
@SeanGHOB 3 года назад
You've only trained your AI to last as long as possible, not to maximise score. Any plans to work on that? It would be interesting to see if it comes up with any new strategies that the top players haven't yet considered.
@CodingLikeMad
@CodingLikeMad 3 года назад
I talked about this with a lot of people on some of the tetris discords. I'm hoping to work on a reinforcement learning approach that can come up with "unique" strategies on its own, with a goal of maximizing score. To make it useful to human players, I probably need to restrict it to "human" moves. Right now due to the latency issues it probably is doing that by default anyway, but it's still a long term issue. I also am not sure how to best help humans interpret it - is footage of it playing enough, or is it worth giving a guide to what it is "thinking" somehow? Maybe a tetris analyzer where you can upload a board and a next piece and it tells you the best move it sees? I dunno.
@salumtummundi9462
@salumtummundi9462 3 года назад
@@CodingLikeMad Humans now in tetris can play up to level 38 and higher, killscreen is already easu for them. Ai playing tetris would just be like chess engines which woulf be cool.
@aGameScout
@aGameScout 3 года назад
"buy good stuff you idiot" lol
@ShizukaNIX
@ShizukaNIX 3 года назад
"To be honest, I.. think it might catch fire at any time. So... science!" I love this XD
@michaellyga4726
@michaellyga4726 3 года назад
Hypertappers: exist Level 29: *chuckles* I’m in danger
@CodingLikeMad
@CodingLikeMad 3 года назад
Working on it! It'll get there soon!
@jameskevinbutchers
@jameskevinbutchers 3 года назад
I enjoyed this and I love playing Tetris. The only thing I was hoping to see is if the AI could figure out the benefit of getting tetrises - clearing four lines at once which not only helps deliver a higher score but is a far more efficient way of playing. If the AI can make that leap, I think you'll find it starts producing far better play and maybe even clearing a line or two on the kill screen!
@CodingLikeMad
@CodingLikeMad 3 года назад
That's an interesting thought - I hadn't considered that it would make a more efficient method of play by doing that. Score maximizing is definitely the next thing up for sure though, so it'll be interesting to see if that accidently increases survival too! Glad you enjoyed.
@anchikai
@anchikai 3 года назад
awesome vid! would love to see a further video with improvements and it possibly playing level 29 :)
@CodingLikeMad
@CodingLikeMad 3 года назад
That's the hope for me too! That level 29 is quite a leap though. I'll need to replace the whole capture system at least :/
@anchikai
@anchikai 3 года назад
@@CodingLikeMad good luck with it :) it would also be cool to see it go against a human or maybe itself. Just tossing some ideas for you :)
@CodingLikeMad
@CodingLikeMad 3 года назад
My friend keeps asking me to setup up to play them online. That actually would be pretty easy to do, although I'm sure my account on PPT would be banned very fast if I tried. ;)
@DrMegaGaming
@DrMegaGaming 3 года назад
Awesome video!
@TylerDunphy
@TylerDunphy 3 года назад
I love machine learning! I would definitely love to see this where fitness is not survival time but is overall score by the time the run is complete, maybe it could work its way up to a maxout! Amazing work on this and I can’t wait for more from this channel :)
@CodingLikeMad
@CodingLikeMad 3 года назад
Thanks so much, I appreciate it :) I think everyone wants to see the max out, so that's definitely coming. Next up from my side I'd love to be trying out a reinforcement learning approach as well. That's going to be needed for a lot of my projects, so better get started :)
@jeremyhastings4756
@jeremyhastings4756 3 года назад
Great video! We grew up playing Tetris on a Mac laptop and competition was fierce. If you got into a flow state you could go for quite a while. Interesting comparison between the human brain and AI.
@JBroms64
@JBroms64 3 года назад
I enjoyed this. I'm a Tetris the Grand Master (TGM) player and I've always wondered if an AI like this could be used to help train human players to choose more optimal placements. There are a lot of situations in higher level Tetris where the "best move" isn't always obvious and humans have to rely on their intuition when they decide on a placement.
@CodingLikeMad
@CodingLikeMad 3 года назад
I'm glad you enjoyed it, I've been hanging around the tetris discords trying to figure out how to keep the video appealing to all audiences, from Tetris Grand Masters to people who remember it from childhood :) Regarding your point, I think you could probably display some kind of scores from the trained model for different moves in principle. Sortof a ... tetris analysis engine. Like a "What would TetrisBot do?" type thing. Only problem is how to package something like that(like a website or app or what), the AI itself could just be ripped out of my current engine.
@JBroms64
@JBroms64 3 года назад
@@CodingLikeMad Are you in our "The Absolute PLUS" Discord? It's linked on the sidebar of the subreddit. I'll take a look at your longer video when I get the time to really absorb the info.
@CodingLikeMad
@CodingLikeMad 3 года назад
I just joined actually, I'll make a nuisance of myself there soon. Actually, someone asked me if I would port my bot for that game, so probably a good place to be anyway.
@Bolvar
@Bolvar 3 года назад
That's definitely further than I ever got myself. Really impressive result!
@CodingLikeMad
@CodingLikeMad 3 года назад
Thanks, I'm super proud of this project and so glad you enjoyed it :)
@wmpowell8
@wmpowell8 3 года назад
I’m happy to announce that @aGameScout plugged you! (If you don’t know who I’m talking about, look him up on RU-vid.
@CodingLikeMad
@CodingLikeMad 3 года назад
I've been trying to figure where the traffic was coming from all morning, thanks so much for letting me know. I knew aGameScout had looked at it, I didn't realize they plugged it though. I'll have to thank them.
@balbar_b
@balbar_b 3 года назад
Nice video and nice bot/ai. Hope you will get better hardware(capture card) and gets maxout+ amazing killscreen play
@CodingLikeMad
@CodingLikeMad 3 года назад
Stay tuned, I'm starting work on that now :) Thanks so much.
@CyrusTabery
@CyrusTabery 3 года назад
I really liked the video. I would like a deeper dive as you mentioned about a tetris analysis engine. I like that it performs, but i am interested to use AI for real insight about physics or in this case game strategy!
@CodingLikeMad
@CodingLikeMad 3 года назад
Did you check out the linked video below? I talk about the architecture a bit more there. Balancing a general and technical audience is hard :/
@Nevanator2005
@Nevanator2005 3 года назад
7:50 That hurts cause it had the perfect pieces for an all clear
@CodingLikeMad
@CodingLikeMad 3 года назад
Oof, I never noticed that! Poor Tetris bot :(
@jewbacca2577
@jewbacca2577 3 года назад
Great job. Tetris is an all time favorite of mine. Im curious to see how a better capture device would impact the programs ability to adapt to the quicker frame movement.
@CodingLikeMad
@CodingLikeMad 3 года назад
In principle I should be able to get past 29 with a faster capture card. I think I have about 1 or 2 frames to grab the block shape, and that is doable with good hardware. The AI itself averages only 2 frames, and that can speed up if I need it to. If I can get it fast enough, I could even start doing tspins!
@YusifTetris
@YusifTetris 3 года назад
I've always wondered how AI works. Great project! :D
@CodingLikeMad
@CodingLikeMad 3 года назад
This AI is still too simple in my eyes - stay tuned, the next couple are much cooler :)
@dogenestris
@dogenestris 3 года назад
Train it more and do a follow up video on it. It has great potential
@CodingLikeMad
@CodingLikeMad 3 года назад
Thanks so much :)
@dogenestris
@dogenestris 3 года назад
@@CodingLikeMad oh just one thing. You should make the ai read the next box so that it's not slow on 29
@CodingLikeMad
@CodingLikeMad 3 года назад
@@dogenestris I actually do read the next box right now, I just don't pre-compute the move for a single next piece, I use the next two pieces (so the one on screen, and the one in the next box). I could drop to just one piece on 29 though, that would help a bit. A bigger issue is knowing when the next piece is actually on screen though. That type of timing is done very poorly right now, and it wastes a lot of time.
@CheezTetris
@CheezTetris 3 года назад
the fact that the AI missed the perfect clear in killscreen makes me sad
@CodingLikeMad
@CodingLikeMad 3 года назад
I've got a new AI trained, new video to be released shortly. It's play should make you MUCH less sad :)
@MikeDolanFliss
@MikeDolanFliss 3 года назад
Lovely! I wonder about simple-ish additions that might help your time pipeline problem. Not sure what multi-threading is available or whether your controller can, in the same frame, both process setting the known piece and getting started on next pieces, but given multi-threading it seems you could do a bit of preprocessing of potential next-next pieces alongside the current piece. Or, if I'm following, always try to operate one (next piece) move ahead, rather than try to ID the piece at the top, figure it's placement, then move it to that location. Might still work single threaded, but give the benefit of spending "the piece is on the board!" time entirely placing it, then going to try to AI-place in the not-yet-existing next state (assuming your placement succeeds) in memory, first. At any rate, probably some obvious "improvements" to anyone who does any AI work. :) This is a lovely toy example about how AI game controllers and heuristic functions work though! Perhaps other videos could be a deeper dive in your chosen features / heauristics / cost functions, and iterative improve this little guy to the education of your audience! Great work!
@CodingLikeMad
@CodingLikeMad 3 года назад
Hi Mike, Sorry for not replying sooner, I wanted to give you comment the full attention it deserves! With regards to multi-threading - the original code (as you can see in my bonus video) is shattered into multiple pieces. The code responsible for reading from the camera, and the code responsible for interpreting the output are in different executables. I have a new version of the code that is pure python (and soon will be python+C most likely). This version I hope to introduce some multithreading to, perhaps with a seperate thread responsible for reading the camera. In principle there is enough time to pre-compute all 7 possible "next" piece shapes, however the current system doesn't know the "time" accurately enough to take advantage of this. I hope that by multithreading and properly moving the frame analysis into the same thread that I can close this gap substantially, perhaps enough that I will know if I have spare time to work with between drops. My next video on this is going to use the same features but this time for score optimization (I never listed them, I should include them in the next bonus video explicitly, although I'm going to add to the list so I need to mention it there anyway), but they aren't that different then the ones meatfighter uses - actually, I think they are a strict subset, although I developed my code entirely before seeing his(or anyone elses) work on this. Hoping to hit a world record there, but I need to do the above speed ups because I refuse to continue working with matlab on this. Then I can move on to much more interesting machine learning stuff - I really need a reinforcement learning approach for this, and I'm planning on applying it to Dr. Mario as well :) Hopefully those will match your interest. And while I had thought about your ideas on multithreading already, I wouldn't call them obvious. I'd love to hear more ideas on the next video, since you're certainly at the edge of the things I'm thinking about for sure :)
@RedStone576
@RedStone576 2 года назад
missed pc before the killscreen lol
@CodingLikeMad
@CodingLikeMad 2 года назад
I know, it's heart breaking, but the good news is that the newer bot plays much better :) I need an update video so bad for this :/
@francoismenard6704
@francoismenard6704 3 года назад
You should take it a step further and have the AI optimise the score. And to do that and really beat humans you need to have it start at level 19. Super video thought.
@CodingLikeMad
@CodingLikeMad 3 года назад
For sure, level 19 start and score optimizations are a big deal. I think, to be honest, that beating 29 is not that important for challenging the leaderboards since it's so difficult to do practically anyway. I'm getting way too excited about the next project though, we'll see if I can force myself to finish my minesweeper video before I start the next teris one.
@thomasdalton1508
@thomasdalton1508 3 года назад
@@CodingLikeMad Even the best human players struggle to score many tetrises past level 29, so the impact on score of being able to survive the killscreen is minimal. What you need to consistently get high scores is efficient play on level 19 - as many line clears as possible need to be in the form of tetrises.
@CodingLikeMad
@CodingLikeMad 3 года назад
@@thomasdalton1508 Interesting... that's very cool for this bot, as it can survive pretty well in that level range. Only at 29 does it collapse. I'd really like to see it take the WR for score, although obviously it's cheating, not being human and all.
@QwDragon
@QwDragon 9 месяцев назад
You should've use piece from the next box to determine moves and make ai send signals based on it.
@dehaitch
@dehaitch 3 года назад
Very neat video. What did you use to train the AI, recorded previous games?
@CodingLikeMad
@CodingLikeMad 3 года назад
The AI was actually let loose on a simulation of tetris without any gui, and just allowed to play over and over again, trying different strategies until it found one that let it win consistently. I did a few hundred games with each strategy and it progressively improved until it seemed to hit a wall. Still good enough to hit level 29 though :)
@afaelr
@afaelr 3 года назад
Waiting for more NES tetris videos
@CodingLikeMad
@CodingLikeMad 3 года назад
Seems like people enjoyed this, so definitely a few more coming in the next few months :)
@bigbassjonz
@bigbassjonz 3 года назад
This is really great. Can you teach it strategy?
@CodingLikeMad
@CodingLikeMad 3 года назад
I'm most interested in an AI figuring out strategy for itself, but the current version is dumb enough that it's not going to do that. For me, advanced AIs are ones that do things humans dont think of and cant teach. That's my real goal for this, but that's a future video :)
@ThePixelPolygon
@ThePixelPolygon 3 года назад
If you were able to strike a balance between score and survival you could definitely hit up the top players for a sweet challenge
@CodingLikeMad
@CodingLikeMad 3 года назад
That's for sure a plan, people keep asking for a versus mode to fight the bot :p
@kevineames620
@kevineames620 3 года назад
This is awesome, I have thought how tetris ai would be, but have literally 0 of the knowledge on how to do it. Does it use the next box in any way?
@CodingLikeMad
@CodingLikeMad 3 года назад
It does! I look for the combination of the next two pieces that gets the board in the best possible position.
@Blastoisebob
@Blastoisebob 3 года назад
I am here for The T-spins and free pizza ;)
@CodingLikeMad
@CodingLikeMad 3 года назад
Noone promised pizza! How do these rumors even start? TSpins are incoming if I ever manage to get a faster capture card :)
@algola7024
@algola7024 3 года назад
Yooo free pizza ???
@relarin952
@relarin952 3 года назад
Catching fire is basically the entreaty of science 😂
@CodingLikeMad
@CodingLikeMad 3 года назад
I'd love to say that's a one time thing for me, but i count like 4 times with even trying :/
@bigbassjonz
@bigbassjonz 3 года назад
Just to follow up on my previous question about strategy. I'd hook up with some of the old school Tetris pros like Jonas or Green tea. I know Green Tea has contributed to modern Tetris games in some sort of a development capacity. Any of them can give you ideas for strategy though that you could implement into the AI.
@kylewagoner
@kylewagoner 3 года назад
I would say NES Tetris destroyed this AI, not the other way around. Still very cool!
@CodingLikeMad
@CodingLikeMad 3 года назад
I mean, in seriousness, it still plays better than all but top players, that's pretty solid. I do confess that tetris won this round though. Guess we need a sequel.
@foiledthrice
@foiledthrice 3 года назад
Don’t see the problem with the first attempt. Spam left is meta, right?😜
@CodingLikeMad
@CodingLikeMad 3 года назад
My AI, it's too smart for me!
@dailyskeptic
@dailyskeptic 3 года назад
I'd love to see it attack B Type gameplay!
@CodingLikeMad
@CodingLikeMad 3 года назад
Me too! The height creates some annoying issues for the graphics processing that I'm embarrassed to say aren't fully solved yet. floating shapes (like you get when you have height>0) can make it confused on where the active piece is if they happen to be in the shape of a normal tetris block. Def. a thing to play with though, especially since I think the high heights and high levels are known to be crazy difficult.
@MrK-
@MrK- 3 года назад
What capture device did you use.
@CodingLikeMad
@CodingLikeMad 3 года назад
Since I bad mouthed it so hard I'm trying to avoid naming it. But it is a common one. I can provide recommendations for better ones if you are interested though. Consensus among those ive talked to is that the right way to do this is to mod the NES to RGB and then use an OSSC... I'm just not quite willing to spend that much cash yet on this project.
@MrK-
@MrK- 3 года назад
@@CodingLikeMad that captured video actually looked pretty decent. Which is why I was asking. I've looked into some better ones like gv-usb2.
@CodingLikeMad
@CodingLikeMad 3 года назад
@@MrK- I'm not a huge fan of the gv-usb2, but it's one of the ones in my repertoire(I own 4 or 5 capture cards now). The latency on it isn't great on it, but if you just need capture it's a common one. One of the things I don't like about it is that it doesn't deal with the interlaced video properly. If you look at my level 29 sequence, you can see the capture card I use has this problem as well - notice how the square block when I first hit 29 seems to occupy 6 blocks? It's showing 30 frames per seconds with doubled up vertical resolution instead of 60 frames per second. Unfortunately, every component/RCA capture card system I have has this problem right now :/ If you compare to an emulator, you'll see much cleaner blocks. That's what I really want to see. But, indeed, the price can't be beaten for that card.
@MrK-
@MrK- 3 года назад
@@CodingLikeMad yeah. Atleast its better of a capture card than what I currently have. I dont have the biggest budgets for better ones.
@CodingLikeMad
@CodingLikeMad 3 года назад
Yeah, for a low end card, I've found them pretty reliable. No linux drivers is the other thing that annoyed me with them. But the price cant be beat.
@TheUnnamedGent
@TheUnnamedGent 3 года назад
What would happen if you trained the AI for score? That seems to be the main thing human players go for. I do software dev, including some Arduino stuff, but AI stuff seems like magic to me.
@CodingLikeMad
@CodingLikeMad 3 года назад
Training the AI for score is for SURE the next step. All I need to do is change the cost function actually, so it optimizes the linear weights towards 3 and 4 line clears instead of just surviving. Conveniently, because it uses the total score over the lifetime, it'll actually still consider survival, since your score will lower if you die. I probably will also provide some explicit features so it can see it set itself up for a 2 or 3 or 4 line clear. Hopefully that's enough to hit a max out on the score, since it can definitely get to level 29 already.
@TheUnnamedGent
@TheUnnamedGent 3 года назад
I wondered if it would work out to prefer tetrises by itself. You think it may need help?
@CodingLikeMad
@CodingLikeMad 3 года назад
The feature set I use us pretty simple, I think this version would be helped by adding features that "suggest" tetrises at least. That said, a more sophisticated algorithm like a neural net could learn those features on it's own. Project for a future day though.
@wlhjohn622
@wlhjohn622 3 года назад
Result: Human brain>capture card
@CodingLikeMad
@CodingLikeMad 3 года назад
Crazy how good the human mind is at this. Even professional self driving car systems dont manage amazing frame rates actually, it's awe inspiring.
@georgebarc
@georgebarc 3 года назад
But you need to get tetris though
@CodingLikeMad
@CodingLikeMad 3 года назад
Up next, stay tuned :)
@didiramona7131
@didiramona7131 3 года назад
I am definitely not a bot :)
@CodingLikeMad
@CodingLikeMad 3 года назад
I'm skeptical. You'll need to play some tetris to prove it.
@alllmas
@alllmas 3 года назад
Make ai max out at least.
@CodingLikeMad
@CodingLikeMad 3 года назад
Next step for sure!
@mthees08
@mthees08 3 года назад
Spending money on little robot treats but not robot hardware is like giving a child candy that has had no supper. Buy better hardware.
@CodingLikeMad
@CodingLikeMad 3 года назад
But it's a good bot, it earned its treats!
@westonhartuv6779
@westonhartuv6779 3 года назад
Awesome video !
Далее
Creating the Biggest Missing Statistic in NES Tetris
21:15
AI BREAKS NES TETRIS! - 102 MILLION and level 237
25:48
Клип Уже На Канале #янгер #shorts
00:15
bringing JUSTICE to the MOST HATED Mario game.
23:05
Просмотров 131 тыс.
Light sucking flames look like magic
18:05
Просмотров 2,4 млн
Game Boy games that did the impossible.
15:33
Просмотров 250 тыс.
A.I. Learns to Play Tetris
11:09
Просмотров 290 тыс.
Nearly 700k...
4:12
Просмотров 129
How Did I Complete This IMPOSSIBLE Tetris Challenge!?!?
16:10
Bugs & Glitches of High-Level NES Tetris
53:21
Просмотров 178 тыс.
💅🏻Айфон vs Андроид🤮
0:20
Просмотров 740 тыс.