Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Learning game AI programming with Lua
Learning game AI programming with Lua

Learning game AI programming with Lua: Leverage the power of Lua programming to create game AI that focuses on motion, animation, and tactics

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Learning game AI programming with Lua

Chapter 2. Creating and Moving Agents

In this chapter, we will cover the following topics:

  • Setting up your first sandbox executable
  • Creating your first sandbox Lua scripts
  • Understanding agent properties and their effects
  • Basic Newtonian motion
  • Agent-steering forces
  • Creating seeking, pursuing, path following, and grouped agents

Now that we understand how AI sandbox is set up and some of the underlying system structure, we're going to dive head-first into creating a brand new sandbox demo. Throughout the rest of the book, the new Lua sandbox API will be introduced piece by piece, extending this demo with additional AI functionality, animation, graphics, and game play.

While the sandbox is doing a lot of heavy lifting in terms of graphics and physics, the core AI logic will be completely implemented in Lua, backed by data structures that are managed by the C++ code.

Creating a new sandbox project

First, to create a new sandbox executable, we need to declare a new Visual Studio demo project within the Premake build scripts. You can add a new sandbox project by opening the SandboxDemos.lua script and appending a new entry to the SandboxDemos table. In this case, you can name your my_sandbox demo or any other name you'd like. The project name will determine the name of the executable that is built:

SandboxDemos.lua:

SandboxDemos = {
    "chapter_1_introduction",
    ...
    "my_sandbox"
};

Note

All the heavy lifting of configuring a sandbox demo actually takes place in the premake.lua file by the CreateDemoProject function. The premake.lua script simply loops over all entries within the SandboxDemos table and creates the corresponding projects, setting up the source files, project dependencies, library includes, and so on.

Setting up the file structure

The next step is to set up the actual file structure for the C++ source files, C++ header files, and Lua script files for the demo. Create the corresponding directory structure based on the entry you added to the SandboxDemos table. Premake will automatically search for any .h, .cpp, and .lua files that reside within these folders and any subfolders, automatically adding them to the Visual Studio project during the solution regeneration:

src/my_sandbox/include
src/my_sandbox/src
src/my_sandbox/script

Extending the SandboxApplication class

Once your project has been set up, you need to create three blank files for Premake to discover.

Create the source and header files as follows:

src/my_sandbox/include/MySandbox.h
src/my_sandbox/src/MySandbox.cpp
src/my_sandbox/src/main.cpp

Now, it's time to regenerate the Visual Studio solution by executing vs2008.bat, vs2010.bat, vs2012.bat, or vs2013.bat. When you open the Visual Studio solution, you'll see your brand new My_Sandbox project!

Each of the sandbox demos is set up to extend the base SandboxApplication class and declare where to find the corresponding Lua script files for the executable.

Declaring your MySandbox class follows the same pattern and looks as follows:

MySandbox.h:

#include "demo_framework/include/SandboxApplication.h"

class MySandbox : public SandboxApplication {
public:
    MySandbox(void);

    virtual ~MySandbox(void);

    virtual void Initialize();
};

Inheriting from SandboxApplication gives you a base...

Running your sandbox for the first time

Now, compile your solution and run your sandbox. As no meshes, lights, and so on have been added to the sandbox yet, all you should see is a black screen. While this might seem small, a lot has happened already, and your SandboxApplication class is properly set up to let Lua take over.

Creating a new Decoda project

Once Visual Studio is out of the way, it's time to create a Decoda project. Open Decoda and create a blank new project. Save the project to the decoda folder, which will create the .deproj and .deuser files. Whenever we need to create a new Lua script file, we will create the file within Decoda and save the .lua file to the src/my_sandbox/script folder:

decoda/my_sandbox.deproj
decoda/my_sandbox.deuser

Creating a new sandbox project


First, to create a new sandbox executable, we need to declare a new Visual Studio demo project within the Premake build scripts. You can add a new sandbox project by opening the SandboxDemos.lua script and appending a new entry to the SandboxDemos table. In this case, you can name your my_sandbox demo or any other name you'd like. The project name will determine the name of the executable that is built:

SandboxDemos.lua:

SandboxDemos = {
    "chapter_1_introduction",
    ...
    "my_sandbox"
};

Note

All the heavy lifting of configuring a sandbox demo actually takes place in the premake.lua file by the CreateDemoProject function. The premake.lua script simply loops over all entries within the SandboxDemos table and creates the corresponding projects, setting up the source files, project dependencies, library includes, and so on.

Setting up the file structure


The next step is to set up the actual file structure for the C++ source files, C++ header files, and Lua script files for the demo. Create the corresponding directory structure based on the entry you added to the SandboxDemos table. Premake will automatically search for any .h, .cpp, and .lua files that reside within these folders and any subfolders, automatically adding them to the Visual Studio project during the solution regeneration:

src/my_sandbox/include
src/my_sandbox/src
src/my_sandbox/script

Extending the SandboxApplication class


Once your project has been set up, you need to create three blank files for Premake to discover.

Create the source and header files as follows:

src/my_sandbox/include/MySandbox.h
src/my_sandbox/src/MySandbox.cpp
src/my_sandbox/src/main.cpp

Now, it's time to regenerate the Visual Studio solution by executing vs2008.bat, vs2010.bat, vs2012.bat, or vs2013.bat. When you open the Visual Studio solution, you'll see your brand new My_Sandbox project!

Each of the sandbox demos is set up to extend the base SandboxApplication class and declare where to find the corresponding Lua script files for the executable.

Declaring your MySandbox class follows the same pattern and looks as follows:

MySandbox.h:

#include "demo_framework/include/SandboxApplication.h"

class MySandbox : public SandboxApplication {
public:
    MySandbox(void);

    virtual ~MySandbox(void);

    virtual void Initialize();
};

Inheriting from SandboxApplication gives you a base to start with. For now...

Running your sandbox for the first time


Now, compile your solution and run your sandbox. As no meshes, lights, and so on have been added to the sandbox yet, all you should see is a black screen. While this might seem small, a lot has happened already, and your SandboxApplication class is properly set up to let Lua take over.

Creating a new Decoda project


Once Visual Studio is out of the way, it's time to create a Decoda project. Open Decoda and create a blank new project. Save the project to the decoda folder, which will create the .deproj and .deuser files. Whenever we need to create a new Lua script file, we will create the file within Decoda and save the .lua file to the src/my_sandbox/script folder:

decoda/my_sandbox.deproj
decoda/my_sandbox.deuser

Configuring Decoda's run executable


In order for Decoda to execute your sandbox, we need to configure the Decoda project with the following settings. You can access the project settings by navigating to Project | Settings. Typically, we'll have Decoda run the Release version of the sandbox executable for performance. Unless you need to debug the C++ sandbox code and Lua scripts at the same time, it's advisable to run the Release version of your executable.

The configuration of new Decoda project debug settings

Note

Note the relative path for the release executable. The path that Decoda will execute is based on the location of the .deproj file.

Remember that you have to build the Visual Studio solution before trying to debug with Decoda.

Creating a sandbox Lua script


With a basic sandbox application out of the way, we're going to create the basic Lua script that sets up the sandbox. First, create a new Sandbox.lua script within the script folder:

Create the Lua file as follows:

src/my_sandbox/script/Sandbox.lua

A sandbox Lua script must implement four global functions that the C++ code will call, and they are Sandbox_Cleanup, Sandbox_HandleEvent, Sandbox_Initialize, and Sandbox_Update:

Sandbox.lua:

function Sandbox_Cleanup(sandbox)
end

function Sandbox_HandleEvent(sandbox, event)
end

function Sandbox_Initialize(sandbox)
end

function Sandbox_Update(sandbox, deltaTimeInMillis)
end

With the basic hooks in place, modify your SandboxApplication class to create a sandbox based on your Lua script:

MySandbox.cpp:

void MySandbox::Initialize() {
    SandboxApplication::Initialize();

    ...
    CreateSandbox("Sandbox.lua");
}

Tip

Don't forget to recompile your sandbox application whenever a change is made to any of the C++ files.

Creating...

Shooting blocks


Now that we have some basic lighting, a physics plane, and the ability to create and simulate physics objects, it's time to start shooting things. Before we jump head-first into creating agents, we'll take a quick detour into accessing some of the physics aspects of sandbox objects, as well as interacting with input controls.

The Sandbox_HandleEvent function allows the sandbox to respond to mouse and keyboard inputs. The event parameter is a Lua table that stores the source of the event, whether the event was generated by a down or up key press, and what key caused the event. Mouse-movement events are similar, but contain the width and height location of the mouse cursor.

As we already know how to create a sandbox object, all we need to do to shoot objects is position the object at the camera's position and orientation and apply a physics impulse on the object.

In this case, we're going to create and shoot a block on a space_key press event. The camera's position and forward...

Creating an agent Lua script


To start creating an agent, we need to create another Lua script that implements the Agent_Cleanup, Agent_HandleEvent, Agent_Initialize, and Agent_Update functions:

Create the Lua file as follows:

src/my_sandbox/script/Agent.lua

Agent.lua:

function Agent_Cleanup(agent)
end

function Agent_HandleEvent(agent, event)
end

function Agent_Initialize(agent)
end

function Agent_Update(agent, deltaTimeInMillis)
end

Now that we have a basic agent script, we can create an instance of the agent within the sandbox. Modify the initialization of the sandbox in order to create your AI agent with the Sandbox.CreateAgent function.

Tip

Remember that each AI agent runs within its own Lua virtual machine (VM). Even though a separate VM is running the agent logic, you can still access and modify properties of an agent from the sandbox Lua script, as the C++ code manages agent data.

Modify the initialization of the sandbox in order to create your AI agent with the Sandbox.CreateAgent function...

Agent properties


Now that we can create agents, we're going to take a step back and look at what properties are available to an agent and what they mean.

Orientation

Whenever you need to return the orientation of an agent, it's easiest to use the forward vector that usually represents the direction of movement of an agent. Both the left and up vectors of orientation are available as well. Whenever you need to change an agent's direction, simply set its forward vector.

The forward axis

To access and set the forward vector of our agents, we can use the built-in GetForward and SetForward helper functions.

local forwardVector = agent:GetForward();
Agent.SetForward(agent, forwardVector);

The left axis

We can also access the left orientation vector using the GetLeft helper function.

local leftVector = agent:GetLeft();

The up axis

Accessing the up orientation vector is similarly provided by a GetUp helper function.

local upVector = agent:GetUp();

Location

An agent's position is the center of the mass of its...

Physics


Even though agents are simulated with physics, not all of the agent's physics parameters are enforced at the physics simulation level. The mass of an agent, for example, is the identical mass used within the physics simulation itself, while the MaxForce and MaxSpeed functions of an agent are only enforced by the agent. These two properties represent the maximum amount of force an agent can exert on itself and the max speed the agent can reach without any outside influences.

An intuitive example of why this separation is desirable when dealing with agent physics is gravity. When an agent accelerates to its max speed, we still want gravity to accelerate the agents downward in the case of falls. This acceleration can force agents to have a speed larger than their max speed property.

Mass

To access and modify the mass of our agents we can use the agent's GetMass and SetMass helper functions.

local mass = agent:GetMass();
agent:SetMass(mass);

The max force

The maximum force of our agents can...

Knowledge


Agents themselves have a very basic set of knowledge so that external Lua scripts such as the sandbox script can direct agents with some amount of persistence. For example, when we create an agent that moves to a target position, we might want the sandbox to set this position instead of the agent having to determine its target.

Target

An agent's target is a vector position. Typically, agents will use the target as a position they want to reach or the known position of another agent.

local targetVector = agent:GetTarget();
agent:SetTarget(targetVector);

Target radius

A target radius is a number value that agents use to determine whether they are close enough to their target without having to be exactly at the target position. This fudge factor helps agents avoid circling a target position due to small numerical differences in their position and target position.

local targetRadius = agent:GetTargetRadius();
agent:SetTargetRadius(targetRadius );

Path

An agent's path is a series of vector...

Agents' movement


As all agents within the sandbox are automatically simulated through the physics system, it's time to get acquainted with some basic Newtonian physics.

Mass

The mass of an agent comes into play when colliding with other objects and is based on how much the agent should accelerate based on the forces applied to the agent. All mass calculations within the sandbox occur in kilograms.

Speed

Speed defines how fast an agent is moving without considering the direction the agent is moving in. All speed values within the sandbox will be measured in meters per second and signify the magnitude of the velocity vector.

Velocity

Velocity, on the other hand, is both the speed and direction the agent is moving in. It is measured in meters per second and is represented as a vector.

Acceleration

Acceleration within the sandbox is always measured in meters per second squared and represents the change in the velocity of an agent.

Force

Force plays a large part when moving agents around and is measured...

Agent-steering forces


With some basic agent properties and a full-fledged physics system supporting the sandbox, we can begin moving agents realistically through forces. This type of movement system is best known as a steering-based locomotion system. Craig Reynolds' Steering Behaviors For Autonomous Characters (http://www.red3d.com/cwr/papers/1999/gdc99steer.html) is best known for describing this style of steering system for moving characters. Steering forces allow for an easy classification of different movement types and allow for an easy way to apply multiple forces to a character.

As the sandbox uses the OpenSteer library to steer calculations, this makes it painless for Lua to request steering forces. While the steering calculations are left to OpenSteer, the application of forces will reside within our Lua Scripts.

Seeking

Seeking is one of the core steering forces and calculates a force that moves the agent toward their target. OpenSteer combines both seeking- and arrival-steering...

Avoidance


Avoidance steering behavior involves avoiding collisions between moving agents, objects, and other moving agents. The collision avoidance calculated from ForceToAvoidAgents creates a steering force in the tangent direction of a potential agent as two agents move closer to one another. Predictive movements are used to determine whether two agents will collide within a given amount of time.

Obstacle avoidance, on the other hand, approximates sandbox objects using spheres and uses the agent's predictive movement to create a steering force tangent for the potential collision.

Collision avoidance

To calculate the force to avoid other agents, based on the minimum time, to collide with other agents, we can use the ForceToAvoidAgents function.

local avoidAgentForce = 
    agent:ForceToAvoidAgents(minTimeToCollision);

Obstacle avoidance

A similar force to avoid other dynamic moving obstacles can be calculated using the ForceToAvoidObjects function.

local avoidObjectForce =     
    agent:ForceToAvoidObjects...
Left arrow icon Right arrow icon

Description

If you are a game developer or a general programmer who wishes to focus on programming systems and techniques to build your game AI without creating low-level interfaces in a game engine, then this book is for you. Knowledge of C++ will come in handy to debug the entirety of the AI sandbox and expand on the features present within the book, but it is not required.

What you will learn

  • Create an animation state machine to drive AI animations within Lua
  • Build and find paths on navigation meshes
  • Write and debug Lua scripts within a fullscale Lua IDE
  • Develop decision logic with behavior trees, state machines, and decision trees to build modular, reusable AI
  • Manage short and longterm knowledge representation with blackboard data structures
  • Add sensory perception to give AIs the ability to see and hear
  • Develop highlevel tactics with multiple AIs based on influence maps
Estimated delivery fee Deliver to Portugal

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 28, 2014
Length: 352 pages
Edition : 1st
Language : English
ISBN-13 : 9781783281336
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Portugal

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Nov 28, 2014
Length: 352 pages
Edition : 1st
Language : English
ISBN-13 : 9781783281336
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
L÷VE for Lua Game Programming
€24.99
Learning game AI programming with Lua
€36.99
Lua Game Development Cookbook
€41.99
Total 103.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Getting Started with AI Sandbox Chevron down icon Chevron up icon
2. Creating and Moving Agents Chevron down icon Chevron up icon
3. Character Animations Chevron down icon Chevron up icon
4. Mind Body Control Chevron down icon Chevron up icon
5. Navigation Chevron down icon Chevron up icon
6. Decision Making Chevron down icon Chevron up icon
7. Knowledge Representation Chevron down icon Chevron up icon
8. Perception Chevron down icon Chevron up icon
9. Tactics Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(3 Ratings)
5 star 33.3%
4 star 66.7%
3 star 0%
2 star 0%
1 star 0%
Jimmy franco Dec 10, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is amazing , I recomend that you buy it and buy as a gift for all ur friends it's so informational and I must say I enjoyed reading it .
Amazon Verified review Amazon
CPallini Dec 24, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The book uses Lua scripting for implementing AI on a 3D game.Lua executes in a C++ framework (the sandbox) on the top of open source libraries like Ogre3D.Pros: - Lua scripting in a C++ framework is a very happy choice. - Focus is on practical AI. - The sandbox C++ code looks solid and is full accessible. - The companion code works out of the box.Cons: - In my opinion, the code/text ratio in the book is too high, more explanations would have been welcomed. To sum up, this is a good book, backed up by solid code (and good open source libraries) and you can actually script AI in a 3D game. Please note, in order to enjoy the book, you have to download the companion source code.
Amazon Verified review Amazon
Mr. Gibbins Jul 22, 2019
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is informative but hard to get you're head around unless you run lua on in c++ environment, if like me you don't have access to the c++ environment because the game engine doesn't allow you access then it's quite hard to figure out how to use the I formation provided with the system they use.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela