Adaptive AI Engine for RTS Games

Discussing the theory and practice

Scripting Systems

Posted by Ogail on July 23, 2009

Scripting Systems


  • Previous techniques are coded with programmers; so when a gamer what to add new thing how?
  • Scripting: using simplified programming language to build AI elements, logic or behavior
  • Scripting Languages could be:
    • Very Simple (predicate language): contains general rules with a keyword and value
    • Full-Fledged: i.e. Neverwinter Nights uses Java in its scripting language
  • Game designers/end users use the scripting system
  • Design issues in creating scripting systems:
    • The kinds of functionality that the language will require
      • Example in shooter game:
        • Simple script: define how enemies where will spawned and their parameters
        • More complex: define how enemies move
        • More complex: create new enemies
          • Scripter can define:
            • Set of attributes: body type, speed, duration, armor level etc…
            • Se of behaviors: attack method, movement style and pattern etc…
      • System could be implemented that it has several values and the game side determine which values to use in response to the current player state
    • Will the runtime engine interpret the scripts, or will they precompiled into some kind of bytecode
      • Interpreted scripts
        • tend to be slower and large
        • flexible where you can enter new script from an in-game console
        • Simpler to implement
      • CPU power will be an important issue in determining the choice here
    • How big the scripts be in size?
      • Take care of the computer memory assigned to to
      • Also if the scripts are to be used within the game take care of memory bandwidth you are dealing with
    • How will be using scripting language?
  • Scripting System Components:
    • Parser: to load the scripted files under certain tokens
    • Tokens:
      • Token name
      • Execute(): which parser invoke it when it finds token
        • Executing involves scanning the file for any additional parameters that the token expects and then sending game message via this data
    • In-Game Callbacks:
      • Functions that will respond to the messages sent by token Execuet()
      • Here that’s the place where you actually bind real game variables to incoming script data
    • Script files
  • Implementation Notes (Simple scripting language):
    • To initialize the system you should register parser with all tokens
    • Considered problems:
      • Capital/small letters
      • Substring problem (Shout and out)


  • Performance of the AI with this system:
    • The loading at the startup will somehow be delayed because the loading operation
  • Additions:
    • Comments
    • Paramerarized tokens
    • Block signifier (recursive tokens)
  • Lua PL Advantages:
    • Fast, has smaller memory footprint and easier to learn
    • Procedural syntax with dynamic types
    • It can be interpreted from script or compiled bytecode
    • Have automatic memory management
    • Has easy to use APIs
  • Some language basic features:
    • Very simple scoping
    • Dynamic Typing
    • Tables
    • Control Structures
    • The Stack
  • Lua Language Fundamentals
  • Pros of Scripting Systems:
    • Rapid Prototyping:
      • Main concepts will be held in scripts so advanced logic could be added easily
    • Increased Accessibility:
      • Many game designers and end users could alter logic easily
    • Speed of Tuning:
    • Provides means of user extensibility:
      • Providing end users with tools used in creating the scripts add extensibility
    • Scales Well:
      • As the number of things under control of the scripting system increases, the real power of scripting makes itself known
  • Cons of Scripting Systems:
    • Speed of Execution:
      • Any interpreted system is going to be slower than programs that have been compiled into native code
      • Problems of bytecode that it’s unreadable but it’s faster
      • You can develop functions that require speed in the compiled language while using script to develop the parts of the game that aren’t as performance sensitive
    • Debugging Can be Difficult:
      • Custom scripting languages don’t have level of debugging tools
        • Dedicated debuggers, profiles, asserts, internal error checking, syntax checking
        • Non-technical people who write scripts tend to lack some “common sense debugging techniques” this techniques could include binary bug hunting
    • Looking Scripted:
      • When players play the game much your scripts behaviors are discovered!
    • The Question of How Much Power:
      • Answer of this question lies in the type of the game you are working on, level of functionality you need in your scripts to perform the things you need, and the level of organization and control you want of the content in your game
    • You are now maintaining Two Systems!
    • Too much functionality in the scripting system can be a problem as well
  • Extensions to this method:
    • Completely Custom Languages:
      • Creating scripted custom system using “Lex & Yacc” route
        • Create grammar file using Lex then process this file under Yacc and generates the necessary C code to parse file using the specified grammar
    • Built-In Debugging Tool:
    • Smart IDE for Writing Scripts
    • Automatic Integration With The Game
      • Ways to implement this:
        • Recognize that some change happened and then rebuild all the project to consider changes
        • Adding request system so, ay anytime when new Widget is requested it’s added to a special list that the programmer can access and find out what scripter require for new functionality and then programmer implement it as well
    • Self-Modifying Scripts:
      • Scripts could keep track of behaviors that work and doesn’t work
      • The system could append additional rules onto its scripts (or remove them) as the consequence of some event during the game
      • Genetic Algorithms:
        • which strive to use genetically derived methods to perfect algorithms for finding solutions to problems
      • Genetic Programming:
        • Deals with using genetic methods to actually write whole programs to solve problems
      • Here the system is searching for the ideal script in which to perform its job instead of the ideal parameters to use within script
  • Optimizations:
    • Performance of scripting system relies on:
      • Level of its use within the game
      • Functionality of scripting language
      • How structured your overall system is
  • Design Considerations:
    • Types of Solutions: its preferred to be used by strategic level and could work with tactical level also
    • Agent Reactivity: give you vast area of reactivity
    • System Realism:
      • Webb designed scripted systems have the ability to perform realistic, unique behavior

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: