Book Image

Hands-On Artificial Intelligence with Java for Beginners

By : Nisheeth Joshi
Book Image

Hands-On Artificial Intelligence with Java for Beginners

By: Nisheeth Joshi

Overview of this book

Artificial intelligence (AI) is increasingly in demand as well as relevant in the modern world, where everything is driven by technology and data. AI can be used for automating systems or processes to carry out complex tasks and functions in order to achieve optimal performance and productivity. Hands-On Artificial Intelligence with Java for Beginners begins by introducing you to AI concepts and algorithms. You will learn about various Java-based libraries and frameworks that can be used in implementing AI to build smart applications. In addition to this, the book teaches you how to implement easy to complex AI tasks, such as genetic programming, heuristic searches, reinforcement learning, neural networks, and segmentation, all with a practical approach. By the end of this book, you will not only have a solid grasp of AI concepts, but you'll also be able to build your own smart applications for multiple domains.
Table of Contents (14 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

A brief introduction to the A* algorithm


We'll now look at how an A* algorithm works. In this algorithm, we'll calculate two costs. We'll be taking four pieces of input: our start state (a set of implicitly given states), a state transition operator, a goal state, and the heuristic value of each node. Based on those, we'll be calculating our actual cost, g(n) (which we also calculated in our Dijkstra's algorithm). Along with the actual cost, we'll calculate one more cost: the final cost (f(n)). The final cost will be the actual cost plus the heuristic cost (h(n)). The formula is as follows:

 

In the preceding formula, the following applies:

  • g(n) is the actual cost of traversing from the initial state to state n
  • h(n) is the estimated cost of reaching the goal from state n

We are given the following information:

[S,s,O,G,h]

In the preceding statement, the following applies:

  • S is an implicitly given set of states
  • s is the start state
  • O is the state transition operator
  • G is the goal
  • h is the heuristic function...