cs498gd:scrolling_sound_ai
Table of Contents
Scrolling, Sound, AI
Scrolling Games
- Example: Super Mario Brothers
- Game that travels left or right well beyond the length of the game panel
- Graphics requirement: tile maps (a.k.a., “bricklaying”)
- Backgrounds are often composed of several tile map layers
- Scrolling Demo:
- The following example illustrates a wrap-around “ribbon” background.
- ScrollDemo.java (main program)
Sound Basics
- Two types of sound used in games
- Sampled audio data - Series of digital values that represent the amplitude or intensity of sound pressure waves
- Most often used for game feedback (i.e. audio effects)
- Support for encoded/compressed audio (e.g. mp3) is also used in games.
- Synthesized audio data
- Example: MIDI (Musical Instrument Digital Interface) - A standard electronics communications protocol
- used in a many video games (in almost all NES games)
- Most often used for game atmosphere (i.e. background music)
Playing a Sound in Java
Java Sound API
- Allows access to (and manipulation of) audio data and the underlying machine's audio hardware and software
- The packages: (SoundPlayback.java)
- javax.sound.sampled.*
- Handles digital audio data
- Supports WAV, AU, and AIFF formats, and can be extended to support more formats such as mp3
- Going beyond simple sound playback:
- Port - I/O to microphone, speaker, etc.
- Mixer - Audio device with multiple I/O lines
- DataLine - Adds functionality to a line, including start, stop, and pause audio.
- GainControl - Used to manipulate an audio signal's volume
- PanControl - Used to control the balance between the left and right stereo channels
- Example: Simple sound recording application with playback
Game AI
- What is AI?
- The study of computational systems that “exhibit intelligence”
- Capabilities: problem solving, planning, and learning
- “AI” in Games (note the double quotes)
- Opponents (e.g., how can they outsmart you?)
- Computer teammates
- Support characters and autonomous characters (NPCs - non-player characters)
- Commentators (sports games)
- Camera control
- Plot control (story branching)
- Some goals of AI in games:
- Provide challenging opponents…
- …but not too challenging or too predictable
- Gather enough knowledge…
- …but aim for low CPU and memory usage
- Provide an illusion of reality (e.g., human characteristics)
- Experiences with game AI? Game-generated opponents that you thought were well done?
- Effects of Bad AI
- Reduced fun
- Extreme behaviors (from lame to superhuman)
- Unrealistic behaviors
- Mindless hordes (of opponents)
- Cheating
- Sample Problems for a game AI
- What to do when the enemy is heard or sensed?
- What to do when AI-controlled character health level is low?
- What to do if AI-controlled character doesn't see or hear anything? (idle time)
- How to move from point A to the goal in a maze?
- How to move a flock of objects (e.g., birds)?
- Building a game AI agent
- Given: the environment
- Cycle (one iteration of the game loop):
- Sense - Gather information about the environment
- Think - Use some decision-making routine
- Act - Execute something based on the decision
- Repeat steps
- Some constraints:
- Memory: What to remember and for how long?
- CPU usage
Finite State Machines (FSM)
- Glossary:
- FSM - A collection of states and transitions that outline a path of actions that may occur.
- State - A state is a position in time.
- For example, when you are at the bus stop, you are currently in a waiting state.
- Event - An event is something that happens in time.
- For example, the bus has arrived.
- Action - A task performed given a certain event that occurred.
- For example, you enter the bus.
- Transition - A link between 2 states.
- May be unidirectional or bidirectional.
- Possibly the simplest type of game AI decision-making engine
- Looks like the state diagrams in game design documents
- Strengths:
- Simple, quick
- Can be compacted into a simple data structure such as an array
- Finite State Machine Example: Quake II
- 9 different states for AI-controlled enemies
- Standing
- Walking
- Running
- Dodging
- Attaching
- Melee
- See the enemy
- Idle
- Searching
References
cs498gd/scrolling_sound_ai.txt · Last modified: 2011/11/11 14:18 by jchung