Can a Computer Play the Perfect Game of Super Mario?

Mario_Bros._WorldMaybe you’ve seen these videos online of video game “speed-runs,” where the goal is to complete, let’s say, a game of “Super Mario Bros.” as fast as possible. They generally fall into one of two categories: actual humans playing the game in real-time, punching actual buttons and all that, or the “tool-assisted” variant, where players use an emulator to basically play the game slowed down, being able to use button combinations that wouldn’t be physically possible on a real controller, and, the big one: being able to “rewind” the game and doing moves over and over until they get them perfect.

I’ve played around with an NES and SNES emulator a bit and it’s basically like a combination of Neo’s powers at the end of “The Matrix” and the ability to travel back in time to fix mistakes that those aliens in “Edge of Tomorrow” have. After I’ve played that way for a few hours I got so used to this strange power that I had to remind myself the real world doesn’t quite work that way. Which is a good thing to keep in mind when you’re riding your bike down a busy street…

There are huge communities around both tool-assisted and non-assisted speed-runners, and one thing that kinda blows my mind is that even for games that have been around for two decades they are still setting new records on a regular basis. These guys and girls don’t rest on their laurels; they’re constantly looking for ways to improve the current runs, even if the end result’s just one frame faster than the old record. It’s fascinating.

The human element, even with tool-assisted speed-runs, is a huge, important part of the experience, and I immensely enjoy both the skill and the creativity on display there. But I was wondering if a computer program, on its own, would be able to find the fastest way through a video game. If we take something relatively simple like the the first Super Mario Bros. on the NES, and just let a computer play through all possible ways to play the first level, how long would it take to master it?

The options aren’t unlimited. The NES controller only has a few inputs: four directions (up, down, left, right), an “A”-button that makes Mario jump, and a “B”-button that, when held down, makes Mario run. Without physical restrictions (it’s impossible [I think?] to press both “up” and “down” simultaneously on the controller), our computer would have, on each frame of the game, the option to either press no button at all, one of the six buttons, a combination of two of the six, and so on. That’s, like, 64 unique button combinations per frame?

The longest the level can be played is until the timer runs out, which I gather is around 200 seconds. (I’ve just spent more time than I’d like to admit trying to come up with exact numbers on this. It gets pretty messy with frame rates and other stuff that I don’t really understand. Feel free to write in with the correct numbers.) Let’s say the game has 60 frames per second (again, not an exact number, just something to work with), that would mean a maximum of 12,000 frames per run-through, with 768,000 unique button combinations. Less than that, actually, if you stop the run each time Mario either dies or reaches the goal before the timer is up.

The world record for Level 1-1 of Super Mario Bros., as far as I can tell, is somewhere around 32 seconds (including the little victory animation at the end), so we can just tell our computer to stop trying if it hasn’t reached the goal after that time. So already we’re down to about 120 million button combinations that contain the fastest possible way (or ways) through the level.

If we have our computer play through each combination for 32 seconds in real time it should be done within 45 days.

And why stop there? The record for all of Super Mario Bros. is under 5 minutes, which should take our computer no longer than 10 years to beat (or confirm).

Let’s get on that.

