20
PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES Simon Cooper [email protected]

PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

  • Upload
    ircoops

  • View
    1.156

  • Download
    0

Embed Size (px)

DESCRIPTION

AISB2010 presentation slides

Citation preview

Page 1: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

PROCEDURAL CONTENTGENERATION AND LEVEL DESIGN FOR COMPUTER GAMESSimon Cooper [email protected]

Page 2: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

INTRODUCTION

Onteca Research Project

• Create a 3D Tile Based Map Level Editor.

but...

• With minimum input needed from level designers.

Page 3: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

GOALS• Create a system that can procedurally

generate content for a game level.

• Use either random constraints or those set by a user.

• Distribute on a variety of platforms including modern web browsers and multiple operating systems.

• Level should then be exportable to a generic file format which could be loaded in at a later time - even in another game engine or programming language.

Page 4: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

INITIAL IDEAS

• Procedurally create assets programmatically.

• Creatively reuse a small number of predefined assets.

• Avoid obvious pattern repetition.

• Create a simple UI to control some constraints.

Page 5: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES
Page 6: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

RELATED WORK• CityEngine - inspired by modelling of natural

phenomena in string grammars and L-systems.

• Procedural buildings - Shape Grammars used to describe structures.

• Other approaches include the application of intelligent agents, real-time frustum filling and template based generation.

• Some authors propose to simulate the evolution of cities by modelling land use and evolving a city usage map over time that can be used later to create a cityscape.

• Real-time city generation has also been attempted.

Page 7: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

NOVELTIES• Solution development allowing deployment

across many platforms including web browsers, multiple OS and the Google Android platform.

• Instant in-game generation, rendering and recreation of 3D tile based and organic environments.

• Agent AI Bots to terraform the environment after the generation stage and according to other user-set constraints, and structural constraints induced by the game world.

• Full control of the environment generation by the user as well as semi-random generation options.

Page 8: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

IterationsTHE FUNCTIONS USED FOR LEVEL GENERATION

• Terrain Generator

• Water Generator

• Tree Scattering

• Building Architecture Creator

• Building Texture Painter

• Road & Buildings Layout Rational Agent

“For each possible percept sequence a rational agent should select an action that is expected to maximise it’s performance measure, given the evidence provided by the percept sequence and whatever built-in knowledge the agent has.”

• GUI & User Constraints

Page 9: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

TERRAIN• Midpoint displacement fractals are used

to generate our terrain

• Four corners given random values between 0-1.

• Subdivide into 4 squares.

• Give midpoints on each edge a value by averaging the two adjacent colours.

• Now give the centre point a colour value using the average of the 4 new midpoints .

• Add a random offset to the centre point (this offset can be determined by the grid size and a roughness variable).

• Repeat until all pixels have a colour.

Page 10: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

WATERSEA

The sea level depends on the range of terrain heights and a water level variable between 0 and 5 (none – flooded).

SHOREThe edge detection between sea and land creating the shore line/shallows – four way check for land tile next to each sea square.

RIVERSNeed to be routed around the map in a natural way using A* Pathfinding and two main heuristics:

• Rivers will flow into a larger body of water (in our case the sea or in-land pools created by creators in our terrain) or off the screen if there are none present.

• Rivers will flow downhill due to gravity usually taking the easiest path.

Page 11: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

TREES• If the trees and plants are scattered using ‘n’

randomly generated [x, z] positions within our grid the results can look “neither random nor natural”.

• Can be arranged in a grid with an equal distance between them before a small random offset is applied to scatter them (small enough to stop two trees overlapping).

• For tile based maps a variation of the land fractal can also be used.

• More variation can be added later by randomly rotating and scaling the trees (including their exclusion zones), as some trees will be more fully-grown than others.

Page 12: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

BUILDINGSShape grammars

• In architecture building structures have many repeating shapes and patterns that can be described using a rule.

• Shape grammars are used to provide a computational approach to the generation of designs:• Shapes – the structures building blocks. • Spatial Relations – how these shapes are

positioned relative to one another. • Rules – to describe how and where new

shapes are added. • Rule Labels – give a set orientation marker to

the rule. • Transformations – translation, rotation and

scale of the shapes. • Derivation – repeat the rule for n steps to

create multiple designs.

Page 13: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

BUILDINGSProcedural Textures

• The texture is created procedurally using image graphics and saved as a texture state.

• Equally divide up the texture for number of windows and their size.

• Set a base colour for the window that is dark (unlit), white or orange (lit).

• Distribute lit windows randomly for residential buildings.

• Distribute lit windows in blocks for office buildings as companies usually occupy a whole floor.

• Create light to dark gradient to add depth.

• Add colour noise to add detail.

• Finally add black lines to block out window shape/style.

Page 14: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

ROADS• Once the land is created it can be populated

with an urban city structure.• The first main step is to divide up the level

into lots (smaller areas that can be used to place building, etc) by forming a road network.

• We can scatter points around the map then connect them using pathfinding to create the roads along suitable routes.

• A popular algorithm for this is A*, which can run in real time on a reasonable sized map.

• As our roads are generated in an editor a slight delay is not as big an issue as it would be in other cases such as an enemy AI in a shooter game.

Page 15: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

GUISliders to control terrain height & roughness, water level and tree density

Choose map tile textures

Randomise all settings

Rebuild all level

Toggle generation animation

Page 16: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES
Page 17: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES
Page 18: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES
Page 19: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES

DUNGEON TILE EDITOR• Other work has been done on a level editor for a tile based dungeon map• Users can easily draw a floor plan by adding/removing tiles with the mouse• Walls are added automatically• Doors can be added by clicking on walls that separate two rooms• Floor pattern can be changed for each room

Page 20: PROCEDURAL CONTENT GENERATION AND LEVEL DESIGN FOR COMPUTER GAMES