26
General Intelligence through playing games? Julian Togelius New York University julian.togelius.com @togelius

General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

General Intelligence through playing games?

Julian Togelius New York Universityjulian.togelius.com

@togelius

Page 2: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can
Page 3: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Are we generally intelligent?

• No

• Programmed for decades for doing some small range of tasks, using curricula developed for centuries by society

• We “could” solve any task, but it takes ages for society to reprogram us to do it

• Turing-completeness is irrelevant

Page 4: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

General intelligenceAccording to Legg and Hutter: universal intelligence is the sum of the performance of an agent on all possible problems, weighted by their simplicity

3.3 A formal definition of machine intelligence 23

of short programs, that in general it is impossible for long random strings to have shortprograms. In other words, they have high Kolmogorov complexity.

An important property of K is that it is nearly independent of the choice of U . To seewhy, consider what happens if we switch from U , in the above definition of K, to someother universal Turing machine U ′. Due to the universality property of U ′, there exists aprogram q that allows U ′ to simulate U . Thus, if we give U ′ both q and p as inputs, it cansimulate U running p and thereby compute U(p). It follows then that switching from U toU ′ in our definition of K above incurs at most an additional cost of l(q) bits in minimalprogram length. The constant l(q) is independent of which string x we are measuringthe complexity of, and for reasonable universal Turing machines, this constant will besmall. This invariance property makes K an excellent universal complexity measure. Foran extensive treatment of Kolmogorov complexity see [LV97] or [Cal02].

In our current application we need to measure the complexity of the computablemeasures that describe environments. It can be shown that this set can be enumeratedµ1, µ2, µ3, . . . (see Theorem 4.3.1 in [LV97]). Using a simple encoding method we canexpress each index as a binary string, written ⟨i⟩. In a sense this binary string is adescription of an environment with respect to our enumeration. This lets us define thecomplexity of an environment µi to be K(µi) := K(⟨i⟩). Intuitively, if a short programcan be used to describe the program for an environment µi, then this environment willhave a low complexity.

This answers our problem of needing to be able to measure the complexity of envi-ronments, but we are not done yet. In order to formalise Occam’s razor we need to havea way to assign an a priori probability to environments in such a way that complex en-vironments are less likely, and simple environments more likely. If we consider that eachenvironment µi is described by a minimal length program that is a binary string, then thenatural way to do this is to consider each additional bit of program length to reduce theenvironment’s probability by one half, reflecting the fact that each bit has two possiblestates. This gives us what is known as the algorithmic probability distribution over thespace of environments, defined 2−K(µ). This distribution has powerful properties that es-sentially solve long-standing open philosophical, statistical, and computational problemsin the area of inductive inference [Hut07a]. Furthermore, the distribution can be used todefine powerful universal learning agents that have provably optimal performance [Hut05].

Bringing all these pieces together, we can now define our formal measure of intelligencefor arbitrary systems. Let E be the space of all computable reward summable environ-mental measures with respect to the reference machine U , and let K be the Kolmogorovcomplexity function. The expected performance of agent π with respect to the universaldistribution 2−K(µ) over the space of all environments E is given by,

Υ(π) :=!

µ∈E

2−K(µ) V πµ .

We call this the universal intelligence of agent π.Consider how this equation corresponds to our informal definition. We needed a mea-

sure of an agent’s general ability to achieve goals in a wide range of environments. Clearlypresent in the equation is the agent π, the environment µ and, implicit in the environment,a goal. The agent’s “ability to achieve” is represented by the value function V π

µ . By a“wide range of environments” we have taken the space of all well defined reward summableenvironments, where these environments have been characterised as computable measures

Page 5: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

What kind of general intelligence?

• Human-like? (Which human?)

• Human-relevant?

• Abstract and incomprehensible?

• How dependent is the definition of general AI on the description language of tasks/problems?

Page 6: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Games as AI benchmarks• Old and obvious idea

• Faster, cheaper and technically easier than robots

• Games are made to challenge human thinking

• “Fun” comes largely from our ability to learn the game as we play

• Well-designed games should therefore be relevant test for AI

Page 7: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Me, 2006: Train general

AI in video games

REMOVE

Page 8: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Game-based AI benchmarks

• FAIR Torchcraft

• Minecraft/Malmö

• DeepMind Labs

• OpenAI Universe

• General Game Playing

• Arcade learning environment

• Simulated Car Racing

• Mario AI

• StarCraft

• Unreal 2k4/BotPrize

Page 9: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Problem: overfitting

Another interesting feature is that different sets of be-haviours and different levels of coordination between thosebehaviours are necessary in order to play levels of differ-ent difficulty, and complete these with different degrees ofsuccess. In other words, there is a smooth learning curvebetween levels, both in terms of which behaviours are nec-essary and their necessary degree of refinement. For example,to complete a very simple Mario level (with no enemies andonly small and few holes and obstacles) it might be enough tokeep walking right and jumping whenever there is something(hole or obstacle) immediately in front of Mario. A controllerthat does this should be easy to learn. To complete the samelevel while collecting as many as possible of the coins presenton the same level likely demands some planning skills, suchas smashing a power-up block to retrieve a mushroom thatmakes Mario Big so that he can retrieve the coins hiddenbehind a brick block, and jumping up on a platform to collectthe coins there and then going back to collect the coinshidden under it. More advanced levels, including most ofthose in the original Super Mario Bros game, require a variedbehaviour repertoire just to complete. These levels mightinclude concentrations of enemies of different kinds whichcan only be passed by observing their behaviour pattern andtiming Mario’s passage precisely; arrangements of holes andplatforms that require complicated sequences of jumps topass; dead ends that require backtracking; and so on. How tocomplete Super Mario Bros in minimal time while collectingthe highest score is still the subject of intense competitionamong human players3.

III. HOW?

Much of the work that went into this paper consisted intransforming the Infinite Mario Bros game into a piece ofbenchmarking software that can be interfaced with reinforce-ment learning algorithms. This included removing the real-time element of the game so that it can be “stepped” forwardby the learning algorithm, removing the dependency ongraphical output, and substantial refactoring (as the developerof the game did not anticipate that the game would be turnedinto an RL benchmark). Each time step, which corresponds to40 milliseconds of simulated time (an update frequency of 25

fps), the controller receives a description of the environment,and outputs an action. The resulting software is a single-threaded Java application that can easily be run on any majorhardware architecture and operating system, with the keymethods that a controller needs to implement specified ina single Java interface file (see figures 2 and 3). On aniMac from 2007, 5�20 full levels can be played per second(several thousand times faster than real-time) depending onthe level type and controller architecture. A TCP interfacefor controllers is also provided, along with an examplePython client. However, using TCP introduces a significantconnection overhead, limiting the speed to about one gameper minute (three times real-time speed).

3Search for “super mario speedrun” on YouTube to gauge the interest inthis subject.

public enum AGENT_TYPE{AI, HUMAN, TCP_SERVER}

public void reset();public boolean[] getAction

(Environment observation);public AGENT_TYPE getType();public String getName();public void setName(String name);

Fig. 2. The Agent Java interface, which must be implemented by allcontrollers. Called by the game each time step.

// always the same dimensionality 22x22// always centered on the agentpublic byte[][] getCompleteObservation();public byte[][] getEnemiesObservation();public byte[][] getLevelSceneObservation();public float[] getMarioFloatPos();public float[] getEnemiesFloatPos();public boolean isMarioOnGround();public boolean mayMarioJump();

Fig. 3. The Environment Java interface, which contains the observation,i.e the information the controller can use to decide which action to take.

We devised a number of variations on a simple neural-network based controller architecture, varying in whetherwe allowed internal state in the network or not, and howmany of the “blocks” around Mario were used as inputs.The controllers had the following inputs; the value for eachinput can be either 0 (on) or 1 (off).

• A bias input, with the constant value of 1.• One input indicating whether Mario is currently on the

ground.• One input indicating whether Mario can currently jump.• A number of input indicating the presence of environ-

mental obstacles around Mario.• A number of input indicating the presence of enemies

Fig. 4. Visualization of the environment and enemy sensors. Using thesmallest number of sensors, the top six environment sensors would output0 and the lower three input 1. All of the enemy sensors would output 0, aseven if all 49 enemy sensors were consulted none of them would reach allthe way to the body of the turtle, which is four blocks below Mario. Noneof the sensors register the coins.

Page 10: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Solution: many, unseen games

Another interesting feature is that different sets of be-haviours and different levels of coordination between thosebehaviours are necessary in order to play levels of differ-ent difficulty, and complete these with different degrees ofsuccess. In other words, there is a smooth learning curvebetween levels, both in terms of which behaviours are nec-essary and their necessary degree of refinement. For example,to complete a very simple Mario level (with no enemies andonly small and few holes and obstacles) it might be enough tokeep walking right and jumping whenever there is something(hole or obstacle) immediately in front of Mario. A controllerthat does this should be easy to learn. To complete the samelevel while collecting as many as possible of the coins presenton the same level likely demands some planning skills, suchas smashing a power-up block to retrieve a mushroom thatmakes Mario Big so that he can retrieve the coins hiddenbehind a brick block, and jumping up on a platform to collectthe coins there and then going back to collect the coinshidden under it. More advanced levels, including most ofthose in the original Super Mario Bros game, require a variedbehaviour repertoire just to complete. These levels mightinclude concentrations of enemies of different kinds whichcan only be passed by observing their behaviour pattern andtiming Mario’s passage precisely; arrangements of holes andplatforms that require complicated sequences of jumps topass; dead ends that require backtracking; and so on. How tocomplete Super Mario Bros in minimal time while collectingthe highest score is still the subject of intense competitionamong human players3.

III. HOW?

Much of the work that went into this paper consisted intransforming the Infinite Mario Bros game into a piece ofbenchmarking software that can be interfaced with reinforce-ment learning algorithms. This included removing the real-time element of the game so that it can be “stepped” forwardby the learning algorithm, removing the dependency ongraphical output, and substantial refactoring (as the developerof the game did not anticipate that the game would be turnedinto an RL benchmark). Each time step, which corresponds to40 milliseconds of simulated time (an update frequency of 25

fps), the controller receives a description of the environment,and outputs an action. The resulting software is a single-threaded Java application that can easily be run on any majorhardware architecture and operating system, with the keymethods that a controller needs to implement specified ina single Java interface file (see figures 2 and 3). On aniMac from 2007, 5�20 full levels can be played per second(several thousand times faster than real-time) depending onthe level type and controller architecture. A TCP interfacefor controllers is also provided, along with an examplePython client. However, using TCP introduces a significantconnection overhead, limiting the speed to about one gameper minute (three times real-time speed).

3Search for “super mario speedrun” on YouTube to gauge the interest inthis subject.

public enum AGENT_TYPE{AI, HUMAN, TCP_SERVER}

public void reset();public boolean[] getAction

(Environment observation);public AGENT_TYPE getType();public String getName();public void setName(String name);

Fig. 2. The Agent Java interface, which must be implemented by allcontrollers. Called by the game each time step.

// always the same dimensionality 22x22// always centered on the agentpublic byte[][] getCompleteObservation();public byte[][] getEnemiesObservation();public byte[][] getLevelSceneObservation();public float[] getMarioFloatPos();public float[] getEnemiesFloatPos();public boolean isMarioOnGround();public boolean mayMarioJump();

Fig. 3. The Environment Java interface, which contains the observation,i.e the information the controller can use to decide which action to take.

We devised a number of variations on a simple neural-network based controller architecture, varying in whetherwe allowed internal state in the network or not, and howmany of the “blocks” around Mario were used as inputs.The controllers had the following inputs; the value for eachinput can be either 0 (on) or 1 (off).

• A bias input, with the constant value of 1.• One input indicating whether Mario is currently on the

ground.• One input indicating whether Mario can currently jump.• A number of input indicating the presence of environ-

mental obstacles around Mario.• A number of input indicating the presence of enemies

Fig. 4. Visualization of the environment and enemy sensors. Using thesmallest number of sensors, the top six environment sensors would output0 and the lower three input 1. All of the enemy sensors would output 0, aseven if all 49 enemy sensors were consulted none of them would reach allthe way to the body of the turtle, which is four blocks below Mario. Noneof the sensors register the coins.

Page 11: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

General Video Game AI• Video game-based AI testing framework with

currently about 100 games

• Most of them modeled on 70s and 80s games

• Agents are submitted to a server, and tested on unseen games

• Agents are written in a description language

• Easy to write for humans, possible to generate!

Page 12: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Zelda: Human

Page 13: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Zelda: Random

Page 14: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Zelda: OLETS

Page 15: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

VideoGame

Description Language

Page 16: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

MOAR GAMES

Page 17: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

GVGAI is better because…

• Can be used with or without forward models

• No pixel parsing necessary

• Games are unknown

• Infinite game supply (potentially generatable)

different

Page 18: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

What works in GVGAI?• Tree search

• MCTS and friends

• Iterative width / novelty pruning

• Evolutionary action selection

• Hyper-heuristics / algorithm selection

Page 19: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can
Page 20: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Planning vs learning• If you have a forward model, why not use it?

• Enables use of heuristic search / planning

• Most physical world problems do not have forward models, but they could (easily?) be learned!

• Most computer-based problems allow (easy?) extraction of a forward model

• GVGAI planning track: forward model, no learning time

• GVGAI learning track: no forward model, learning time

Page 21: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Pixels versus object data

• If you have nicely processed data, why not use it?

• For most computer-based problems, we have such data

• For most physical world problems, we could learn a model that parses the pixels

Page 22: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

General Intelligence through GVGAI?

• Incremental/gradual learning: start on simple levels of a single game, go on to harder

• Start on simple games, go on to harder ones

• Learning to learn: given many games that need to be learned, this seems to be an advantage

Page 23: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

What kind of intelligence do you get from only playing games?

• Capacity for linguistic interaction?

• Bodily awareness?

• Empathy?

• …

Page 24: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Games are also this

Page 25: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Still wanna play?• Sure

• Games are less bad than other AI environments, and we need environments

• We need unseen games and generation though

• By gradually increasing the types of games we test on, we include more “intelligences”

• The only way to figure out what general intelligence is is to build it

Page 26: General Intelligence through playing games? · define powerful universal learning agents that have provabl yoptimalperformance[Hut05]. Bringing all these pieces together, we can

Further reading• Tom Schaul, Julian Togelius and Jürgen Schmidhuber

(2011): Measuring Intelligence Through Games. arXiv:1109.1314

• Julian Togelius (2016): AI Researchers, Games Are Your Friends! Computational Intelligence, Springer.

• Diego Perez, Spyridon Samothrakis, Julian Togelius, Tom Schaul, Simon Lucas, Adrien Couetoux, Jerry Lee, Chong-U Lim and Tommy Thompson (2015): The 2014 General Game Playing Competition. IEEE TCIAIG.

• www.gvgai.net