2 thoughts on “Can a Computer Play the Perfect Game of Super Mario?

  1. Nope, sorry.

    The number of unique button combinations during 12000 frames is not 768000, it’s 144440108719300505854342146233905241558424453287954055525651133421061937678097707462584724889394797593844398202249790922619939812980192183842564006699447720026509550863268091747930850390683832269833190741360882812710750568835333168901198144823267563431967780404943205737053117665070705288249374413602646810653378608961748066846190351130479496423911966706432067558613576498817879884648255539541313657221930353069894773478118485967412383067557136639078733422277292282993661908559429815882447519366460521479622951299297379767670108867595483006587896150761725144524906244069181140969720683890280034167373331792210883855885091327950292561829431109198221482280526996075550879322577475417962250127845069275096650048401983524220852384572153618629068758719582005019435755354389365523018417976910639368203351269873155626952388005789341491877553385525056342750000659568318542977788010227283925875938484529459527873213046280080981838818438913260435416223917924878844363928692945484644345689743914534852994835844222102341083230132626831488106789112738070730705808871591561772872351322095399449473667417608453198216613954752224895411515063291343819992666437421636365551523318662577718845624945542370255002131078699043599999755893705452790046836228989489800088753697250188484229338193728835965903488350996614820834112804519355887746612261580307935314370212762564916330170376285252324272270369936262443032328183393608712626183443380107131789036430780365047739309598511856764374030620965366867721623452529060676717516905962033676414757005589675090907993637501539673320434792218071920628462580661142643145135075738108599177392162562366955636925977212008985307255151419166639955982167491268440272096065990034998269010512789922173353261824811655735425127606030122804755692594655519210727647152407270878252131720375328693592331744320329706872480683330069275196027153647235685413157066033224563668909367930403865978120665024539400510404483161203801670656452938345205828969818381277469991893535671551893182366895341899329628510017429600160913321954103048806459208249642336458009863032561982552990308907280563175467380504968125023376480033665435737116400511408107988218225002881839108101982672856553736713245516127801591041812881340852557814371355314901013269522658418546352883326604284379410463013370091133056498609390460924791847081227279628838594890902457772744626310674228562055737303041682522183024870380989062663008635175369432863693259953202788371168335890854880777070435514195206408149000445395772353771833316631025999859376040262833099543768539281104632931743872389457645805390318825797714876657075480120195954890652970068703981705654350281733489207123956830640916058254608078711477898117177193624524673486492167898548515507480183946823594933053449860198809909417933615130869687495606929286034812147481433437854296427671296246975983081294005781171425408627455639020531551825252818663225559327072031156319580824702594724129148102567912246566318194370561598071526005335596478291742056757223884406435261374004971989765716666388402467620374856775305516558579185076303083518346263214105587012210131919061409218228737716692827410617633548154608580048696757126714203499551633450707796302503308989022708309724761065203253433402788554558824660840635835067048102568952543592018548338499380717195586287930244576325463124441521402966579572051914971781022837811708321440550982589233707195536602892802652049618016137386084494077867713387144888594026225531462299725740642958120080808848934981155816306167605200737917378374784080710035579827308182763928333156213588651582979354899287039408861069473268929518509392432797827597518718410605385461306520203995679563449905756778510782834317585925361676366856285568840990106025995477619147582289901877928938438207537687864392330672192091376067544544621318643142923526745990721802738697341614979530641196814388466766782461134129629882888246352763422511756068589329400791681323867733934665534715343658790570050582632122921230170291658478669135004499786996101913173302103591103654146040661759489212771996232977787346384780542415014865353845215393628316394742732373544240938571888671621622971808698141430847103502601510362179595620685468540497989196336281919872145111741836709839879018893454731661905351831163686358989318644802041806397880038354217086468287614881905907274704061383945395478584530476077842171908378485015730400038489085347955231671452326923895999969504971485262609988243183002756830497939987838922646902840196078598663739977582561319971162867469406382163030291692935587522778277770343562478524290119093764506848601029775439787238073901737381914189494689685530617935754275181973118271404594124612187690190777625896978462165273911433216264929692281501406585931045295409530094801568007934113081862619830301369460659221997060534977258938054278182677726275419963482237309680247931718078053259816387647524468007915152509708842119901754129758497200828425079648454831671278572592901657212796542179045032931211947747561795598645643698546365608544289032482137745897979768233823188760664772155229556505164573973603528186934280083044575194027461448082397849982382376081747083801487622368237803605009652982565596607520747244189921955898314695409664340303043299472011743368722159011950116573079629038500174545029101973260941154563053478281183090615721045644696557536762333359955929983205466670344114285377918731727590244295192151021494609708966688196452732454555021140711816922483234247645826322233868338530340803783527540722298831543100594275827609648032736451739118830693280581014403948415218670082528528175044508275420283600890502197717563534601001381181050947887101383284960764886140235768953887829597958630563699388053883248155980186537920521281667019570766599292794602554353294191525097004710081756938148785348539426415322093211434999561534558324734816510975488173399040809573151255662873484157412876626812888437120466409293244054030352698006847837794488534062636020223608844373998063881989005782171295471157462360651080977138584775513226527611283248217783814358153040948006834673183603470612344901994299839003753703443728300645511856230973787772606577604596375201286359110853321835920753732781268153879913921158129075847090729628191223299155698713472017123379681151288014419379515656463248434688580592161166527159393059943324858316903622409935255645053159375571536890516912855171462917645282727246800695704034996315064151062213843706425904967883671419759656920868782817218296281983944760353823428666709481541340785327803658476910035906904555704396741171245073787608543861874659916335498214033367096126791689456815435285556220367693583386067553034399784143374545556556697381619199390989294665554052649777068071055204905536595640169099892049413053607134554431404831428110784692779657367317132404727499019108213287435489739935714417736716722543635914208580902199214482268233811667914515511922710442368339798161500343701398572488846769651670507622302086923147365728083267239747441068401735109236825203983416239334091195278954918347933127240008424152280911603196592507429034716386569914298605099037991578062438885340539290558355201959397509212213296823704037665068858379530503743741189072659023106072653137710596291120251745520989632049755242228121215717954878084200209072850807582137654985242621431672912428003202082586492500169426178509130310951675612920526844723349175021274443892827156310903150812430824467569276244007057235710891208714170021945521370907955240562817933021652752802215669883879369107718125735327689972862391841238395110429639876992538730388179779897465478993477164992744232108200713091030994356564092725316534909918810727012123111133301039531068565092988742422683413556302115454133333201672953542755515268932318112962301563869519339366836156361113975882040342996532325192631473056062003946658805345460656257697787421291450426759457469729822862020079230136787649474639273614213780115797637805505252237192938603490305113798464888606154557951545731895855101835939467094899460619587776350199676388982227283961240398239867323829322247732579422178860798462919992395839620761374101551972536137971236644928494094764397788347437300190967040939431187732790779623662026458075251817344375019531834631389821192058648424015859035518960539082245490257216735572750977129613159971409465847256866851294034595992511966700550541080866182891807355910839759979907864714621826016766162983669777541455167485481879294044508132382465175171442689148023429177582282438899432571017133875206985996525140758507385359260315288260374209518251196085577119414980221029425250584920617273406498279543101116448229492320319728753382469158665470057132320390670465009073008463724057052898567985952041531889759676371165590159752483217926603190502736454074688725805049022086696061237958631793156308054773680358417620395976283679353849265450693721757820977457974591102065389900374223889180719929762745028083617642885270248813684918882076611104573035872696733185912702110935391635567010651763430199181994347876445217111565305721682931181378294544410606998232693288762424175056894752500811321984201861845507539698221441043806225992847720588372469181570663149124737964758525792296646668752635261278051882457133471122127005818401954915570290942206890877900007133766610891571298883118622250634370841778836440272700976450628885921689713753770561323163168813865890792567433035081046584669919270401520115014564641810199512749969058356078302701696327216254583599877042806370676673462885061747083641223651235998345778397607391781252742479219649549793514131902401155290751353426161993920512968497832746811003970748164429109356778789482936187110684152730872948422980101542473807717517460509486393013081059898219638348654060108831774632088877303463826794832440709038872091184636380460802529811627920735217671375204663186374145130006392763868573777295791040548311572554307188862265770417087737327356265042432133662677516344933401585964506806499726756761608224549332982524954166507460313090822842336945494374795627527150969988388047899223036801746329009325335535229513902237009106328843946038319059878496241436495903402069644952784374377857433816151607882294865241712573811889646962783055050320390662283897791693287607999037776899277148591779440488772227786671573186399511406162102286758949861526387730875795769337844202443231170845028562329892075966394853444041064118837887124642826223891171359022765281394502624824861583419763680218050455475809909309437824402934684691849144416055086709478514802715114885913600484167568399420468257953383537868005191039387627048592696933342459647397689800845077409054763027177480324760317845405621672387272736547491890149555192089139175089892938286420513558559672369083900055292606730136244838019995608804044493149887327996095461740697681551092501480118340064239910022077426967819923310637872377187275480363053611058692438893949855739526642900116499294747199515864037776022525220355504854642906491933005659313750161923420625873293884843918071377183481897170501659096250848331795308439763788593649649760432810679833001070774938061705455662624671902945473176301266278455302702813183609458600919514056898882500374303662945434440798035048691114777378064748678596470362001822802311851549735872387515977049535226694183525591714129340611881586704735083297599545421742057341826938313991516657778514590634623314834469119478953160284443581630304494746233696472222991089492072554605730135282923247562970254928216266405386204523949829713121119924845943559966083802926451603820203371065523275760927501270726868302181681051118200350704803861325184641892896973178705683657505362498809744162687372861133267447175682319966448688695778839839101550832161002901157971123192494294963324415949172898444213150014794649172479286493940240519719413499902754878487049181441842568063029387223039350388356030403123427084670405700062380817487560322317881321044817881468379727299505894970238180025991510911148884602659785319087166026137279840377369220235642291217111850810349956871268755367120954750070272668229444058042391740448401406432476297612403639043433708075003539160670916123154037740070643029141592820697031534020707284000329766178223673867661440720240693521228209881527477613533599825319936664630894492385632150494769682136094172361030103207831570034463700748985002253998686478061700276642901890073210904785553585122996305743259266550859199899902850831523309748340044730991597211877618851093328198208969704364602680267550680969444182152554710284335774285231976825948911348036105031049959027915062978160724211199525894924793743939333072107360509406469774170173218086637414885537916532138832787458307895707761217361413305325103030956989446921579415445742279494915975116983489172298108859059976547049266557901421209664166506944448303109282026335068928440742118300072882852689848640866899522835726795558706977990528214081237200372570999593047216432009644422654774706026819372025624826078839741331083827435604345735254761274231960084392971681300447554826056931654666218740937405269969432086178022889409707966338961939089464612709394801816669520953180507447637214915010906684468241567066757451986593491132174012501433128781606472015745733901837153391720547195432880274012597002279978785947653015070624831795479762260325565083031470883975990946228744577604736520363061014895088642244217702552117386184325564535799053089444787785990180967450020066660585906531902530259197695923247024968101972723687331000034414243974768030842152099511027304141498487727706986899291680058606365470269159717788837310188723377626173141137849266432006861215943279420713384498395594582508251413393415167166030958924295632191142788034426690296872587126341549334320489444976380869605239838788821928203863578740574433210715747242022768242161877315265983072183182460678218355064111891961343812016914416206387801537339992893994404674212517005103709087016793872057371705227633303431368938412430109928738584879680304748824931589637815377832029806471221300199864454679042582873223019124467770045198814404543083537807066341927848595974542474927747095590792004369490611143912551703685959211080290498651306006924225915067795508117961592510856432637467887126801744584177104799523735515305946761095915553781967517059309046046878049101545142538343083667883363227021720522371395986761219548752384584093828400541264892978285032605116610194606267611005087352898294209562697926704958187055173975816730548166062779711051092630744927092860932346794118205720247818333442175587182701703577924941319802377838684290015214870888042283339062691448942775734627972190507715129613612619150857166677889302441649109441438428691722071517600764663049893451923796668872933293771557129064494071747932999358700395908934994873563550059443972180615777999631074430664071130087923731659529107101402516960251278079251267822119066534585046148146537511294891893905879921512016786942124702257472735507205648325408472999304205969980472417682886395438388597983003798280207819058586580871142570303744421166467409620532170013036442678677626538820963190405950104233630876656763618352967268418525055614573215122344989330382822851945468684149133474482383591661143729462106081239559582842871742521229190997570112333557319039167470725721445717434225808173690993420290207062897825354785696311052170151491273501488852368915795825834634719257320766511320619799070048375427356932081664732506734213944534460225037357775650850824081640397239596200570544913893665421304244494708039451712662630887228936524351158646709971907032934545361460834464699527177437303955556612738523565527699209607399951912690230660049369592137018339422416884073747912734326683583790221169732097317791653980950726804683487162183445081868012806275999941343055627301767911426931498406628691141536386863698589566439145357819090395948800371756043971652658394059096346376611862522289973628167721130004107690399107338350949113932324091521932885322723524058021887868244825083282994896321549346806415449656469546432950645706413048709528765696588890800737829692991508884249522739814016098990514713244923489199260278673828064341470752726148374415361291409225753467714094545190287656342618496563040021590553248596332057718078284519442794943664524946437576875929961263161042250579741415768599076238527424848796041670257073046806417988113403052563294653405787520953235901141320451892748134983225619288585103921136649841133420869725651226315964221051280715271095010890933272157726264894513418664746923753608456370121693611468384720284078696375417669246799630761101696243051201581396635891692628793817790669119608337315189547976585149166739462901731763560717680535175108671079105359579483676894057735418907641779170101953366560970090419471984972374901512973048855733577773779570390721501248382608293112928752974180483283816342527433332379816123159532673278016336494040858296134803820174825679010106748264328335164421414360289185904740290697121175664714054258204096032612103074070309656087359964369781481385748127899579298825052426121234879194721791765790713788307552641895846028224348444921673979076773732736660172351581175651154113331469241233133684504164271907777606547050727463208299660638388024615870450925951606402558628844216178051868607344535430630017123678502348445622695929851731550342620938131071956801588980409862533322709884740589475805983882442933387738325974331406780438382349582788483017743756573601934459078716650009742228112583991278198044112009594043754936168160855595905700814994802605668468919935083687807926078654818825887813228396872247236474433754366555165034951996884533739837649333069696730986964150343838221131948106961382549595986822385116928792756709603536122822244264048530790615438768344927127392078227657835216284029447138708698605100994175897285725899280710038885411537038916099468579296671809028168040577924020383273950207494157891053535775521250984341543762076147162543712800469210365435899027702673004452194325868025335609842756995338212815958269935733264237770115452876664031728425783238894077989083435549144526434741041423919297005444428357072025964226788115390038030116622776575510098453044590272820228459176299727004321606130955107403559014819408575064056438997508780951405149161788907400300757063260778813592201920767727195102838486439976528119166085746139207554111933761061898771591727263461460473071887723529464865068814905580549501817780191376233723645998321004552918423149620272705933340852218855410837626120814672590780572174077838345692641079199229194018246310472895188316848107162735889183953304565620281878924887556682904908175430053282422534383186798799156430705371904773034157658461149038506376835896235411548992530909918573426552629654556179595847797717016712126825064228515056946356947967978977233593795981273713230897637827817160681570629395600575811428957703615244568532283349716473668594645769228618634937492107084340683075200366969197650767200307914329897164660811029599713506929257045452743211471030855964890705124045047561672764848301210839542228532533617574070974061216212150657524646985172106419989776887210307231073168779098937278055577364596935127947170206623594893559292923954617881744736517435896919163331737689501685095514244694587505221341892787558184314322337064136408439014453805358520115727692688918743794711180588661169747381921751996118151816769905886810184886326769562970117338512533626250227641609368010821259225840134118795842734040948120231283449688909717369188626728604142822065480343031333955480623571156049987951158095623321964936331362850574725917574425292355323298604498621174768866133770236982423074180944963189178261208223357048614454587881444337331532691735935969459094210240983072565279386393781974288145588420301122634491319362182843824746776689103150714661885629262955848135538473582814742239471794740754739698541311667111084905011877433977439276200506705636429745638606515646809241640137974139264557472892566799453809738401606138882033923339630285941516139691740192071445497003739755000593004075955304202304527540065874393718481053033393020363857333664081127148230222044581286907721612195882335696763328565431278403935136389979266051083145619684443844624605903776224739684278986156707322023788429032210771553235735345434239990571276186457236106564310271132979568608775172493792306298757552141463691828235456144546053837898394903696609457233269658107766921608910747904596632785259053133633618414310972535675375984372186013308851672344747519315634631993883165448786351055600903459219498449061498811392909291152887528132981424745552450351776130906557674294000327675543905606508505116836485918829786665182371522676268924288612019086617679971765278599418518852056534122695657267453086938912812004709186145298140383831108158688119824029331930812456974188067147506151497559600394118445656760406626779347638775589305445073239141586669782947780236295300915084749863419424236263102096083012832903882132818644909014524733852063803297964358050641133399191405144061682350576341966240741870070668056505989675021263957570885681652600278054197502819930918312692263677899761204960693994597304692368846769747414059932702433091717154040381449166795156604891206347782034594772570055628384613001497362402162483777598131148979785155475692317838046850188463322139411693385356595744141792226356967546570141823597447462518772984609150239270095594998861582146877605632258437564377157164855599818863841888245930550204878607115379639181487376557685476580114341952600260871879711571547434637992153908859963879763258862896127920961193767283498878439678842322591511557249704460528530267687169040062272533268955779516640719634618406791604825668847273928937473999880279611528264289181816298623394480180693893954263291018073687424248842559960194922902970224846375286702980429740020156986703296405880354487185881014205535405344448034126220789135756083961396737009232787807491395512288427499803114660043331190305553123096567356319005765654101082865094106210816229376

  2. I’ve been exploring for a little for any high quality articles or weblog posts on this sort of house .
    Exploring in Yahoo I ultimately stumbled upon this
    site. Reading this info So i’m glad to show that I’ve a very good uncanny feeling I found out exactly what
    I needed. I so much for sure will make certain to do not
    put out of your mind this web site and give it a look on a
    relentless basis.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: