You are on page 1of 53

AI for Games 3rd Edition Ian Millington

Visit to download the full and correct content document:


https://textbookfull.com/product/ai-for-games-3rd-edition-ian-millington/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

AI for Games 3e Millington

https://textbookfull.com/product/ai-for-games-3e-millington/

Unity 2017 Game AI Programming Leverage the power of


Artificial Intelligence to program smart entities for
your games Raymundo Barrera

https://textbookfull.com/product/unity-2017-game-ai-programming-
leverage-the-power-of-artificial-intelligence-to-program-smart-
entities-for-your-games-raymundo-barrera/

A Guide to Japanese Role Playing Games 3rd edition


Bitmap Books

https://textbookfull.com/product/a-guide-to-japanese-role-
playing-games-3rd-edition-bitmap-books/

Designing games for children developmental usability


and design considerations for making games for kids
Fisher

https://textbookfull.com/product/designing-games-for-children-
developmental-usability-and-design-considerations-for-making-
games-for-kids-fisher/
Game play therapeutic use of games with children and
adolescents 3rd Ed 3rd Edition Jessica Stone

https://textbookfull.com/product/game-play-therapeutic-use-of-
games-with-children-and-adolescents-3rd-ed-3rd-edition-jessica-
stone/

High Score! Expanded: The Illustrated History of


Electronic Games 3rd Edition Demaria

https://textbookfull.com/product/high-score-expanded-the-
illustrated-history-of-electronic-games-3rd-edition-demaria/

AI for the Good Stefan Vieweg

https://textbookfull.com/product/ai-for-the-good-stefan-vieweg/

Vaccines for Veterinarians 1st Edition Ian R. Tizard

https://textbookfull.com/product/vaccines-for-veterinarians-1st-
edition-ian-r-tizard/

Succeeding with AI: How to Make AI Work for Your


Business Veljko Krunic

https://textbookfull.com/product/succeeding-with-ai-how-to-make-
ai-work-for-your-business-veljko-krunic/
AI for
Games
THIRD EDITION
AI for
Games
THIRD EDITION

Ian Millington
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742

© 2019 by Taylor & Francis Group, LLC


CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper


Version Date: 20190221

International Standard Book Number-13: 978-1-138-48397-2 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish
reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the
consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in
this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright
material has not been acknowledged please write and let us know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any
form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and
recording, or in any information storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.
copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400.
CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been
granted a photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identifica-
tion and explanation without intent to infringe.

Library of Congress Cataloging-in-Publication Data

Names: Millington, Ian, author.


Title: AI for games / Ian Millington.
Other titles: AI for games
Description: Third edition. | Boca Raton : Taylor & Francis, a CRC title,
part of the Taylor & Francis imprint, a member of the Taylor & Francis
Group, the academic division of T&F Informa, plc, [2019] | Includes
bibliographical references.
Identifiers: LCCN 2018041305 | ISBN 9781138483972 (hardback : acid-free paper)
Subjects: LCSH: Computer games--Programming. | Computer animation. |
Artificial intelligence.
Classification: LCC QA76.76.C672 M549 2019 | DDC 794.8/1525--dc23
LC record available at https://lccn.loc.gov/2018041305

Visit the Taylor & Francis Web site at


http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
for Daniel
my favorite game designer
CONTENTS

PART I
AI and Games 1

CHAPTER INTRODUCTION 3
1 1.1 What Is AI? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 Academic AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 Game AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2 Model of Game AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.2.1 Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2.2 Decision Making . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2.3 Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.4 Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.5 Agent-Based AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.2.6 In the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3 Algorithms and Data Structures . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2 Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.4 Layout of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

CHAPTER GAME AI 21
2 2.1 The Complexity Fallacy . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1.1 When Simple Things Look Good . . . . . . . . . . . . . . . . . . . . 21
2.1.2 When Complex Things Look Bad . . . . . . . . . . . . . . . . . . . . 22
2.1.3 The Perception Window . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.4 Changes of Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2 The Kind of AI in Games . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.1 Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.2 Heuristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2.3 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

vii
viii CONTENTS

2.3 Speed and Memory Constraints . . . . . . . . . . . . . . . . . . . . . . 28


2.3.1 Processor Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3.2 Memory Concerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.3.3 Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.4 The AI Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4.1 Structure of an AI Engine . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4.2 Tool Concerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.4.3 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . 37

PART II
Techniques 39

CHAPTER MOVEMENT 41
3 3.1 The Basics of Movement Algorithms . . . . . . . . . . . . . . . . . . . 42
3.1.1 Two-Dimensional Movement . . . . . . . . . . . . . . . . . . . . . . 43
3.1.2 Statics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.1.3 Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2 Kinematic Movement Algorithms . . . . . . . . . . . . . . . . . . . . . 51
3.2.1 Seek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.2.2 Wandering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.3 Steering Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.3.1 Steering Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.3.2 Variable Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.3.3 Seek and Flee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.3.4 Arrive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.3.5 Align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.3.6 Velocity Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.3.7 Delegated Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.3.8 Pursue and Evade . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.3.9 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.3.10 Looking Where You’re Going . . . . . . . . . . . . . . . . . . . . . . 72
3.3.11 Wander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.3.12 Path Following . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.3.13 Separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.3.14 Collision Avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.3.15 Obstacle and Wall Avoidance . . . . . . . . . . . . . . . . . . . . . . 90
3.3.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
CONTENTS ix

3.4 Combining Steering Behaviors . . . . . . . . . . . . . . . . . . . . . . 95


3.4.1 Blending and Arbitration . . . . . . . . . . . . . . . . . . . . . . . . 96
3.4.2 Weighted Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
3.4.3 Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.4.4 Cooperative Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.4.5 Steering Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.5 Predicting Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.5.1 Aiming and Shooting . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3.5.2 Projectile Trajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
3.5.3 The Firing Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.5.4 Projectiles with Drag . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
3.5.5 Iterative Targeting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
3.6 Jumping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3.6.1 Jump Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3.6.2 Landing Pads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
3.6.3 Hole Fillers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
3.7 Coordinated Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3.7.1 Fixed Formations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
3.7.2 Scalable Formations . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
3.7.3 Emergent Formations . . . . . . . . . . . . . . . . . . . . . . . . . . 146
3.7.4 Two-Level Formation Steering . . . . . . . . . . . . . . . . . . . . . 147
3.7.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
3.7.6 Extending to More Than Two Levels . . . . . . . . . . . . . . . . . . 156
3.7.7 Slot Roles and Better Assignment . . . . . . . . . . . . . . . . . . . . 158
3.7.8 Slot Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.7.9 Dynamic Slots and Plays . . . . . . . . . . . . . . . . . . . . . . . . . 164
3.7.10 Tactical Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
3.8 Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.8.1 Output Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.8.2 Capability-Sensitive Steering . . . . . . . . . . . . . . . . . . . . . . 173
3.8.3 Common Actuation Properties . . . . . . . . . . . . . . . . . . . . . 174
3.9 Movement in the Third Dimension . . . . . . . . . . . . . . . . . . . . 177
3.9.1 Rotation in Three Dimensions . . . . . . . . . . . . . . . . . . . . . . 178
3.9.2 Converting Steering Behaviors to Three Dimensions . . . . . . . . . . 179
3.9.3 Align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
3.9.4 Align to Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
3.9.5 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
3.9.6 Look Where You’re Going . . . . . . . . . . . . . . . . . . . . . . . . 185
3.9.7 Wander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
3.9.8 Faking Rotation Axes . . . . . . . . . . . . . . . . . . . . . . . . . . 187
x CONTENTS

CHAPTER PATHFINDING 195


4 4.1 The Pathfinding Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
4.1.1 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
4.1.2 Weighted Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
4.1.3 Directed Weighted Graphs . . . . . . . . . . . . . . . . . . . . . . . 200
4.1.4 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
4.1.5 Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
4.2 Dijkstra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
4.2.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
4.2.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
4.2.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
4.2.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 211
4.2.5 Performance of Dijkstra . . . . . . . . . . . . . . . . . . . . . . . . . 213
4.2.6 Weaknesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
4.3 A* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
4.3.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
4.3.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
4.3.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
4.3.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 222
4.3.5 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 227
4.3.6 Algorithm Performance . . . . . . . . . . . . . . . . . . . . . . . . . 227
4.3.7 Node Array A* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
4.3.8 Choosing a Heuristic . . . . . . . . . . . . . . . . . . . . . . . . . . 230
4.4 World Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
4.4.1 Tile Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
4.4.2 Dirichlet Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
4.4.3 Points of Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
4.4.4 Navigation Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
4.4.5 Non-Translational Problems . . . . . . . . . . . . . . . . . . . . . . . 252
4.4.6 Cost Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
4.4.7 Path Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
4.5 Improving on A* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
4.6 Hierarchical Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . 257
4.6.1 The Hierarchical Pathfinding Graph . . . . . . . . . . . . . . . . . . 258
4.6.2 Pathfinding on the Hierarchical Graph . . . . . . . . . . . . . . . . . 261
4.6.3 Hierarchical Pathfinding on Exclusions . . . . . . . . . . . . . . . . . 264
4.6.4 Strange Effects of Hierarchies on Pathfinding . . . . . . . . . . . . . . 265
4.6.5 Instanced Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
4.7 Other Ideas in Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . 274
4.7.1 Open Goal Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . 274
CONTENTS xi

4.7.2 Dynamic Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . 274


4.7.3 Other Kinds of Information Reuse . . . . . . . . . . . . . . . . . . . 275
4.7.4 Low Memory Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 275
4.7.5 Interruptible Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . 277
4.7.6 Pooling Planners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
4.8 Continuous Time Pathfinding . . . . . . . . . . . . . . . . . . . . . . . 278
4.8.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
4.8.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
4.8.3 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 284
4.8.4 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
4.8.5 Weaknesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
4.9 Movement Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
4.9.1 Animations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
4.9.2 Movement Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
4.9.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
4.9.4 Footfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

CHAPTER DECISION MAKING 297


5 5.1 Overview of Decision Making . . . . . . . . . . . . . . . . . . . . . . . 298
5.2 Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
5.2.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
5.2.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
5.2.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
5.2.4 Knowledge Representation . . . . . . . . . . . . . . . . . . . . . . . 307
5.2.5 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 308
5.2.6 Performance of Decision Trees . . . . . . . . . . . . . . . . . . . . . 308
5.2.7 Balancing the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
5.2.8 Beyond the Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
5.2.9 Random Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . 311
5.3 State Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
5.3.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
5.3.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
5.3.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
5.3.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 317
5.3.5 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
5.3.6 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 320
5.3.7 Hard-Coded FSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
5.3.8 Hierarchical State Machines . . . . . . . . . . . . . . . . . . . . . . . 323
5.3.9 Combining Decision Trees and State Machines . . . . . . . . . . . . . 335
xii CONTENTS

5.4 Behavior Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338


5.4.1 Implementing Behavior Trees . . . . . . . . . . . . . . . . . . . . . . 345
5.4.2 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
5.4.3 Decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
5.4.4 Concurrency and Timing . . . . . . . . . . . . . . . . . . . . . . . . 355
5.4.5 Adding Data to Behavior Trees . . . . . . . . . . . . . . . . . . . . . 364
5.4.6 Reusing Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
5.4.7 Limitations of Behavior Trees . . . . . . . . . . . . . . . . . . . . . . 373
5.5 Fuzzy Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
5.5.1 A Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
5.5.2 Introduction to Fuzzy Logic . . . . . . . . . . . . . . . . . . . . . . . 375
5.5.3 Fuzzy Logic Decision Making . . . . . . . . . . . . . . . . . . . . . . 385
5.5.4 Fuzzy State Machines . . . . . . . . . . . . . . . . . . . . . . . . . . 394
5.6 Markov Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
5.6.1 Markov Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
5.6.2 Markov State Machine . . . . . . . . . . . . . . . . . . . . . . . . . . 402
5.7 Goal-Oriented Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . 405
5.7.1 Goal-Oriented Behavior . . . . . . . . . . . . . . . . . . . . . . . . . 406
5.7.2 Simple Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
5.7.3 Overall Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
5.7.4 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
5.7.5 Overall Utility GOAP . . . . . . . . . . . . . . . . . . . . . . . . . . 416
5.7.6 GOAP with IDA* . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
5.7.7 Smelly GOB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
5.8 Rule-Based Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
5.8.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
5.8.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
5.8.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
5.8.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 438
5.8.5 Rule Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
5.8.6 Unification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
5.8.7 Rete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
5.8.8 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
5.8.9 Where Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
5.9 Blackboard Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . 461
5.9.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
5.9.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
5.9.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
5.9.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 464
5.9.5 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
5.9.6 Other Things Are Blackboard Systems . . . . . . . . . . . . . . . . . 467
CONTENTS xiii

5.10 Action Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469


5.10.1 Types of Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
5.10.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
5.10.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
5.10.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 476
5.10.5 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 478
5.10.6 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
5.10.7 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . 479

CHAPTER TACTICAL AND STRATEGIC AI 485


6 6.1 Waypoint Tactics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
6.1.1 Tactical Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
6.1.2 Using Tactical Locations . . . . . . . . . . . . . . . . . . . . . . . . . 496
6.1.3 Generating the Tactical Properties of a Waypoint . . . . . . . . . . . . 500
6.1.4 Automatically Generating the Waypoints . . . . . . . . . . . . . . . . 506
6.1.5 The Condensation Algorithm . . . . . . . . . . . . . . . . . . . . . . 507
6.2 Tactical Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
6.2.1 Representing the Game Level . . . . . . . . . . . . . . . . . . . . . . 512
6.2.2 Simple Influence Maps . . . . . . . . . . . . . . . . . . . . . . . . . . 512
6.2.3 Terrain Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
6.2.4 Learning with Tactical Analyses . . . . . . . . . . . . . . . . . . . . . 521
6.2.5 A Structure for Tactical Analyses . . . . . . . . . . . . . . . . . . . . 523
6.2.6 Map Flooding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
6.2.7 Convolution Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
6.2.8 Cellular Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
6.3 Tactical Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
6.3.1 The Cost Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
6.3.2 Tactic Weights and Concern Blending . . . . . . . . . . . . . . . . . 549
6.3.3 Modifying the Pathfinding Heuristic . . . . . . . . . . . . . . . . . . 551
6.3.4 Tactical Graphs for Pathfinding . . . . . . . . . . . . . . . . . . . . . 552
6.3.5 Using Tactical Waypoints . . . . . . . . . . . . . . . . . . . . . . . . 553
6.4 Coordinated Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
6.4.1 Multi-Tier AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
6.4.2 Emergent Cooperation . . . . . . . . . . . . . . . . . . . . . . . . . 561
6.4.3 Scripting Group Actions . . . . . . . . . . . . . . . . . . . . . . . . . 564
6.4.4 Military Tactics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568

CHAPTER LEARNING 575


7 7.1 Learning Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
7.1.1 Online or Offline Learning . . . . . . . . . . . . . . . . . . . . . . . 576
xiv CONTENTS

7.1.2 Intra-Behavior Learning . . . . . . . . . . . . . . . . . . . . . . . . . 577


7.1.3 Inter-Behavior Learning . . . . . . . . . . . . . . . . . . . . . . . . . 577
7.1.4 A Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
7.1.5 Over-Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
7.1.6 The Zoo of Learning Algorithms . . . . . . . . . . . . . . . . . . . . 579
7.1.7 The Balance of Effort . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
7.2 Parameter Modification . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
7.2.1 The Parameter Landscape . . . . . . . . . . . . . . . . . . . . . . . . 580
7.2.2 Hill Climbing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
7.2.3 Extensions to Basic Hill Climbing . . . . . . . . . . . . . . . . . . . . 584
7.2.4 Annealing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
7.3 Action Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
7.3.1 Left or Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
7.3.2 Raw Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
7.3.3 String Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
7.3.4 N-Grams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
7.3.5 Window Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
7.3.6 Hierarchical N-Grams . . . . . . . . . . . . . . . . . . . . . . . . . . 599
7.3.7 Application in Combat . . . . . . . . . . . . . . . . . . . . . . . . . 602
7.4 Decision Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
7.4.1 The Structure of Decision Learning . . . . . . . . . . . . . . . . . . . 602
7.4.2 What Should You Learn? . . . . . . . . . . . . . . . . . . . . . . . . 603
7.4.3 Four Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
7.5 Naive Bayes Classifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
7.5.1 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
7.5.2 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 609
7.6 Decision Tree Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
7.6.1 ID3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
7.6.2 ID3 with Continuous Attributes . . . . . . . . . . . . . . . . . . . . . 618
7.6.3 Incremental Decision Tree Learning . . . . . . . . . . . . . . . . . . 622
7.7 Reinforcement Learning . . . . . . . . . . . . . . . . . . . . . . . . . . 627
7.7.1 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
7.7.2 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
7.7.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
7.7.4 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 632
7.7.5 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 633
7.7.6 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
7.7.7 Tailoring Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
7.7.8 Weaknesses and Realistic Applications . . . . . . . . . . . . . . . . . 637
7.7.9 Other Ideas in Reinforcement Learning . . . . . . . . . . . . . . . . . 640
CONTENTS xv

7.8 Artificial Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . 642


7.8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
7.8.2 The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
7.8.3 The Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
7.8.4 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
7.8.5 Data Structures and Interfaces . . . . . . . . . . . . . . . . . . . . . . 653
7.8.6 Implementation Caveats . . . . . . . . . . . . . . . . . . . . . . . . . 655
7.8.7 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
7.8.8 Other Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
7.9 Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660
7.9.1 What is Deep Learning? . . . . . . . . . . . . . . . . . . . . . . . . . 660
7.9.2 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661

CHAPTER PROCEDURAL CONTENT GENERATION 669


8 8.1 Pseudorandom Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 670
8.1.1 Numeric Mixing and Game Seeds . . . . . . . . . . . . . . . . . . . . 671
8.1.2 Halton Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
8.1.3 Phyllotaxic Angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
8.1.4 Poisson Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
8.2 Lindenmayer Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
8.2.1 Simple L-systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
8.2.2 Adding Randomness to L-systems . . . . . . . . . . . . . . . . . . . 684
8.2.3 Stage-Specific Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
8.3 Landscape Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
8.3.1 Modifiers and Height-Maps . . . . . . . . . . . . . . . . . . . . . . . 688
8.3.2 Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
8.3.3 Perlin Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
8.3.4 Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
8.3.5 Thermal Erosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
8.3.6 Hydraulic Erosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
8.3.7 Altitude Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
8.4 Dungeons and Maze Generation . . . . . . . . . . . . . . . . . . . . . 705
8.4.1 Mazes by Depth First Backtracking . . . . . . . . . . . . . . . . . . . 705
8.4.2 Minimum Spanning Tree Algorithms . . . . . . . . . . . . . . . . . . 716
8.4.3 Recursive Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . 721
8.4.4 Generate and Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
8.5 Shape Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
8.5.1 Running the Grammar . . . . . . . . . . . . . . . . . . . . . . . . . 730
8.5.2 Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
xvi CONTENTS

CHAPTER BOARD GAMES 741


9 9.1 Game Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
9.1.1 Types of Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
9.1.2 The Game Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
9.2 Minimaxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
9.2.1 The Static Evaluation Function . . . . . . . . . . . . . . . . . . . . . 747
9.2.2 Minimaxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
9.2.3 The Minimaxing Algorithm . . . . . . . . . . . . . . . . . . . . . . . 750
9.2.4 Negamaxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753
9.2.5 AB Pruning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755
9.2.6 The AB Search Window . . . . . . . . . . . . . . . . . . . . . . . . . 759
9.2.7 Negascout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761
9.3 Transposition Tables and Memory . . . . . . . . . . . . . . . . . . . . 764
9.3.1 Hashing Game States . . . . . . . . . . . . . . . . . . . . . . . . . . 764
9.3.2 What to Store in the Table . . . . . . . . . . . . . . . . . . . . . . . . 767
9.3.3 Hash Table Implementation . . . . . . . . . . . . . . . . . . . . . . . 768
9.3.4 Replacement Strategies . . . . . . . . . . . . . . . . . . . . . . . . . 769
9.3.5 A Complete Transposition Table . . . . . . . . . . . . . . . . . . . . 770
9.3.6 Transposition Table Issues . . . . . . . . . . . . . . . . . . . . . . . . 771
9.3.7 Using Opponent’s Thinking Time . . . . . . . . . . . . . . . . . . . . 771
9.4 Memory-Enhanced Test Algorithms . . . . . . . . . . . . . . . . . . . 772
9.4.1 Implementing Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772
9.4.2 The MTD Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 774
9.4.3 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775
9.5 Monte Carlo Tree Search (MCTS) . . . . . . . . . . . . . . . . . . . . . 776
9.5.1 Pure Monte Carlo Tree Search . . . . . . . . . . . . . . . . . . . . . . 776
9.5.2 Adding Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . 782
9.6 Opening Books and Other Set Plays . . . . . . . . . . . . . . . . . . . 783
9.6.1 Implementing an Opening Book . . . . . . . . . . . . . . . . . . . . 783
9.6.2 Learning for Opening Books . . . . . . . . . . . . . . . . . . . . . . 784
9.6.3 Set Play Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
9.7 Further Optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
9.7.1 Iterative Deepening . . . . . . . . . . . . . . . . . . . . . . . . . . . 786
9.7.2 Variable Depth Approaches . . . . . . . . . . . . . . . . . . . . . . . 787
9.8 Game Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788
9.8.1 Creating a Static Evaluation Function . . . . . . . . . . . . . . . . . . 791
9.8.2 Learning the Static Evaluation Function . . . . . . . . . . . . . . . . 794
9.9 Turn-Based Strategy Games . . . . . . . . . . . . . . . . . . . . . . . . 797
9.9.1 Impossible Tree Size . . . . . . . . . . . . . . . . . . . . . . . . . . . 798
9.9.2 Real-Time AI in a Turn-Based Game . . . . . . . . . . . . . . . . . . 799
CONTENTS xvii

PART III
Supporting Technologies 801

CHAPTER EXECUTION MANAGEMENT 803


10 10.1 Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804
10.1.1 The Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804
10.1.2 Interruptible Processes . . . . . . . . . . . . . . . . . . . . . . . . . 811
10.1.3 Load-Balancing Scheduler . . . . . . . . . . . . . . . . . . . . . . . . 814
10.1.4 Hierarchical Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . 816
10.1.5 Priority Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
10.2 Anytime Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820
10.3 Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821
10.3.1 Graphics Level of Detail . . . . . . . . . . . . . . . . . . . . . . . . . 821
10.3.2 AI LOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 822
10.3.3 Scheduling LOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823
10.3.4 Behavioral LOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824
10.3.5 Group LOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829
10.3.6 In Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833

CHAPTER WORLD INTERFACING 835


11 11.1 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
11.1.1 Polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
11.1.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
11.1.3 Determining Which Approach to Use . . . . . . . . . . . . . . . . . . 838
11.2 Event Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838
11.2.1 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 841
11.2.2 Event Casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
11.2.3 Inter-Agent Communication . . . . . . . . . . . . . . . . . . . . . . 846
11.3 Polling Stations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 846
11.3.1 Pseudo-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847
11.3.2 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848
11.3.3 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 848
11.3.4 Abstract Polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848
11.4 Sense Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
11.4.1 Faking It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
11.4.2 What Do We Know? . . . . . . . . . . . . . . . . . . . . . . . . . . . 851
11.4.3 Sensory Modalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
11.4.4 Region Sense Manager . . . . . . . . . . . . . . . . . . . . . . . . . . 857
11.4.5 Finite Element Model Sense Manager . . . . . . . . . . . . . . . . . . 865
xviii CONTENTS

CHAPTER TOOLS AND CONTENT CREATION 875


12 12.0.1 Toolchains Limit AI . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
12.0.2 Where AI Knowledge Comes From . . . . . . . . . . . . . . . . . . . 876
12.1 Knowledge for Pathfinding and Waypoints . . . . . . . . . . . . . . . 877
12.1.1 Manually Creating Region Data . . . . . . . . . . . . . . . . . . . . . 877
12.1.2 Automatic Graph Creation . . . . . . . . . . . . . . . . . . . . . . . 880
12.1.3 Geometric Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
12.1.4 Data Mining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
12.2 Knowledge for Movement . . . . . . . . . . . . . . . . . . . . . . . . . 886
12.2.1 Obstacles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886
12.2.2 High-Level Staging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888
12.3 Knowledge for Decision Making . . . . . . . . . . . . . . . . . . . . . 889
12.3.1 Object Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
12.3.2 Concrete Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
12.4 The Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 890
12.4.1 Integrated Game Engines . . . . . . . . . . . . . . . . . . . . . . . . 890
12.4.2 Custom Data-Driven Editors . . . . . . . . . . . . . . . . . . . . . . 893
12.4.3 AI Design Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 894
12.4.4 Remote Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
12.4.5 Plug-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896

CHAPTER PROGRAMMING GAME AI 901


13 13.1 Implementation Language . . . . . . . . . . . . . . . . . . . . . . . . . 902
13.1.1 C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903
13.1.2 C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904
13.1.3 Swift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 905
13.1.4 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
13.1.5 JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 908
13.2 Scripted AI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909
13.2.1 What Is Scripted AI? . . . . . . . . . . . . . . . . . . . . . . . . . . . 910
13.2.2 What Makes a Good Scripting Language? . . . . . . . . . . . . . . . 911
13.2.3 Embedding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913
13.2.4 Choosing an Open Source Language . . . . . . . . . . . . . . . . . . 913
13.2.5 A Language Selection . . . . . . . . . . . . . . . . . . . . . . . . . . 914
13.3 Creating a Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 919
13.3.1 Rolling Your Own . . . . . . . . . . . . . . . . . . . . . . . . . . . . 921
CONTENTS xix

PART IV
Designing Game AI 927

CHAPTER DESIGNING GAME AI 929


14 14.1 The Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929
14.1.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
14.1.2 Evaluating the Behaviors . . . . . . . . . . . . . . . . . . . . . . . . 931
14.1.3 Selecting Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . 934
14.1.4 The Scope of One Game . . . . . . . . . . . . . . . . . . . . . . . . . 936
14.2 Shooters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937
14.2.1 Movement and Firing . . . . . . . . . . . . . . . . . . . . . . . . . . 937
14.2.2 Decision Making . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
14.2.3 Perception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940
14.2.4 Pathfinding and Tactical AI . . . . . . . . . . . . . . . . . . . . . . . 941
14.2.5 Shooter-Like Games . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
14.2.6 Melee Combat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943
14.3 Driving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 946
14.3.1 Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 946
14.3.2 Pathfinding and Tactical AI . . . . . . . . . . . . . . . . . . . . . . . 949
14.3.3 Driving-Like Games . . . . . . . . . . . . . . . . . . . . . . . . . . . 950
14.4 Real-Time Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 950
14.4.1 Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 950
14.4.2 Group Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 951
14.4.3 Tactical and Strategic AI . . . . . . . . . . . . . . . . . . . . . . . . . 952
14.4.4 Decision Making . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 953
14.4.5 MOBAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954
14.5 Sports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955
14.5.1 Physics Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956
14.5.2 Playbooks and Content Creation . . . . . . . . . . . . . . . . . . . . 956
14.6 Turn-Based Strategy Games . . . . . . . . . . . . . . . . . . . . . . . . 956
14.6.1 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 957
14.6.2 Helping the Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958

CHAPTER AI-BASED GAME GENRES 959


15 15.1 Teaching Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960
15.1.1 Representing Actions . . . . . . . . . . . . . . . . . . . . . . . . . . 960
15.1.2 Representing the World . . . . . . . . . . . . . . . . . . . . . . . . . 961
15.1.3 Learning Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . 961
15.1.4 Predictable Mental Models . . . . . . . . . . . . . . . . . . . . . . . 963
xx CONTENTS

15.2 Flocking and Herding Games . . . . . . . . . . . . . . . . . . . . . . . 965


15.2.1 Making the Creatures . . . . . . . . . . . . . . . . . . . . . . . . . . 965
15.2.2 Tuning Steering for Interactivity . . . . . . . . . . . . . . . . . . . . 965
15.2.3 Steering Behavior Stability . . . . . . . . . . . . . . . . . . . . . . . . 967
15.2.4 Ecosystem Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 967

REFERENCES 971
Books, Periodicals, Papers and Websites . . . . . . . . . . . . . . . . . . . . 971
Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 976

INDEX 983
PART I

AI and Games
1
INTRODUCTION

ame development lives in its own technical world. It has its own idioms, skills, and
G challenges. That’s one of the reasons games are so much fun to work on. Each game
has its own rules, its own aesthetic, its own trade-offs, and the hardware it will run on keeps
changing. There’s a reasonably good chance you will be the first person to meet and beat a
new programming challenge.
Despite numerous efforts to standardize game development, in line with the rest of the
software industry (efforts that go back at least 25 years), the style of programming in a game
is still rather unique. There is a focus on speed, but it differs from real-time programming
for embedded or control applications. There is a focus on clever algorithms, but it doesn’t
share the same rigor as database server engineering. It draws techniques from a huge range
of different sources, but almost without exception modifies them beyond resemblance. And,
to add an extra layer of intrigue, developers make their modifications in different ways, often
under extreme time pressure, and tailored entirely to the game at hand, leaving algorithms
unrecognizable from studio to studio or project to project.
As exciting and challenging as this may be, it makes it difficult for new developers to
get the information they need. Twenty years ago, it was almost impossible to get hold of
information about techniques and algorithms that real developers used in their games. There
was an atmosphere of secrecy, even alchemy, about the coding techniques in top studios. Then
came the Internet and an ever-growing range of websites, along with books, conferences, and
periodicals. It is now easier than ever to teach yourself new techniques in game development.
This book is designed to help you master one element of game development: artificial
intelligence (AI). There have been many articles published about different aspects of game AI:
websites on particular techniques, compilations in book form, some introductory texts, and

3
4 Chapter 1 Introduction

plenty of lectures at development conferences. But this book was designed to cover it all, as a
coherent whole.
In my career I have developed many AI modules for lots of different genres of games. I
developed AI middleware tools that have a lot of new research and clever content. I have
worked on research and development for next-generation AI, and I get to do a lot with some
very clever technologies. However, throughout this book I tried to resist the temptation to
pass off how I think it should be done as how it is done. My aim has been to tell it like it is (or
for those technologies I mention that are still emerging, to tell you how most people agree it
will be).
The meat of this book covers a wide range of techniques for game AI. Some of them are
barely techniques, more like a general approach or development style. Some are full-blown
algorithms, ready to implement in a reusable way. And others are shallow introductions to
huge fields that would fill multiple books on their own. In these cases, I’ve tried to give enough
of an overview for you to understand how and why an approach may be useful (or not).
This book is intended for a wide range of readers: from hobbyists or students looking
to get a solid understanding of game AI through to professionals who need a comprehensive
reference to techniques they may not have used before. I will assume you can program (though
I will not assume any particular language—see Chapter 13 for a discussion of implementation
languages), and I will assume you have high-school level mathematical knowledge.
Before we get into the techniques themselves, this chapter introduces AI, its history, and
the way it is used. We’ll look at a model of AI to help fit the techniques together, and I’ll give
some background on how the rest of the book is structured.

1.1 WHAT IS AI?


Artificial intelligence is about making computers able to perform the thinking tasks that hu-
mans and animals are capable of.
We can program computers to have superhuman abilities in solving many problems:
arithmetic, sorting, searching, and so on. Some of these problems were originally consid-
ered AI problems, but as they have been solved in more and more comprehensive ways, they
have slipped out of the domain of AI developers.
But there are many things that computers aren’t good at which we find trivial: recognizing
familiar faces, speaking our own language, deciding what to do next, and being creative. These
are the domain of AI: trying to work out what kinds of algorithms are needed to display these
properties.
Often the dividing line between AI and not-AI is merely difficulty: things we can’t do
require AI, things we can are tricks and math. It is tempting to get into a discussion of what
is ‘real’ AI, to try defining ‘intelligence’, ‘consciousness’ or ‘thought’. In my experience, it is an
impossible task, largely irrelevant to the business of making games.
In academia, some AI researchers are motivated by those philosophical questions: under-
standing the nature of thought and the nature of intelligence and building software to model
1.1 What Is AI? 5

how thinking might work. Others are motivated by psychology: understanding the mechan-
ics of the human brain and mental processes. And yet others are motivated by engineering:
building algorithms to perform human-like tasks. This threefold distinction is at the heart of
academic AI, and the different concerns are responsible for different subfields of the subject.
As games developers, we are practical folks; interested in only the engineering side. We
build algorithms that make game characters appear human or animal-like. Developers have
always drawn from academic research, where that research helps them get the job done, and
ignored the rest.
It is worth taking a quick overview of the AI work done in academia to get a sense of what
exists in the subject and what might be worth plagiarizing.

1.1.1 ACADEMIC AI

To tell the story, I will divide academic AI into three periods: the early days, the symbolic era,
and the natural computing and statistical era. This is a gross oversimplification, of course,
and they all overlap to some extent, but I find it a useful distinction. For a collection of papers
which give a much more nuanced and fleshed out account, see [38].

The Early Days


The early days include the time before computers, where philosophy of mind occasionally
made forays into AI with such questions as: “What produces thought?” “Could you give
life to an inanimate object?” “What is the difference between a cadaver and the human it
previously was?” Tangential to this was the popular taste in automata, mechanical robots,
from the 18th century onward. Intricate clockwork models were created that displayed the
kind of animated, animal- or human-like behaviors that we now employ game artists to create
in a modeling package (for an academic history and discussion, see [23], and for an in-depth
look at two piano playing examples, see [74]).
In the war effort of the 1940s, the need to break enemy codes [8] and to perform the cal-
culations required for atomic warfare motivated the development of the first programmable
computers [46]. Given that these machines were being used to perform calculations that
would otherwise be done by a person, it was natural for programmers to be interested in AI.
Several computing pioneers (such as Turing, von Neumann, and Shannon) were also pioneers
in early AI. Turing, in particular, has become an adopted father to the field, as a result of a
philosophical paper he published in 1950 [70].

The Symbolic Era


From the late 1950s through to the early 1980s the main thrust of AI research was “symbolic”
systems. A symbolic system is one in which the algorithm is divided into two components:
6 Chapter 1 Introduction

a set of knowledge (represented as symbols such as words, numbers, sentences, or pictures)


and a reasoning algorithm that manipulates those symbols to create new combinations that
hopefully represent problem solutions or new knowledge.
An expert system, one of the purest expressions of this approach, is among the most fa-
mous AI techniques. If today all the AI headlines talk about “deep learning,” in the 1980s,
they name dropped “expert systems.” An expert system has a large database of knowledge
and it applies a collection of rules to draw conclusions or to discover new things (see Sec-
tion 5.8). Other symbolic approaches applicable to games include blackboard architectures
(5.9), pathfinding (Chapter 4), decision trees (Section 5.2) and state machines (Section 5.3).
These and many more are described in this book.
A common feature of symbolic systems is a trade-off: when solving a problem the more
knowledge you have, the less work you need to do in reasoning. Often, reasoning algorithms
consist of searching: trying different possibilities to get the best result. This leads us to the
golden rule of AI, that we will see in various forms throughout this book:
Search and knowledge are intrinsically linked. The more knowledge you have,
the less searching for an answer you need; the more search you can do (i.e., the
faster you can search), the less knowledge you need.
It was suggested by researchers Newell and Simon in 1976 that knowledge infused search
(known as ‘heuristic search’) is the way all intelligent behavior arises [45]. Unfortunately,
despite its having several solid and important features, this theory has been largely discredited
as an account of all intelligence. Nevertheless, many people with a recent education in AI are
not aware that, as an engineering trade-off, knowledge versus search is unavoidable. Recent
work on the mathematics of problem solving has proved this theoretically [76]. At a practical
level, AI engineers have always known it.

The Natural Computing / Statistical Era


Through the 1980s and into the early 1990s, there was an increasing frustration with symbolic
approaches. The frustration came from various directions.
From an engineering point of view, the early successes on simple problems didn’t seem to
scale to more difficult problems. For example: it seemed easy to develop AI that understood
(or appeared to understand) simple sentences, but developing an understanding of a full hu-
man language seemed no nearer. This was compounded by hype: when AI touted as ‘the next
big thing’ failed to live up to its billing, confidence in the whole sector crashed.
There was also an influential philosophical argument that symbolic approaches weren’t
biologically plausible. You can’t understand how a human being plans a route by using a
symbolic route-planning algorithm any more than you can understand how human muscles
work by studying a forklift truck.
The effect was a move toward natural computing: techniques inspired by biology or other
natural systems. These techniques include neural networks, genetic algorithms, and simulated
1.1 What Is AI? 7

annealing.1 Many natural computing techniques have been around for a long time. Neural
networks, for example, predate the symbolic era; they were first suggested in 1943 [39].
But in the 1980s through to the early 2000s they received the bulk of the research effort.
When I began my PhD in artificial intelligence in the 90s, it was difficult to find research places
in Expert Systems, for example. I studied genetic algorithms; most of my peers were working
on neural networks.
Despite its origin as a correlate to biology, AI research heavily applied mathematics, par-
ticularly probability and statistics, to understanding and optimizing natural computing tech-
niques. The ability to handle all the uncertainty and messiness of real-world data, in contrast
to the clean and rigid boundaries of the symbolic approaches, led to the development of a wide
range of other probabilistic techniques, such as Bayes nets, support-vector machines (SVMs),
and Gaussian processes.
The biggest change in AI in the last decade has not come from a breakthrough in academia.
We are living in a time when AI is again back in the newspapers: self driving cars, deep fakes,
world champion Go programs, and home virtual assistants. This is the era of deep learning.
Though many academic innovations are used, these systems are still fundamentally powered
by neural networks, now made practical by the increase in computing power.

Engineering
Though newspaper headlines and high-profile applications have flourished in the last five
years, AI has been a key technology relevant to solving real-world problems for decades. Nav-
igation systems in cars, job scheduling in factories, voice recognition and dictation, and large-
scale search are all more than 20 years old. Google’s search technology, for example, has long
been underpinned by AI. It is no coincidence that Peter Norvig is both a Director of Research
at Google and the co-author (along with his former graduate adviser, professor Stuart Russell)
of the canonical undergraduate textbook for modern academic AI [54].
When something is hot, it is tempting to assume it is the only thing that matters. When
natural computing techniques took center stage, there was a tendency to assume that symbolic
approaches were dead. Similarly, with talk of deep learning everywhere, you might be forgiven
for thinking that is what should be used.
But we always come back to the same trade-off: search vs knowledge. Deep learning is the
ultimate in the compute intensive search, AlphaGo Zero (the third iteration of the AlphaGo
software, [60]) was given very minimal knowledge of the rules of the game, but extraordinary
amounts of processing time to try different strategies and learn the best. On the other hand,
a character that needs to use a health pack when injured can be told that explicitly:
IF injured THEN use health pack

1. Though old, a good introduction to Genetic Algorithms can be found in [41], and Simulated Annealing in [34]. In
their current vogue as Deep Learning, there are many more contemporary resources on neural networks. For a gentle
and shallow introduction, see [21], for a more comprehensive guide, [18].
8 Chapter 1 Introduction

No search required.
The only way any algorithm can outperform another is either to consume more processing
power (more search), or to be optimized toward a specific set of problems (more knowledge
of the problem).
In practice, engineers work from both sides. A voice recognition program, for example,
converts the input signals using known formulae into a format where the neural network can
decode it. The results are then fed through a series of symbolic algorithms that look at words
from a dictionary and the way words are combined in the language. A statistical algorithm
optimizing the order of a production line will have the rules about production encoded into
its structure, so it can’t possibly suggest an illegal timetable: the knowledge is used to reduce
the amount of search required.
Unfortunately, games are usually designed to run on consumer hardware. And while AI is
important, graphics have always taken the majority of the processing power. This seems in no
danger of changing. For AI designed to run on the device during the game, low computation
/ high knowledge approaches are often the clear winners. And these are very often symbolic:
approaches pioneered in academia in the 70s and 80s.
We’ll look at several statistical computing techniques in this book, useful for specific prob-
lems. But I have enough experience to know that for games they are often unnecessary: the
same effect can often be achieved better, faster, and with more control using a simpler ap-
proach. This hasn’t changed significantly since the first edition of this book in 2004. Over-
whelmingly the AI used in games is still symbolic technology.

1.1.2 GAME AI

Pac-Man [140] was the first game many people remember playing with fledgling AI. Up to that
point there had been Pong clones with opponent-controlled bats (following the ball up and
down) and countless shooters in the Space Invaders mold. But Pac-Man had definite enemy
characters that seemed to conspire against you, moved around the level just as you did, and
made life tough.
Pac-Man relied on a very simple AI technique: a state machine (which I’ll cover later in
Chapter 5). Each of the four monsters (later called ghosts after a disastrously flickering port
to the Atari 2600) occupied one of three states: chasing, scattering (heading for the corners at
specific time intervals), and frightened (when Pac-Man eats a power up). For each state they
choose a tile as their target, and turn toward it at each junction. In chase mode, each ghost
chooses the target according to a slightly different hard-coded rule, giving them their person-
alities. A complete breakdown of the Pac-Man game mechanics, including the AI algorithms,
can be found at [49].
Game AI didn’t change much until the mid-1990s. Most computer-controlled characters
prior to then were about as sophisticated as a Pac-Man ghost.
Take a classic like Golden Axe [176] eight years later. Enemy characters stood still (or
walked back and forward a short distance) until the player got close to them, whereupon they
Another random document with
no related content on Scribd:
Hart, Republican 385,514
McGrann, Democrat 340,269
Irish, Prohibitionist 18,471
Kennedy, Greenback 8,900

Total 753,154

An important feature of the year was the interest shown in the


question of prohibiting the manufacture and sale of intoxicating
liquors. Four States have voted on this issue, Michigan leading off in
April, Texas voting in August, Tennessee in September, and Oregon
in November. Prohibition was defeated in each instance, but its
advocates succeeded in polling a surprisingly large vote. The poll in
these States was as follows:

For Pro. Against Pro.


Michigan 178,488 184,429
Texas 129,273 221,627
Tennessee 117,504 145,197
Oregon 19,973 27,958

Totals 445,238 579,211


Majority against prohibition 133,973

To this should be added the defeat of prohibition in Atlanta and


Fulton counties, Ga., by 1122 majority, where it had won two years
before by 228 majority. The interest shown in local option and high
license as a solution of the temperance question, and its popularity
wherever adopted, is also a marked feature of the year’s politics. In
Michigan local option succeeded the failure of prohibition, while in
Pennsylvania the people are promised a choice between high license
and prohibition.
The elections of 1887 as a whole, without removing doubts as to
the future, were generally accepted as favorable to the Republicans.
The following is a fair comparison with Rhode Island omitted, for the
plain reason that her spring result was reversed in the fall:
1883. 1887.
Rep. Dem. Rep. Dem.
Mass 160,092 150,228 136,000 118,394
New York 429,757 445,976 452,435 469,886
New Jersey 97,047 103,856 107,026 104,407
Penna 319,106 302,031 385,514 340,269
Maryland 80,707 92,694 86,644 98,936
Ohio 347,164 359,793 356,937 333,205
Kentucky 89,181 133,615 126,476 143,270
Iowa 164,182 139,093 168,696 152,886
Nebraska 56,381 41,998 86,725 56,548
Virginia 144,419 124,080 119,380 119,806
Totals 1,888,036 1,893,364 2,025,833 1,937,607

Democratic majority in 1883 5,328


Republican majority in 1887 88,226
Gain in the Dem. vote in four years 44,243
Gain in the Rep. vote in four years 137,797

The vote in Rhode Island would probably reduce the Republican


gain of the year about 5000. But as the figures for Virginia are
disputed and not the official vote, which it is known would add
several thousand to the Republican total, the above result can be
taken as a just estimate of the gain made by the Republicans in these
eleven states, where general elections were held. It would be at least
25,000 larger if the vote of the highest candidate, instead of the head
of the ticket, were taken.
OPENING OF THE CAMPAIGN OF 1888.

The fiftieth Congress convened in December, 1887, the Senate


consisting of 38 Republicans, 37 Democrats, and 1 Readjuster, Mr.
Riddleberger, of Virginia. In the House there were 168 Democrats,
153 Republicans, and 4 Independents—Anderson, of Iowa and
Hopkins, of Virginia, classed with the Democrats, and Smith of
Wisconsin and Nichols of North Carolina, classed with the
Republicans upon tariff and educational subjects—two questions
which in the form of Revenue measures and of the Blair educational
bill, gave early promise of becoming the issues for the campaign of
1888.
Upon the assembling of the fiftieth Congress President Cleveland,
instead of sending the usual message describing the condition of the
Nation and its relations with foreign nations, together with such
recommendations as he desired to make, sent simply a message upon
questions of revenue, and in this way gave the subject such emphasis
as to make his views the issue in the campaign to follow. The
message excited wide and varied political comment, and when Mr.
Blaine, who at the time was in Paris, permitted an answer to be wired
to the New York Tribune, the two opposing views seemed to meet the
wishes of the two great opposing parties, and they were at once
accepted as defining the tendencies of each party, at least, upon tariff
and revenue subjects.
As these two papers will prove the text for much of the discussion
incident to the campaign of 1888, we give below their text:
President Cleveland’s Message.

To the Congress of the United States:


You are confronted at the threshold of your legislative duties with
a condition of the national finances which imperatively demands
immediate and careful consideration.
The amount of money annually exacted, through the operation of
the present laws, from the industries and necessities of the people,
largely exceeds the sum necessary to meet the expenses of the
government.
When we consider that the theory of our institutions guarantees to
every citizen the full enjoyment of all the fruits of his industry and
enterprise, with only such deduction as may be his share towards the
careful and economical maintenance of the government which
protects him, it is plain that the exaction of more than this is
indefensible extortion, and a culpable betrayal of American fairness
and justice. This wrong inflicted upon those who bear the burden of
national taxation, like other wrongs, multiplies a brood of evil
consequences. The public treasury, which should only exist as a
conduit conveying the people’s tribute to its legitimate objects of
expenditure, becomes a hoarding-place for money needlessly
withdrawn from trade and the people’s use, thus crippling our
national energies, suspending our country’s development, preventing
investment in productive enterprise, threatening financial
disturbance, and inviting schemes of public plunder.
This condition of our treasury is not altogether new; and it has
more than once of late been submitted to the people’s
representatives in the Congress, who alone can apply a remedy. And
yet the situation still continues, with aggravated incidents, more than
ever presaging financial convulsion and widespread disaster.
It will not do to neglect this situation because its dangers are not
now palpably imminent and apparent. They exist none the less
certainly, and await the unforeseen and unexpected occasion when
suddenly they will be precipitated upon us.
On the 30th day of June, 1885, the excess of revenues over public
expenditures after complying with the annual requirement of the
sinking fund act, was $17,859,735.84; during the year ended June
30, 1886, such excess amounted to $49,405,545.20; and during the
year ended June 30, 1887, it reached the sum of $55,567,849.54.
The annual contributions to the sinking fund during the three
years above specified, amounting in the aggregate to
$138,058,320.94, and deducted from the surplus as stated, were
made by calling in for that purpose outstanding three per cent. bonds
of the government. During the six months prior to June 30, 1887, the
surplus revenue had grown so large by repeated accumulations, and
it was feared the withdrawal of this great sum of money needed by
the people would so affect the business of the country that the sum of
$79,864,100 of such surplus was applied to the payment of the
principal and interest of the three per cent. bonds still outstanding,
and which were then payable at the option of the government. The
precarious condition of financial affairs among the people still
needing relief, immediately after the 30th day of June, 1887, the
remainder of the three per cent. bonds then outstanding, amounting
with principal and interest to the sum of $18,877,500, were called in
and applied to the sinking fund contribution for the current fiscal
year. Notwithstanding these operations of the Treasury Department,
representations of distress in business circles not only continued but
increased, and absolute peril seemed at hand. In these circumstances
the contribution to the sinking fund for the current fiscal year was at
once completed by the expenditure of $27,684,283.55 in the
purchase of government bonds not yet due bearing four and four and
a half per cent. interest, the premium paid thereon averaging about
twenty-four per cent. for the former and eight per cent. for the latter.
In addition to this, the interest accruing during the current year upon
the outstanding bonded indebtedness of the government was to
some extent anticipated, and banks selected as depositories of public
money were permitted to somewhat increase their deposits.
While the expedients thus employed, to release to the people the
money lying idle in the Treasury, served to avert immediate danger,
our surplus revenues have continued to accumulate, the excess for
the present year amounting on the 1st day of December to
$55,258,701.19, and estimated to reach the sum of $113,000,000 on
the 30th of June next, at which date it is expected that this sum,
added to prior accumulations, will swell the surplus in the Treasury
to $140,000,000.
There seems to be no assurance that, with such a withdrawal from
use of the people’s circulating medium, our business community may
not in the near future be subjected to the same distress which was
quite lately produced from the same cause. And while the functions
of our National Treasury should be few and simple, and while its best
condition would be reached, I believe, by its entire disconnection
with private business interests, yet when, by a perversion of its
purposes, it idly holds money uselessly subtracted from the channels
of trade, there seems to be reason for the claim that some legitimate
means should be devised by the government to restore in an
emergency, without waste or extravagance, such money to its place
among the people.
If such an emergency arises there now exists no clear and
undoubted executive power of relief. Heretofore the redemption of
three per cent. bonds, which were payable at the option of the
government, has afforded a means for the disbursement of the excess
of our revenues; but these bonds have been all retired, and there are
no bonds outstanding the payment of which we have the right to
insist upon. The contribution to the sinking fund which furnishes the
occasion for expenditure in the purchase of bonds has been already
made for the current year, so that there is no outlet in that direction.
In the present state of legislation the only pretence of any existing
executive power to restore, at this time, any part of our surplus
revenues to the people by its expenditure, consists in the supposition
that the Secretary of the Treasury may enter the market and
purchase the bonds of the government not yet due, at a rate of
premium to be agreed upon. The only provision of law from which
such a power could be derived is found in an appropriation bill
passed a number of years ago; and it is subject to the suspicion that it
was intended as temporary and limited in its application, instead of
conferring a continuing discretion and authority. No condition ought
to exist which would justify the grant of power to a single official,
upon his judgment of its necessity, to withhold from or release to the
business of the people, in an unusual manner, money held in the
Treasury, and thus affect, at his will, the financial situation of the
country; and if it is deemed wise to lodge in the Secretary of the
Treasury the authority in the present juncture to purchase bonds, it
should be plainly vested, and provided, as far as possible, with such
checks and limitations as will define this official’s right and
discretion, and at the same time relieve him from undue
responsibility.
In considering the question of purchasing bonds as a means of
restoring to circulation the surplus money accumulating in the
Treasury, it should be borne in mind that premiums must of course
be paid upon such purchase, that there may be a large part of these
bonds held as investments which cannot be purchased at any price,
and that combinations among holders who are willing to sell may
unreasonably enhance the cost of such bonds to the government.
It has been suggested that the present bonded debt might be
refunded at a less rate of interest, and the difference between the old
and new security paid in cash, thus finding use for the surplus in the
Treasury. The success of this plan, it is apparent, must depend upon
the volition of the holders of the present bonds; and it is not entirely
certain that the inducement which must be offered them would
result in more financial benefit to the Government than the purchase
of bonds, while the latter proposition would reduce the principal of
the debt by actual payment, instead of extending it.
The proposition to deposit the money held by the Government in
banks throughout the country, for use by the people, is, it seems to
me, exceedingly objectionable in principle, as establishing too close a
relationship between the operations of the Government Treasury and
the business of the country, and too extensive a commingling of their
money, thus fostering an unnatural reliance in private business upon
public funds. If this scheme should be adopted it should only be done
as a temporary expedient to meet an urgent necessity. Legislative
and executive effort should generally be in the opposite direction and
should have a tendency to divorce, as much and as fast as can safely
be done, the Treasury Department from private enterprise.
Of course it is not expected that unnecessary and extravagant
appropriations will be made for the purpose of avoiding the
accumulation of an excess of revenue. Such expenditure, beside the
demoralization of all just conceptions of public duty which it entails,
stimulates a habit of reckless improvidence not in the least
consistent with the mission of our people or the high and beneficent
purposes of our government.
I have deemed it my duty to thus bring to the knowledge of my
countrymen, as well as to the attention of their representatives
charged with the responsibility of legislative relief, the gravity of our
financial situation. The failure of the Congress heretofore to provide
against the dangers which it was quite evident the very nature of the
difficulty must necessarily produce, caused a condition of financial
distress and apprehension since your last adjournment, which taxed
to the utmost all the authority and expedients within executive
control; and these appear now to be exhausted. If disaster results
from the continued inaction of Congress, the responsibility must rest
where it belongs.
Though the situation thus far considered is fraught with danger
which should be fully realized, and though it presents features of
wrong to the people as well as peril to the country, it is but a result
growing out of a perfectly palpable and apparent cause, constantly
reproducing the same alarming circumstances—a congested national
treasury and a depleted monetary condition in the business of the
country. It need hardly be stated that while the present situation
demands a remedy, we can only be saved from a like predicament in
the future by the removal of its cause.
Our scheme of taxation, by means of which this needless surplus is
taken from the people and put into the public treasury, consists of a
tariff or duty levied upon importations from abroad, and internal
revenue taxes levied upon the consumption of tobacco and spirituous
and malt liquors. It must be conceded that none of the things
subjected to internal revenue taxation are, strictly speaking,
necessaries; there appears to be no just complaint of this taxation by
the consumers of these articles, and there seems to be nothing so
well able to bear the burden without hardship to any portion of the
people.
But our present tariff laws, the vicious, inequitable and illogical
source of unnecessary taxation, ought to be at once revised and
amended. These laws, as their primary and plain effect, raise the
price to consumers of all articles imported and subject to duty, by
precisely the sum paid for such duties. Thus the amount of the duty
measures the tax paid by those who purchase for use these imported
articles. Many of these things, however, are raised or manufactured
in our own country, and the duties now levied upon foreign goods
and products are called protection to these home manufactures,
because they render it possible for those of our people who are
manufacturers, to make these taxed articles and sell them for a price
equal to that demanded for the imported goods that have paid
customs duty. So it happens that while comparatively a few use the
imported articles, millions of our people, who never use and never
saw any of the foreign products, purchase and use things of the same
kind made in this country, and pay therefor nearly or quite the same
enhanced price which the duty adds to the imported articles. Those
who buy imports pay the duty charged thereon into the public
treasury, but the great majority of our citizens, who buy domestic
articles of the same class, pay a sum at least approximately equal to
this duty to the home manufacturer. This reference to the operation
of our tariff laws is not made by way of instruction, but in order that
we may be constantly reminded of the manner in which they impose
a burden upon those who consume domestic products as well as
those who consume imported articles, and thus create a tax upon all
our people.
It is not proposed to entirely relieve the country of this taxation. It
must be extensively continued as the source of the government’s
income; and in a readjustment of our tariff the interests of American
labor engaged in manufacture should be carefully considered, as well
as the preservation of our manufacturers. It may be called
protection, or by any other name, but relief from the hardships and
dangers of our present tariff laws should be devised with especial
precaution against imperilling the existence of our manufacturing
interests. But this existence should not mean a condition which,
without regard to the public welfare or a national exigency, must
always insure the realization of immense profits instead of
moderately profitable returns. As the volume and diversity of our
national activities increase, new recruits are added to those who
desire a continuation of the advantages which they conceive the
present system of tariff taxation directly affords them. So stubbornly
have all efforts to reform the present condition been resisted by
those of our fellow-citizens thus engaged, that they can hardly
complain of the suspicion, entertained to a certain extent, that there
exists an organized combination all along the line to maintain their
advantage.
We are in the midst of centennial celebrations, and with becoming
pride we rejoice in American skill and ingenuity, in American energy
and enterprise, and in the wonderful natural advantages and
resources developed by a century’s national growth. Yet when an
attempt is made to justify a scheme which permits a tax to be laid
upon every consumer in the land for the benefit of our
manufacturers, quite beyond a reasonable demand for governmental
regard, it suits the purposes of advocacy to call our manufactures
infant industries, still needing the highest and greatest degree of
favor and fostering care that can be wrung from Federal legislation.
It is also said that the increase in the price of domestic
manufactures resulting from the present tariff is necessary in order
that higher wages may be paid to our workingmen employed in
manufactures, than are paid for what is called the pauper labor of
Europe. All will acknowledge the force of an argument which
involves the welfare and liberal compensation of our laboring people.
Our labor is honorable in the eyes of every American citizen: and as
it lies at the foundation of our development and progress, it is
entitled, without affectation or hypocrisy, to the utmost regard. The
standard of our laborers’ life should not be measured by that of any
other country less favored, and they are entitled to the full share of
all our advantages.
By the last census it is made to appear that of the 17,392,099 of our
population engaged in all kinds of industries 7,670,493 are employed
in agriculture, 4,074,238 in professional and personal service,
(2,934,876 of whom are domestic servants and laborers,) while
1,810,256 are employed in trade and transportation, and 3,837,112
are classed as employed in manufacturing and mining.
For present purposes, however, the last number given should be
considerably reduced. Without attempting to enumerate all, it will be
conceded that there should be deducted from those which it includes
375,143 carpenters and joiners, 285,401 milliners, dressmakers, and
seamstresses, 172,726 blacksmiths, 133,756 tailors and tailoresses,
102,473 masons, 76,241 butchers, 41,309 bakers, 22,083 plasterers
and 4,891 engaged in manufacturing agricultural implements,
amounting in the aggregate to 1,214,023, leaving 2,623,089 persons
employed in such manufacturing industries as are claimed to be
benefited by a high tariff.
To these the appeal is made to save their employment and
maintain their wages by resisting a change. There should be no
disposition to answer such suggestions by the allegation that they are
in a minority among those who labor, and therefore should forego an
advantage, in the interest of low prices for the majority; their
compensation, as it may be affected by the operation of the tariff
laws, should at all times be scrupulously kept in view; and yet with
slight reflection they will not overlook the fact that they are
consumers with the rest; that they, too, have their own wants and
those of their families to supply from their earnings, and that the
price of the necessaries of life, as well as the amount of their wages,
will regulate the measure of their welfare and comfort.
But the reduction of taxation demanded should be so measured as
not to necessitate or justify either the loss of employment by the
working man nor the lessening of his wages; and the profits still
remaining to the manufacturer, after a necessary readjustment,
should furnish no excuse for the sacrifice of the interests of his
employés either in their opportunity to work or in the diminution of
their compensation. Nor can the worker in manufactures fail to
understand that while a high tariff is claimed to be necessary to allow
the payment of remunerative wages, it certainly results in a very
large increase in the price of nearly all sorts of manufactures, which,
in almost countless forms, he needs for the use of himself and his
family. He receives at the desk of his employer his wages, and
perhaps before he reaches his home is obliged, in a purchase for
family use of an article which embraces his own labor, to return in
the payment of the increase in price which the tariff permits, the
hard-earned compensation of many days of toil.
The farmer and the agriculturist who manufacture nothing, but
who pay the increased price which the tariff imposes, upon every
agricultural implement, upon all he wears and upon all he uses and
owns, except the increase of his flocks and herds and such things as
his husbandry produces from the soil, is invited to aid in maintaining
the present situation; and he is told that a high duty on imported
wool is necessary for the benefit of those who have sheep to shear, in
order that the price of their wool may be increased. They of course
are not reminded that the farmer who has no sheep is by this scheme
obliged, in his purchase of clothing and woolen goods, to pay a
tribute to his fellow farmer as well as to the manufacturer and
merchant; nor is any mention made of the fact that the sheep-owners
themselves and their households, must wear clothing and use other
articles manufactured from the wool they sell at tariff prices, and
thus as consumers must return their share of this increased price to
the tradesman.
I think it may be fairly assumed that a large proportion of the
sheep owned by the farmers throughout the country are found in
small flocks numbering from twenty-five to fifty. The duty on the
grade of imported wool which these sheep yield, is ten cents each
pound if of the value of thirty cents or less, and twelve cents if of the
value of more than thirty cents. If the liberal estimate of six pounds
be allowed for each fleece, the duty thereon would be sixty or
seventy-two cents, and this may be taken as the utmost enhancement
of its price to the farmer by reason of this duty. Eighteen dollars
would thus represent the increased price of the wool from twenty-
five sheep and thirty-six dollars that from the wool of fifty sheep; and
at present values this addition would amount to about one-third of
its price. If upon its sale the farmer receives this or a less tariff profit,
the wool leaves his hands charged with precisely that sum, which in
all its changes will adhere to it, until it reaches the consumer. When
manufactured into cloth and other goods and material for use, its
cost is not only increased to the extent of the farmer’s tariff profit,
but a further sum has been added for the benefit of the manufacturer
under the operation of other tariff laws. In the meantime the day
arrives when the farmer finds it necessary to purchase woolen goods
and material to clothe himself and family for the winter. When he
faces the tradesman for that purpose he discovers that he is obliged
not only to return in the way of increased prices, his tariff profit on
the wool he sold, and which then perhaps lies before him in
manufactured form, but that he must add a considerable sum thereto
to meet a further increase in cost caused by a tariff duty on the
manufacture. Thus in the end he is aroused to the fact that he has
paid upon a moderate purchase, as the result of the tariff scheme,
which, when he sold his wool seemed so profitable, an increase in
price more than sufficient to sweep away all the tariff profit he
received upon the wool he produced and sold.
When the number of farmers engaged in wool-raising is compared
with all the farmers in the country, and the small proportion they
bear to our population is considered; when it is made apparent that,
in the case of a large part of those who own sheep, the benefit of the
present tariff wool is illusory; and, above all, when it must be
conceded that the increase of the cost of living caused by such a
tariff, becomes a burden upon those with moderate means and the
poor, the employed and the unemployed, the sick and well, and the
young and old, and that it constitutes a tax which, with relentless
grasp, is fastened upon the clothing of every man, woman, and child
in the land, reasons are suggested why the removal or reduction or
this duty should be included in a revision of our tariff laws.
In speaking of the increased cost to the consumer of our home
manufactures, resulting from a duty laid upon imported articles of
the same description, the fact is not overlooked that competition
among our domestic producers sometimes has the effect of keeping
the price of their products below the highest limit allowed by such
duty. But it is notorious that this competition is too often strangled
by combinations quite prevalent at this time, and frequently called
trusts, which have for their object the regulation of the supply and
price of commodities made and sold by members of the combination.
The people can hardly hope for any consideration in the operation of
these selfish schemes.
If, however, in the absence of such combination, a healthy and free
competition reduces the price of any particular dutiable article of
home production, below the limit which it might otherwise reach
under our tariff laws, and if, with such reduced price, its
manufacture continues to thrive, it is entirely evident that one thing
has been discovered which should be carefully scrutinized in an
effort to reduce taxation.
The necessity of combination to maintain the price of any
commodity to the tariff point, furnishes proof that some one is
willing to accept lower prices for such commodity, and that such
prices are remunerative; and lower prices produced by competition
prove the same thing. Thus where either of these conditions exists, a
case would seem to be presented for an easy reduction of taxation.
The considerations which have been presented touching our tariff
laws are intended only to enforce an earnest recommendation that
the surplus revenues of the government be prevented by the
reduction of our customs duties, and, at the same time, to emphasize
a suggestion that in accomplishing this purpose, we may discharge a
double duty to our people by granting to them a measure of relief
from tariff taxation in quarters where it is most needed and from
sources where it can be most fairly and justly accorded.
Nor can the presentation made of such considerations be, with any
degree of fairness, regarded as evidence of unfriendliness toward our
manufacturing interests, or of any lack of appreciation of their value
and importance.
These interests constitute a leading and most substantial element
of our national greatness and furnish the proud proof of our
country’s progress. But if in the emergency that presses upon us our
manufacturers are asked to surrender something for the public good
and to avert disaster, their patriotism, as well as a grateful
recognition of advantages already afforded, should lead them to
willing coöperation. No demand is made that they shall forego all the
benefits of governmental regard; but they cannot fail to be
admonished of their duty, as well as their enlightened self-interest
and safety, when they are reminded of the fact that financial panic
and collapse, to which the present condition tends, afford no greater
shelter or protection to our manufactures than to our other
important enterprises. Opportunity for safe, careful, and deliberate
reform is now afforded; and none of us should be unmindful of a
time when an abused and irritated people, heedless of those who
have resisted timely and reasonable relief, may insist upon a radical
and sweeping rectification of their wrongs.
The difficulty attending a wise and fair revision of our tariff laws is
not underestimated. It will require on the part of the Congress great
labor and care, and especially a broad and national contemplation of
the subject, and a patriotic disregard of such local and selfish claims
as are unreasonable and reckless of the welfare of the entire country.
Under our present laws more than four thousand articles are
subject to duty. Many of these do not in any way compete with our
own manufactures, and many are hardly worth attention as subjects
of revenue. A considerable reduction can be made in the aggregate,
by adding them to the free list. The taxation of luxuries presents no
features of hardship; but the necessaries of life used and consumed
by all the people, the duty upon which adds to the cost of living in
every home, should be greatly cheapened.
The radical reduction of the duties imposed upon raw material
used in manufactures, or its free importation, is of course an
important factor in any effort to reduce the price of these
necessaries; it would not only relieve them from the increased cost
caused by the tariff on such material, but the manufactured product
being thus cheapened, that part of the tariff now laid upon such
product, as a compensation to our manufacturers for the present
price of raw material, could be accordingly modified. Such reduction,
or free importation, would serve beside to largely reduce the revenue.
It is not apparent how such a change can have any injurious effect
upon our manufacturers. On the contrary, it would appear to give
them a better chance in foreign markets with the manufacturers of
other countries, who cheapen their wares by free material. Thus our
people might have the opportunity of extending their sales beyond
the limits of home consumption—saving them from the depression,
interruption in business, and loss caused by a glutted domestic
market, and affording their employés more certain and steady labor,
with its resulting quiet and contentment.
The question thus imperatively presented for solution should be
approached in a spirit higher than partisanship and considered in
the light of that regard for patriotic duty which should characterize
the action of those intrusted with the weal of a confiding people. But
the obligation to declared party policy and principle is not wanting to
urge prompt and effective action. Both of the great political parties
now represented in the Government have, by repeated and
authoritative declarations, condemned the condition of our laws
which permits the collection from the people of unnecessary revenue,
and have, in the most solemn manner, promised its correction; and
neither as citizens or partisans are our countrymen in a mood to
condone the deliberate violation of these pledges.
Our progress toward a wise conclusion will not be improved by
dwelling upon the theories of protection and free trade. This savors
too much of bandying epithets. It is a condition which confronts us—
not a theory. Relief from this condition may involve a slight
reduction of the advantages which we award our home productions,
but the entire withdrawal of such advantages should not be
contemplated. The question of free trade is absolutely irrelevant; and
the persistent claim made in certain quarters, that all efforts to
relieve the people from unjust and unnecessary taxation are schemes
of so-called free-traders, is mischievous and far removed from any
consideration for the public good.
The simple and plain duty which we owe the people is to reduce
taxation to the necessary expenses of an economical operation of the
government, and to restore to the business of the country the money
which we hold in the treasury through the perversion of
governmental powers. These things can and should be done with
safety to all our industries, without danger to the opportunity for
remunerative labor which our workingmen need, and with benefit to
them and all our people, by cheapening their means of subsistence
and increasing the measure of their comforts.
The Constitution provides that the President “shall, from time to
time, give to the Congress information of the state of the Union.” It
has been the custom of the Executive, in compliance with this
provision, to annually exhibit to the Congress, at the opening of its
session, the general condition of the country, and to detail, with
some particularity, the operations of the different Executive
Departments. It would be especially agreeable to follow this course at
the present time, and to call attention to the valuable
accomplishments of these departments during the last fiscal year.
But I am much impressed with the paramount importance of the
subject to which this communication has thus far been devoted, that
I shall forego the addition of any other topic, and only urge upon
your immediate consideration the “state of the Union” as shown in
the present condition of our treasury and our general fiscal situation,
upon which every element of our safety and prosperity depends.
The reports of the heads of departments, which will be submitted,
contain full and explicit information touching the transaction of the
business intrusted to them, and such recommendations relating to
legislation in the public interest as they deem advisable. I ask for
these reports and recommendations the deliberate examination and
action of the Legislative branch of the government.
There are other subjects not embraced in the departmental reports
demanding legislative consideration and which I should be glad to
submit. Some of them, however, have been earnestly presented in
previous messages, and as to them, I beg leave to repeat prior
recommendations.
As the law makes no provision for any report from the department
of State, a brief history of the transactions of that important
Department, together with other matters which it may hereafter be
deemed essential to commend to the attention of the Congress, may
furnish the occasion for a future communication.

Grover Cleveland.

Washington, December 6, 1887.


Mr. Blaine’s Answer to Cleveland.

By Cable to the N. Y. Tribune.


Paris, Dec. 7, 1887.—After reading an abstract of the President’s
message, laid before all Europe this morning, I saw Mr. Blaine and
asked him if he would be willing to give his views upon the
recommendation of the President in the form of a letter or interview.
He preferred an interview, if I would agree to send him an intelligent
shorthand reporter, with such questions as should give free scope for
an expression of his views. The following lucid and powerful
statement is the result. Mr. Blaine began by saying to the reporter:
“I have been reading an abstract of the President’s message and
have been especially interested in the comments of the London
papers. Those papers all assume to declare that the message is a free
trade manifesto and evidently are anticipating an enlarged market
for English fabrics in the United States as a consequence of the
President’s recommendations. Perhaps that fact stamped the
character of the message more clearly than any words of mine can.”
“You don’t mean actual free trade without duty?” queried the
reporter.
“No,” replied Mr. Blaine. “Nor do the London papers mean that.
They simply mean that the President has recommended what in the
United States is known as a revenue tariff, rejecting the protective
feature as an object and not even permitting protection to result
freely as an incident to revenue duties.”
“I don’t know that I quite comprehend that last point,” said the
reporter.
“I mean,” said Mr. Blaine, “that for the first time in the history of
the United States the President recommends retaining the internal
tax in order that the tariff may be forced down even below the fair
revenue standard. He recommends that the tax on tobacco be
retained, and thus that many millions annually shall be levied on a
domestic product which would far better come from a tariff on
foreign fabrics.”
“Then do you mean to imply that you would favor the repeal of the
tobacco tax?”
“Certainly; I mean just that,” said Mr. Blaine. “I should urge that it
be done at once, even before the Christmas holidays. It would in the
first place bring great relief to growers of tobacco all over the
country, and would, moreover, materially lessen the price of the
article to consumers. Tobacco to millions of men is a necessity. The
President calls it a luxury, but it is a luxury in no other sense than tea
and coffee are luxuries. It is well to remember that the luxury of
yesterday becomes a necessity of to-day. Watch, if you please, the
number of men at work on the farm, in the coal mine, along the
railroad, in the iron foundry, or in any calling, and you will find 95 in
100 chewing while they work. After each meal the same proportion
seek the solace of a pipe or a cigar. These men not only pay the
millions of the tobacco tax, but pay on every plug and every cigar an
enhanced price which the tax enables the manufacturer and retailer
to impose. The only excuse for such a tax is the actual necessity
under which the government found itself during the war, and the
years immediately following. To retain the tax now in order to
destroy the protection which would incidentally flow from raising the
same amount of money on foreign imports, is certainly a most
extraordinary policy for our government.”
“Well, then, Mr. Blaine, would you advise the repeal of the whiskey
tax also?”
“No, I would not. Other considerations than those of financial
administration are to be taken into account with regard to whiskey.
There is a moral side to it. To cheapen the price of whiskey is to
increase its consumption enormously. There would be no sense in
urging the reform wrought by high license in many States if the
National Government neutralizes the good effect by making whiskey
within reach of every one at twenty cents a gallon. Whiskey would be
everywhere distilled if the surveillance of the government were
withdrawn by the remission of the tax, and illicit sales could not then
be prevented even by a policy as rigorous and searching as that with
which Russia pursues the Nihilists. It would destroy high license at
once in all the States.
“Whiskey has done a vast deal of harm in the United States. I
would try to make it do some good. I would use the tax to fortify our
cities on the seaboard. In view of the powerful letter addressed to the
democratic party on the subject of fortifications by the late Samuel J.
Tilden, in 1885, I am amazed that no attention has been paid to the
subject by the democratic administration. Never before in the history
of the world has any government allowed great cities on the
seaboard, like Philadelphia, New York, Boston, Baltimore, New
Orleans, and San Francisco, to remain defenceless.”
“But,” said the reporter, “you don’t think we are to have a war in
any direction?”
“Certainly not,” said Mr. Blaine, “Neither, I presume, did Mr.
Tilden when he wrote his remarkable letter. But we should change a
remote chance into an absolute impossibility. If our weak and
exposed points were strongly fortified; if to-day we had by any
chance even such a war as we had with Mexico our enemy could
procure ironclads in Europe that would menace our great cities with
destruction or lay them under contribution.”
“But would not our fortifying now possibly look as if we expected
war?”
“Why should it any more than fortifications made seventy or eighty
years ago by our grandfathers when they guarded themselves against
successful attack from the armaments of that day. We don’t
necessarily expect a burglar because we lock our doors at night, but if
by any possibility a burglar comes it contributes vastly to our peace
of mind and our sound sleep to feel that he can’t get in.”
“But after the fortifications should be constructed would you still
maintain the tax on whiskey?”
“Yes,” said Mr. Blaine, “So long as there is whiskey to tax I would
tax it, and when the National Government should have no use for the
money I would divide the tax among the Federal Union with specific
object of lightening the tax on real estate. The houses and farms of
the whole country pay too large a proportion of the total taxes. If
ultimately relief could be given in that direction it would, in my
judgment, be a wise and beneficent policy. Some honest but

You might also like