Anda di halaman 1dari 17

ContentGenerationinDungeonRun

DungeonRun2:DualWield isanactionadventureroguelike.Basically,thegametakesthe
commontropesofdungeoncrawlinginroguelikesandtranslatestheseintoarealtimeaction
game,notunlikea2D Zeldagame.Thelattertypeofgameischaracterizedbyfairlytightlevel
designwithmanylockandkeypuzzles.Although DungeonRun issomewhatlooserindesign,
andasaroguelikedependsalsoonstrategicchoicesandtheabilityoftheplayertoimprovise.
Still,thetypeofgameplaydemandshighstandardsforthegenerateddungeons.Thismeans
thatindesigningthedungeongeneratorIhadtogobeyondthetechniquescommonlyfoundin
roguelikes,tocreatefundungeonswithchallengingquestsandpuzzlesthatspanmultiple
dungeonlevels.

Thisarticledescribesmyapproachtocontentgenerationforthisgame.Itoutlinesthegeneral
approach(ModelDrivenEngineering)andtalksabouttheimportanceofworkingwiththeright
typeofmodels.Itgoesintoconsiderabledetailwherelockandkeygenerationareconcerned.I
feelthelessonsIlearnedindevelopingthisgame(andthetechniquesbehindit)applytomany
gamebeyond DungeonRun .

Disclaimer:Atthemomentofwritingatleast90%ofthestuffIwriteaboutisactually
implementedinthegame.Theremaining10%areplansofwhichIprettysurethatwillget
implemented.Thatbeingsaid,thegameremainsindevelopment,andIamsureIwilladdstuff
tothegamenotcoveredinthisarticle.

Approach:ModelDrivenEngineering
Tostartwith,thegeneralapproachIusedcomesfromModelDrivenEngineering.Ihavebeen
researchingthistechniqueonandoffforseveralyears.ThetoolsetIhavedevelopedforthis
research(Ludoscope)istailoredtowardsModelDrivenEngineering(seefigure1andsidebar
below).Needlesstosay,withoutthistool,DungeonRun wouldnothavebeenpossible.The
ideabehindModelDrivenEngineeringisquitesimple:donottrytogeneratesomething,inthis
caseadungeon,inonehugestep,butratherbreaktheprocessdownintomanyindividualsteps
thateachproducesamodel,whichitpassesontothenextstepintheprocess.Everymodelin
theprocessisamorerefinedrepresentationofthethingyouwanttogenerate,andeverystep
andmodelmustbemeaningfulinthemselves.

Thisapproachhasanumberofclearadvantages.Itisfareasiertomanagethanonebigblack
boxtypealgorithm.Eachstepcanbedesignedanddebuggedindividually.Butmore
importantly,usingdifferentmodelsasthetargetoutputforeachstepallowsyoutousetheright
typeofmodeltosolvetherightproblems.Forexample,thelogicoflockandkeypuzzlesisfar
easiertorepresentwithgraphs,whereasthelayoutandgeographicstructureofadungeonis
bettercapturesusingtilemapsor2Dshapes.


Figure1:Ludoscope

WhatisLudoscope?
Ludoscopeisageneralpurposetooltodesigncontentgeneration.Thetoolisdesigned
aroundtheuseoftransformationalgrammarstocreatecontent,andsetuptofollowthe
ideasofModelDrivenEngineering.Ludoscopecanhandledifferenttypesof
transformationalgrammars:stringgrammars,graphgrammars,tilegrammarsandshape
grammars,andincludesanumberofoperationsthatmanipulateandtranslatebetween
differenttypesofmodels.
Ludoscopeallowsyoutosetupanynumberofmodules,eachwhichexecutesa
grammar,orfollowsapredefinedscript(mixingtheapplicationoftransformationrules
andotheroperations)andcreatesanewmodelbasedonitsinput.Ludoscopeallows
multipleinputsandoutputsbetweenmodulesandhassomebasicbranchinglogicsthat
allowsyoutocreateloopsandlogicalgates.

Inaddition,Ludoscopeextendssomebasicnotionsoftransformationalgrammars.Most
importantly,itallowssymbolstohavearbitrarilydefinedmembervalues,andcan
manipulateandfilteronthosememberswhenapplyingtransformationrules.For
exampleastringgrammarruleinLudoscopemightread:

A(n>0)=>A(n)B

ApplyingthisruletotheexpressionA(n=6)willalwaysresultin:

A(n=0)BBBBBB

IhavebeenusingLudoscopeanditsassociatedcontentgenerationlibraryinseveral
games.

AbstractandGeographicModels
IliketobreakdownthetypesofmodelsIuseintotwomaincategories:abstractand
geographic.Abstractmodelsareoftengraphsorstringsrepresentingthelogicembeddedintoa
dungeon,whereasthegeographicmodelsIusedaremostlytilemapsthatdescribehowthe
dungeonisactuallyconstructed.Forexample,thegraphfigure2representtheroomstructureof
alevelinDungeonRun ,includingtheplacementoflocksandkeys,triggersthatoperatetraps
andturrets,whichenemiespatrolorguardwhichareas,andsoon.Whilethetilemapinfigure3
isthefinalizedmodelforthesamelevel.


Figure2:spacestructureofadungeon,nodesrepresentsroomsthatcontainenemies
andhazords(red),decoration(blue),hints(green),chests(orange)anditems(yellow).
Thegreeneandgandaretheentranceandexitrespectively.


Figure3:tilemapofthesamedungeon,showingrooms,deepandshallowwater,a
coupleofbridgesandmanyobjectsscatteredaround.

ThesetwocategoriescorrespondcloselytotheelementsofleveldesignwhichIelsewherecall
missionandspace.Nowoneoftheharderthingstotacklewiththisapproachishowtotranslate
abstractmissionstructuresintoconcretespatiallayouts.InthepastIhavetriedseveral
techniques:includingautomaticlayoutofgraphsandfoldinggraphsovervoronoidiagrams.For
thiscase(andacoupleofothers)Ihavesettledonusingmodelsthataregraphs,butgraphs
thatalreadyhavesomeexistinggeographicstructure.Inthiscase,Istartedoffromagraphthat
representsagridofrooms(seefigure4).


Figure4Agraphgridrepresentingthestartofnewalevel

TheprocessofgeneratingalevelinDungeonRunroughlyfollowsthefollowingsteps(which
arealsodepictedinfigure5):

Agraphgridiscreated.
Arandomnodeinthegridisappointedastheentrance.Fromtheentrancearandom
pathiscreated.Attheendofthepaththeexitislocated.
Possiblealternativepathsandextrabranchesareidentified.
Onthepathanumberofobstaclesareplaced,includingacouplepossiblelockandkey
mechanisms,wherethekeyisplacedattheendofabranchingpath.Aprogressive
difficultyisaddedtoeachroomonthemainpath.Basicallythedifficultyassignedto
eachroomis10minusthenumberofobstaclesyouhavepassedtogetthere.
Locksandkeysmightbeplacedonthemainpath.
Alternativepathsareassignedanumberofobstaclesbasedonthedifficultydifference
atthestartandtheendofthealternativepath.Theobstaclesoneachindividualpath
canbethemed:somemightinvolvemagic,lotsoffighting,ortraps.Locksandkeys
mightcontrolthetwoentrancesofthealternativepath.
Extrabranchesgetgetbonusrewardsandmoreobstaclesassignedtothem,thatmight
alsobethemedinasimilarway.Alockandkeymightbeaddedtothestartofthe
branch.
Lockandkeymechanicsaredetermined.Whatgameelementsareusedaslockandkey
dependsonwhatthedungeonlevelisallowedtodo(canituselavaforexample),but
alsoonstructuralcharacteristicsrequiredbythelockandkeymechanismsthemselves
(explainedindetailbelow).
Theremainingtasksarespecified:obstaclesbecomeenemies,traps,andsoon.
Roomsaredecoratedandassignedatype(room,corridor,tunnel,orcavern)basedon
whatisinthem.Extralootisscatteredinthedungeon.
Thewholestructuregetstranslatedintoatilemap.
Severaltilemapoperationscreatethecorrectoutlineforrooms,corridors,caverns,and
soon.Eachroom,andcorridormaintainsareferencetotheoriginalroomnodeinthe
graphstructure.
Inaseparatestep,lakesofwater,poolsoflavaandchasmaregenerated.
Theterrainissuperimposedonthedungeonandresolvedtomakesurethedungeon
structureismoreorlessmaintained.
Objects,enemies,traps,anddecorationsareplacedinthedungeon.
Nowalotof'magic'happensineachindividualstep.Thereisfartoomuchdetailto
discusseverythingindetail.IntherestofthisarticleIwillcherrypickacoupleofthe
moreinterestingexamples.

Figure5Theentireprocess

Generatestructurefirst,specifylater
Inmyexperience,anycontentgenerationprocedureshouldstartwithcreatingabstractshape
andstructureandrefiningtheseintospecificleveldesigns.Animportantreasonforthisisthat
whenyoustartswithgeneratingspecificconstructions,youoftenenduptryingtocontrolthe
outputtoomuch.Youmighthavebeenbetteroffhanddesigninglevels.Asanexampleof
focussingonstructurebeforefocussingondetails:inDungeonRuntheentiredungeonconsists
ofroomsandobstacles.Theirexactnatureisnotdefinedatthispoint.Lateron,anobstacle
mightturnintoanenemy,atrap,alockeddoor,andsoon.Androomswithmanystuffendup
beingactualrooms,whileroomsthathavelittleinthemmightbeturnedintocorridors.The
advantageofleavingthenatureoftheobstacleundeterminedinitially,isthatIcanassign
structuralrolestoobstaclesfirst,andlaterdesignwhatspecifictypeofobstaclebestmatches
theroleassignedtoit.Forexample,anobstaclemightbeassignedtherolethatitcando
damage,orthatitteststheplayer'sdexterity,orboth.Basedontheplacementoftheobstacle
(isitonthemainpath,andalternativeroute,orabranchleadingtoareward)differentattributes
canbeassignedtoit.Ingeneral,Ifounditfarmoreeffectivetoletthestructureofthedungeon
dictateallthesethingsbeforeItrytodeterminewhatspecificobstacleisbestused.
Nowyoumightthinkthatthismeansthatisgenerallybettertostartwithabstractmodelssuch
asgraphsfirst,butthisnotnecessarilytrue.AsIhavefoundoutdesigningtherightwaytodeal
withthealternativepathsinthedungeon,sometimesitisbettertoletthespatialaffordancesof
thedungeondictatethedesign.

ThisisalessonIhadtolearnthehardway:whencreatingalternativepathsIfirstwastempted
totrytogeneratemoreorlessbalancedpathsfromthestart.Itsimplyseemedthenaturalway
togo.However,thatprovedtobeverytricky.Easyenoughwithinthelogicofagraph,butvery
hardtomaptospacecorrectly.AtonepointIswitchbacktousingagraphthatwaslockedtoa
gridtogeneratepathsinamoregeographicfashion.Thiscreatestoproblemthatitwasvery
difficulttocontrolthelengthofalternativepaths.Analternativemightcutthemainpathshortbe
severalnodes,makingitthefarbetterroute.However,atonepointIrealizedthatthisisnot
necessarilyabadthing,infact,itprovedtobeanopportunity.Itsimplymeansthatmoreand
moredifficultobstaclesneedtobeplacedwithinthatbranch.Inmyexperienceitturnsoutthat
lettingarbitraryandrandomspatialconstraintsdictatedesignsolutionstocreateaninterestinga
balancedgameisafareasierwaytogeneratevarietythantryingtocontrolthedesignspace
fromthestart.Itissomewhatakintodrawingadungeonbyhandonanemptypieceofpaper,or
onerandomlyfoldedandcut.Thelattertechniqueinspiresmuchmorecreativityfrommost
designers.

Thepartsofthegenerationprocessthatareresponsibletocreateaninterestingexperienceare
basicallysolvingtheproblemstheearlierandmorerandompartsofthegeneratorisgenerating:
Thealternativerouteiscuttingalongmainpathshort,howtobalancethat?Thisbranchgoes
nowhere,whatcanIdotomakeitinterestingorrewardingfortheplayer,nonetheless?What
arethechokepointsinthislevelandhowcanIbestusedthem?

GameDesign:Workingwiththerightcomponents
NowIwouldbelyingifIwouldnotadmitthatproceduralcontentgenerationisabout50%clever
algorithmsand50%happyaccidents.SometimesDungeonRunproducesveryinterestingcurve
balls,butfrequentlythisistheresultofaluckycombinationofgamefeatures.Thereisprobably
nowayaroundit,andwehavetoacceptthatwhengeneratinglevelsforagamelikeDUngeon
Run,nothingcanbeatawellconstructedleveldesignedbyanexperiencedhumandesigner.
However,whatwecandoistodesignthegame'scomponentinsuchwaythatthechancefor
happyaccidentsismaximized.Asaresultthefeelofthedungeonmightapproachtheapparent
clevernessofhanddesignedlevels.

ForDungeonRun,andmanyotherroguelikes,thewayhappyaccidentsareencourageditto
makeeachindividualgameelementhavemanypossibleinteractionswithotherelementsinthe
game.Forexample,asimpleelementlikethetorchinDungeonRunhasmanypossible
interactions:itprovideslight,whichallowsyoutodetecttrapsmoreeasily,butalsomakesusing
stealthimpossible.Ratsfeartorches,butswimmingdousestorches,makingsurethatyoudon't
wanttogoforaswimwithmanyratsnearby(andasithappensthechancesforwatertoappear
increaseswhenratsareinalevel).Gassesmightexplodeorburnawaywhenignitedbya
burningtorch,creatingpotentialdeathtraps,aswellasviablestrategiestoovercomeobstacles.
Themoreinteractionsyoucandesignintoyourgameelementsthebetter.Especiallyifthose
reactionsarebothgoodandbad.Thatwayyouavoidemergingdominantstrategies(atleastto
acertainpoint).Thetorchisagoodexampleofgoodandbadeffects,butsoaremanypotions.
Levitationforexample,allowsyoutocrosshazardousterrainsafelyandavoidtraps.Butitalso
preventsyoufrompickingupsubmergeditems,andmakesyourcharactermoredifficultto
control.Inadditionyouhavetobeverycarefulwhenapotionisnearlyfinishedasyoumightfall
intoagaporevenbekilledbylandingonlava.AllpossiblecombinationsinDungeonRunare
toomanytocataloguehere,butingeneralallmainfeaturesofthegame:weapons,enemies,
traps,terrain,gasses,light,darkness,andmagiceffects,aresetuptomaximizeinteractions
betweenthem.

MetaDesign:PlanningtheDungeon
Sofar,Ihavebeengoingonaboutthegenerationofindividuallevelsofthedungeon.However,
thatisnotwheretheactualgenerationprocessin DungeonRun starts.Itstartswithageneral
planfortheentiredungeon.Atitssimplestthatplanisasuccessionofdungeonlevelswiththe
AmuletofYendorplacedataspecificlevel.Butthedungeonplandictatesmuchmore:itcreates
pacing,bysettingupbossesandspecialrewardseverysooften,itcreatespuzzlesthatspan
multipledungeonlevels,anditallowstheforeshadowingofsomeoftheseevents.

Theplacementofrewardsplaysanimportantroleinthisdesign.Arewardisfoundonabout1in
3levels.Rewardsmightincludevaultsoftreasure,specialmagicalweapons,orsimplyaspecial
itemrequiredtoprogressthroughthedungeon.Allrewardsareguardedbybosses,although
somerewardkeysthatgiveaccesstotherewardinsteadoftherewardsthemselves.Bosses
playanimportantroleinhowlevelsarethemed.Crucially,eachbosscastsashadowtolevels
aboveit.Forexample,oneofthefirstbossesyoumightencounterinthedungeonisthegiant
rat.Ifitislocatedatlevel2,youaresureyoucanfindmanyratsatthatlevel,too.Andonthe
level1aswell.Foreshadowingiscreatedbyusingspecificminionsforabossyou'lllikely
encountersoon,butalsobyprovidingparticularsortofequipmenttodealwiththebossorits
minions.Forexample,thereisaspecifichintthatisoftengeneratedwhenplayersfind
themselvesonalevelwithmanyratsforthefirsttimetellingthatratsfearfire,atthesametime,
moretorchesareplacedonthatleveltofind.Whenhavingtodealwithmanyskeletons,that
gameislikelytogenerateastashofScrollsofLastRites,whichpreventsskeletonsfromrising
againafteryoudefeatedthem.

Figure6givesasimplifiedexampleofadungeonplan.Itsimplydetermineswhatsortof
enemies,terrain,bosses,specialrewardsshouldbeencounteredonaparticularlevel.Someof
theseitemsaretranslateddirectlyintogenerationinstructionsforthelevelgenerator:thislevel
mustincludeaboss,twobonusitems,andahint,forexample,orthislevellikelycontainslakes
oflava,butnoroomsandcorridors.Inaddition,thelevelgeneratordoesn'treallyspecifywhat
specificcreaturesareplacedinthedungeon,ratheritspecifiestheirrole:itisaheavyhitting
enemythatcanpatrol,oramagiccreaturethatisguardingthischest.Itisonlywhenthelevelis
actuallyinstantiatedthegamedetermineswhatspecificcreaturesallowedbythedungeonplan
bestfulfilltheseparticularroles.


Figure6:Alimitedsampleofadungeongeneratedwithfivefloorsandtwovaults.
Legend:e=enemy,b=boss,lvl=level,vlt=vault,hi=hint,it=item,t=test.Yellowconnections
indicatelinksofassociation.

Thiswaycoherencecanbecreatedinthedungeon,uptothepointthatquestsandstorylines
givethedungeonflavorandpurpose.Rightnowthegeneratoriscapableofforeshadowing
bossesusingenemytypesandexplicithints.Itcangeneratelockandkeysspreadovermultiple
floors,createalternativeroutesbackupintovaults,andrewardspecialquestitemssuchasthe
hookshotoramagicbowthatcanexploitedaskeymechanismsaftertheyhavebeenfound.

Beyondsimplelocksandkeys
Locksandkeysarethestapleofdungeondesignin Zelda games.AsDungeonRun borrows
gameplayfromthatseries,locksandkeysaremoreprevalent DungeonRun thaninmost
roguelikes.IntheZeldagames,thedesignoflockandkeymechanismsiscriticalforthe
gameplay.Locksandkeysarenotjustactuallylockeddoorsandassociatedkeys,althoughthey
sometimesarejustthat.Rather,mostlocksandkeyscomeinmanydifferentshapesandsizes,
astooobviouslocksandkeysareveryboringveryquickly.

ForDungeonRunthismeansthatthekeysbeinggeneratedshouldfollowsimilarlogic.They
needtobequitefrequent,butvariedasmuchaspossible,butpreferablywithoutcreating
deadlocksorotherdesignflawsthatmightenduptrappingtheplayerinanunbeatablelevel.In
ordertomakethathappenthegenerationprocessneedstobeawareofthedifferentattributes
locksandkeysmighthave,andhowtheserelatetothestructureofthedungeon.Belowisa
discussionofsomeofthesequalities,followedbyadiscussionhowthesequalitieswere
leveragedtocreatemoreinterestingquestsin DungeonRun.

LocksmightbeConditional,DangerousorUncertain .Typicallywethinkaboutlocksas
binarybarriers,ifyouhavethekeyyoucancrossthebarrier,ifyoudon'thavethekeyyou
simplycannot.Lockeddoors,inwhateverwaytheyareunlockedoropened,arethetypical
example.Irefertothistypeoflockasaconditionallocks.Locksdonotneedtofunctioninthat
way.Somelocksarebarriersthatmightbenavigatedwithoutakey,butthiscrossingthebarrier
mightbeuncertainorimposeacertainrisk.Keysforthistypeoflockmakethecrossingless
dangerous,ormorecertain.Asimpleexampleofanuncertainlockwouldbeasecretdoor,
whichisopenedifoneisabletofindit(acertainmatterofuncertainty).Adangerouslockcould
bealakeoflavawhichmightbecrossedattheexpenseofhitpoints(acertainrisk).Amagic
scrollofmagicmappingthatrevealssecretdoorsorapotionthatprotectsyouagainstfire
damagecanactaskeysforthosedoors,makingiteasiertocrossthelockinbothcases.In
generalIfindthelattertwotypesoflockstobemoreinterestingastheyallowformorevaried
gameplay.Insteadofsimplyhittinganarbitrarybarrier,theplayermighttrytocross,failand
retreat,comeupwithdifferentstrategies,andsoon.Keysfordangerousoruncertainlocks
mightbecombinedthereduceriskevenfurthercallingforcarefulriskassessmentsonthepart
oftheplayer.However,conditionallocksdohavetheiruses,especiallywithinprotectingquest
objectivesandpreventingtheplayerfromenteringcertainlocationsbeforetheyareready.
However,inmyexperience,itisbesttouseconditionallockssparinglyastheycanmakea
gamefeelmorerigidandboremoreeasilythandangerousoruncertainlocksdo.
Notethatalockcanbeconditionalanddangerous,ordangerousanduncertain.Forexample
whencrossingadangerousarearequiresyoutohaveacertainkeyitemtoeventrytomakeit
through.Thelockisbothconditionalanddangerous.

LocksarePermanent,Reversible,orTemporary. Whenyouunlockadoor,thatdoormight
remainunlockedforever(permanent),forashortperiodoftime(temporary),oruntilitis
relocked(reversible).Permanentlocksarethesafesttouse,asoncetheyareopenednothing
cangowrong.Temporarydoorstypicallyproducesmoregameplayatacertainrisk,theycan
turnintovalves(seebelow).Reversiblelockscancreateproblemsdependingonthetypeofkey
youareusingforthem(seebelow).InDungeonRunItriedtocreatepermanentlocksforthe
mainpathdownintothedungeon,butbonusobjectivesandalternativeroutescanmakemore
frequentuseofothertypes.

LocksmightbeValves,orAsymmetrical .Certainlocksallowyoutocrossonlyinone
direction(valves),whileotherscanonlybeopenedfromonedirectionbuttraversedintwo
directionsaftertheyareopened(asymmetrical).Valvesandasymmetricallockstypicallyare
conditionallocks,buttheytendtocreatemoreinterestingconditionallocks.Alsotheyhave
differenteffectsonthestructureofadungeon.ForDungeonRun2Iusedthemtogreateffectto
sealofoneortwoendsofanalternativeroute.Forexample,byusingavalveastheaccess
pointtothestartofanalternativerouteyouforcetheplayertocommittothatrouteeventhough
thatrouteturnsouttobemorechallenging.Theuseofvalvesandorasymmetricallocksalso
createsapossiblesolutionfortheproblemoftooshortalternativeroutes(asdiscussedabove).
Ifthatroutecanonlybeusedtotravelback,theproblemissolved.Infactyouseemanyofsuch
asymmetricallockscreatingpermanentshortcutstoacentralhubinZeldalevels.Asymmetry
canalsobeaproblemwithlocksonthemainpathinDungeonRunastheplayeractuallymight
getbehindthemaccidently.Soforexamplewhenakeyneedtobefoundtounlockadooron
themainpath,DungeonRungeneratesasecondkeyjustbehindthelockfortheplayertouse
shouldhavefoundanotherwaydown.

Specialcase:theunlockedvalve. Ialsothinkofvalvesaslocks,althoughmanyvalves
don'tneedakey.ForexampletheplayerjumpingdownachasminDungeonisusinga
valveintothenextlevel(andariskyoneatthat!).Otherunlockedvalvesinthegame
includecollapsingbridgesoverlakesoflava.Althoughtheyarenotlockedperse,they
sharemanysimilarpropertiesoflocksactuallyoperatedbyakey.

LocksandKeyscanbeSafeorUnsafe .Asafelockisguaranteedtohaveasolution,whilea
unsafelockisnot.Toacertainextendadangerousorauncertainlockisalwayssafe.Itis
importantforagamelikeDungeonRuntohaveonlysafe,conditionallocksonitsmainpath.It
isfinetouseunsafe,conditionallocksonoptionalpaths,althoughifthatlockisalsotemporary
oravalve,youmustmakesurethatthepathbackissafelylocked(iflockedatall).Whethera
lockissafeorunsafedependsontheparticularsofthelockanditskey.Sometimesweird
combinationsofgameelementsmightmakealockunsafe.ForexampleinDungeonRunisis
possibleforakeytobecarriedbyanenemy.Ifthatenemyisthenkilledbythrowingitintoa
chasm,thekeyislost,andthelockremainslockedforever.Soessentiallythatlockandkey
combinationwasunsafe.Itcanhelptomarkthekeyas'mustbesafe'whenusingitona
missioncriticalpath,soatleastthegamecanrespondwhenitisabouttobelost.

KeyscanbeSinglePurposeorMultiPurpose. Singlepurposekeyscanonlybeusedto
openalock,andfornothingelse,whilemultipurposekeyscanalsobeusedindifferentways.
Evenifakeycanopenmultiplelocksitcanbeconsideredtobemultipurpose.Ingeneralitis
bettertomakeuseofmultipurposekeys,assinglepurposekeysaremoreboringand
frequentlyendupasdeadweightinyourinventory.ThewayZeldadungeonsfrequentlyusethe
bowasakeybyhittingswitchesfromadistanceisagoodexampleofamultipurposekey.In
fact,manyofthebestkeysinZeldaalsodoubleasaweapon.

KeysareParticularorNonParticular. Particularkeysaretheonlythingthatunlocksa
particularlock,whereasseveralnonparticularkeysmightunlockasinglelock.Justas
conditionallockstendtobemoreboringthandangerousoruncertainlocks,particularkeystend
tobemoreboringthannonparticularkeys.Oftenbecausenonparticularkeystendtobe
multipurposeaswell(althoughtheydonotneedtobe).Particularkeysfunctionasdoreallife
keys,whilethesmallkeysofZeldaDungeonareagoodexampleofsinglepurpose,
nonparticularkeys.Oneeffectofusingnonparticularkeysisthattheyplayerforwhatever
reasonmighthaveonewhentheencounterthelock,especiallywhenyouhavenotplaceda
nonparticularkeyforeachlockyouwantittoopen,thiscanmakeconditionallocksfeelless
rigid.

KeysmightbeConsumedorPersistent. Keysthataredestroyedsomehowintheprocessof
unlockingadoorareconsumable,whilekeysthatarenotarepersistent.Keysthatare
consumedtendtobelesssafethanpersistentkeys,especiallyifthosekeysarealso
multipurposeandcanbeconsumedtoachieveothergoals.SmallkeysinZeldaareconsumed,
asisapotionoffireimmunitythatisplacedasakeytopassacertainfirebarrier.Like
nonparticularkeys,consumablekeysmightmakeaconditionallocklessrigid,butalsoalot
lesssafe.

KeysmightbeFixedinPlace. Leversandswitchesarethebestexampleofkeysthatare
fixedinplace(andtypicallysinglepurposeandparticularaswell).Oneproblemoffixedinplace
keysisthatifthereisonlyonekeyononesideofthelock,itmakesthelockasymmetrical.
Oftenitisbesttomakethelockstriggeredbykeysthatarefixedinplaceopenpermanently.
Especiallywhentheplayercanreachthekeyonlyonce,whicheffectivelywouldmakethekey
consumableandprobablyunsafeaswell.Whenusingkeysthatarefixedinplaceitisoften
importanttogivesomesortoffeedbackonthestatusofthedoor,aremakesurethelockis
permanentandnotreversible(asoftenisthecasewithlevers).

Discussion:CombiningandTransformingLocksandKeys
Locksandkeystendtobestrungtogether.Forexample,adoormightbeopenedbyaleverthat
isplacedbehindafieldoffire,forwhichtheplayercanfindapotionoffireimmunityelsewhere.
Whenstringingtogetherkeysinthiswayyoutransfercharacteristicsfromonelockandkey
mechanismtothenext.Inthecaseoftheexampleabovethedoornowisunsafe,becausethe
playermightusethepotionforsomethingelseandneverbeabletoreachtheleverinthefirst
place.

Asshouldhavebecomeclearfromthedescriptionsabove,eachtypeoflockandkeyhasits
functionwithinthedungeon.Usingawidevarietyoftypesoflocksandkeyswilladdgreater
varietytoyourgame.Atthesametimeitiscriticalforthemainroutetouseonlysafe,and
symmetrickeys,(andnottoomanyconditionallocks).Inordertodosoitisimportantto
understandwhatcombinationsofcharacteristicsmakealockandkeycombinationunsafe,and
whatcanbedonetomakesurethegamestaysfair.Togetbacktotheexampleabove,you
mightalsowanttomakesurethattheplayercangobacksafely.Thefieldoffireinthiscaseisa
temporarylockopenedbyaconsumablekey.Whiletheplayerneedstocrossittwice.The
playermightnotgetbackintime.Forthisreasonitisbesttoallowtheplayertoreturnthrough
inavalveorbetterstill,anasymmetrical,permanentlock.Thatwaytheplayercanalwaysreturn
tothelevertomakesureitismovedtotherightposition.

DungeonRunmakesheavyuseofallthesedifferentcharacteristicsoflocksandkeysduring
thedungeongeneration.Beforespecifyingwhatspecifictypeoflockorkeyisused,thegame
generatedthecharacteristicsthatarebestsuitedtothecircumstances.Forexample,theygame
usesvalvesandasymmetricallockstooneortwoendsofanalternativeroute,whilealllocks
andkeysthatarebeinggeneratedonthemainpathmustbesafeandsymmetrical.
Thewaythegeneratorenforcesthis,isnotbyrestrictingthetypesoflockandkeysusableon
themainpath,butbybeingawareofallthesecharacteristicsandfixingproblemsastheyarise.
Forexample,whenadoorunlockedbyaremotetriggerisusedonthemainpath,thegenerate
isawareofthefactitjustusedanasymmetricallockwhereitshouldnothaveusedone.Asa
resultitwilleithermakethelocksymmetricalbyaddinganextrakeyontheothersideofthe
door,orbycreatingalternativevalve(orasymmetricallock)toallowtheplayerasafereturn.
Figure7belowshowsanumberagraphgrammarrulesusedbythegeneratorinordertocreate
lockandkeys.Notethatingeneraltheseworkinthreesteps.Firstthelockisgenerated,nexta
suitablekeyisadded,andfinallythatkeymightbeprotectedsomehow(possiblybyanother
lockandkeymechanism).


Figure7:somegraphgrammarrulestocreatelocksandkeys

Graphscanbehardtoread.Soherearesomenaturallanguagetranslationsoftherules
thathandlelocksandkeys:
ALockcanaflameventingturret999
(Whenratsareviableenemies)ALockcanbeafightagainstmanyratswithits
Keybeingatorchandabookexplainingratsfearfire.
(Whenratsareviableenemies)ALockcanbeafightagainstmanypoisonous
ratswithisKeybeingapotionofpoisonimmunity.Optionallyprovideahinttothe
natureofthepotion.
(Whenkoboldsareviableenemies)ALockcanbeafightagainstmanykobolds
withiskeybeingaleverthatactivatespoisonventsnearby.
ALockcanbeaperiodicpoisonvent.
ALockcanbeaperiodicexplosivegasventnearaburningtorch.
ALockcanbeanhardtoavoidtrap.
ALockcanbeasecretdoor.
A(conditional)Lockcanbelockeddoor.
(Whenlavaisallowed)ALockcanbeapooloflava.
(Whenchasmsareallowed)ALockcanbeachasm.
(Whenwaterisallowed)AValvecanbeacollapsingbridgeacrossdeepwater
(removeKey)
AKeytoalockeddoor(thatcanbeasymmetrical)canbeauniquekeyora
lever.
AKeytoalockeddoor(thatcannotbeasymmetrical)canbeauniquekeyora
leverwithaduplicateontheotherhand.
AKeytoasecretdoorcanbeascrollofmagicmappingoramapofthedungeon
floor.
AKeytoasecretdoorcanbeaunlittorchthatmustbelittoopenthedoor.With
ahintrevealingthesecret.
AKeytoapooloflavacanbeapotionoffireimmunityorapotionoflevitation.
Ifapotionisthekeytoapooloflava(thatmustbesymmetrical),addaleverto
raiseabridgeonthepool'sfarend.
Alevercanbeprotectedbyanenemythatguardsthattrigger.
Apotionthatneedstobeprotectedcanbecarriedbyanenemyorstowedina
trappedchest.

FinalWords
Thedevilisinthedetails,astheysay,andalthoughthisarticleisalreadyquitelengthyitcan
onlyscratchthesurfaceofalltheclevernessthatItriedtopourintoDungeonRun. The
generatorisahugeandcomplexthingthatIbuiltoverthepastcoupleofweeks,butreallywas
yearsinthemaking(seefigure8).AlthoughItrytoapproachcontentgenerationinastructured
manner,thecollectionoftechniquesIusedisnosilverbulletthatiseasilyadaptedtoother
projects.However,Idohopethatthequalityofthelevelsgeneratedbythegamedoshowthe
fruitfulnessoftheapproachItook,andthatthiswritinghelpsyouunderstandthefundamental
ideasbehinditsdesign.


Figure8:AllthestepstogenerateadungeonlevelasshowninLudoscopewhile
generatinganewlevel.

Anda mungkin juga menyukai