Alexandre Bergel
Santiago, Chile
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484253830 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5383-0 e-ISBN 978-1-4842-5384-7
https://doi.org/10.1007/978-1-4842-5384-7
Alexandre Bergel 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
Artificial Intelligence (AI) is radically changing the way we use computers to solve problems. For example, by exploiting previous experience, which may be expressed in terms of examples, a machine can identify patterns in a given situation and try to identify the same patterns in a slightly different situation. This is essentially the way AI is used nowadays. The field of AI is moving quickly, and unfortunately, it is often difficult to understand.
The objective of the Agile Artificial Intelligence in Pharo book is to provide a practical foundation for a set of expressive artificial intelligence algorithms using the Pharo programming language. The book makes two large contributions over existing related books. The first contribution is to bring agility in the way some techniques related to artificial intelligence are designed, implemented, and evaluated. The book provides material in an incremental fashion, beginning with a little perception and ending with a full implementation of two algorithms for neuroevolution.
The second contribution is about making these techniques accessible to programmers by detailing their implementation without overwhelming the reader with mathematical material. There is often a significant gap between reading mathematical formulas and producing executable source code from those formulas, unfortunately. The book is meant to be accessible to a large audience by focusing on executable source code.
Overall, this book details and illustrates some easy-to-use recipes to solve actual problems. Furthermore, it highlights some technical details of these recipes using the Pharo programming language. Agile Artificial Intelligence in Pharo is not a book about how to use an existing API provided by external libraries. Instead, this book guides you to build your own API for artificial intelligence.
Book Overview
Agile Artificial Intelligence in Pharo is divided into three parts, each targeting a specific topic within the field of artificial intelligenceneural networks, genetic algorithms, and neuroevolution.
The first part of the book is about neural networks. A neural network is a computational metaphor simulating the interaction occurring between biological neurons. The chapter begins with the implementation of a single neuron and shows its limitations in terms of what it can achieve. Neural networks are then presented to solve more complex problems. Various examples involving relatively simple data classification tasks are presented.
The second part of the book covers genetic algorithms (GAs). The GA is a computational metaphor simulating the evolution occurring in biological species. GAs provide a way to solve problems without knowing the structure and shape of the solution in advance. GAs simulate the way biological species evolve over time. For two candidate solutions, as soon as the machine is able to say which one is closer to the solution, then GAs may be considered to solve the problem. Numerous examples are provided in this second part of the book, including an implementation of zoomorphic creatures, which is a simulation of artificial life. We define a zoomorphic creature as an artificial organism able to evolve in order to move itself through obstacles.
The third part of the book covers the field of neuroevolution, which is a combination of genetic algorithms and neural networks. The evolution of neural networks is called neuroevolution. Instead of training a neural network, as in classical deep learning (Part 1 of the book), neuroevolution begins with extremely simple networks and incrementally adds complexity to them. Evolution makes those networks able to solve particular tasks. This third part uses a Mario Bros-like game, which is used to build an artificial player using neuroevolution.
Installing Pharo
Pharo works on the three common platforms, Mac OSX, Windows, and Linux. The web page at https://pharo.org/download gives a very detailed instruction set and some links to download Pharo. Pharo is easy to install. Just a matter of a few clicks.
The content of the book is known to work up until Pharo 9. The code provided in the book does not heavily rely on the Pharo runtime. So the code provided in this book should be easy to adapt to future versions of Pharo or to another dialect of Smalltalk.
Accompanying Source Code
Agile Artificial Intelligence in Pharo is a book about programming. It provides and details a sizable amount of source code. Most of the code in the book is self-contained. This means that no external libraries are used besides the Pharo core and the Roassal visualization engine. Roassal is used to visually explore data and build a user interface. Readers may prefer to transcribe the code into Pharo or use our dedicated Git repository at https://github.com/Apress/agile-ai-in-pharo .
A script that begins with ellipses (i.e., ... ) means that you need to append the script to the last one seen before.
The code provided in this book is known to run on Pharo 8 and 9. To load the code, you simply need to open a playground and execute the following code: