
Learn to install Anaconda on Windows, create a Python 3.6 virtual environment for AI games, and launch Spyder to write and run a simple hello world program.
Explore how genetic algorithms imitate darwinian natural selection and follow a six-step plan, covering DNA, fitness function, population selection, crossover, and mutation.
Explore the DNA of genetic algorithms, a sequence of moves or behaviors that defines how a bot navigates a maze, with DNA length as a configurable parameter.
Learn how the fitness function measures how close a bot lands to the finish line using x and y distances and the Pythagorean theorem; lower fitness means better progress.
Explains how a population of bots with unique DNA and fitness drives genetic algorithms, highlighting population size and the concept of the first, random population.
Selection chooses the top bots by fitness from the current population to form a new generation, sometimes using a fixed count or percentage, while discarding the rest.
Explore the crossover by selecting two parent bots, combine their DNA to create offspring, and build a new population while keeping the population size constant.
Apply complete or partial mutations to a population of bots to explore new possibilities beyond crossover. Maintain a constant population size while evaluating fitness and repeating selection, crossover, and mutation.
Explore how the lecture introduces the traveling salesman problem and uses genetic algorithms within a planet-filled universe, detailing environment and solution files and a Pygame-based workflow.
Import the Dombi library and the environment class from environments to access the game's behavior and display information.
Create a route class to model a bot population with dna as a sequence of planets and fitness as the total distance traveled. Target the shortest route visiting each planet.
Initialize the random dna for new bots by selecting unique genes from 1 to dna length minus one, avoiding repetition, and append zero to complete the sequence.
Explore genetic algorithms by building a crossover method that mixes two parent DNAs into a unique offspring, ensuring each gene appears once while selectively inheriting from the second parent.
Learn how random partial mutations diversify offspring after crossover by mutating a single DNA index, avoiding duplicates, and implementing this in a Python loop with a 10% mutation rate.
Learn the second partial mutation on a DNA sequence by selecting an index, inserting RNA at i, adjusting prior positions, and handling edge cases with a 10 percent mutation chance.
Define genetic algorithm parameters: population size 50, mutation rate 10 percent, and selection of five; set DNA length to planet count and initialize an empty population.
Create the first random population by filling a population list with root objects using a DNA length. Append each new root to the population until it reaches the population size.
Define a main loop to evaluate the population, perform selection, crossover, and mutation, and track generation and the best distance, starting from infinity and incrementing each iteration.
Evaluate the population by computing each route's fitness as the total distance traveled, resetting the environment for every route, and summing distances over the DNA sequence.
Sort the population with Python's sorted by distance as the fitness measure, then clear and refill with the best bots, updating the best distance if a shorter path is found.
Copy the best previous bots to the new population to preserve their genes and prevent losing DNA in crossover. Reset their distance to zero and append to the new population.
Fill the population to its size by adding complete mutants or offspring from two parents, guided by mutation rate and random selection with DNA-based creation.
Display the best route found by the bot using its DNA, and show generation number. Also present the shortest distance found so far, formatted to two decimals.
Run the genetic algorithm for a traveling salesman game by setting up a virtual environment, installing pygame and nonpoint, and launching the code to observe a shortest route optimization.
Outline the plan of attack for reinforcement learning, explaining the Bellman equation, states and actions values, temporal difference, and how policies relate to plans, with a visualization of key learning.
Learn how reinforcement learning trains an agent to act within an environment by taking actions, observing state changes, and receiving rewards to optimize future outcomes.
Explore the Bellman equation in reinforcement learning by defining states, actions, rewards, and gamma, and show how maximizing action values guides maze navigation toward the finish.
This lecture turns state values from the Bellman equation into arrows, creating a treasure-map plan that guides the agent through maze; it contrasts plans with policies in a stochastic environment.
Explore Markov decision processes and the difference between deterministic and non-deterministic search in game environments. Learn how the Bellman equation extends to expected values under randomness to guide decision making.
Explore q-learning intuition on how policy differs from plan in stochastic search, and apply the Bellman equation to evaluate state values under randomness and discounting.
Explore how a living penalty reshapes Q-learning policies by introducing a negative per-step reward, altering the Bellman equation, and guiding agents toward quicker finishes.
Explore Q-learning intuition: define Q values for actions, link to V values via the Bellman equation, and learn optimal actions in Markov decision processes with rewards and discounting.
Explore how temporal difference updates refine Q-values in stochastic environments, linking the Bellman equation with rewards, states, actions, gamma, and learning rate alpha for gradual convergence.
Watch a Q-learning agent navigate a grid world maze, learn policy and Q-values through exploration, and visualize how values converge to guide decisions.
Learn how to build a three by four maze environment, set start and finish lines, and apply Q-learning to solve it in this introduction to artificial intelligence for simple games.
Import two libraries and the environment class to initialize the project for simple games, using imports from the environments file to prepare the runtime environment.
Define the gamma discount factor and alpha learning rate for a q-learning loop, and set epochs to 1000 to guide the temporal-difference updates of state-action values.
Initialize the environment and the q-table to hold rewards for each state-action pair, and see how current and next states map to moves, rewards, and unavailable actions.
Learn how to prepare the Q-learning process in a maze: start from random non-wall positions, take actions, update Q-values with rewards, and repeat to learn optimal paths to the finish.
Develop a function to locate the maximum Q value and its index across states, enabling the temporal-difference update and subsequent policy testing in the Q-learning process.
Initiate the q-learning loop for simple games by selecting a random starting state, taking a random action, receiving rewards, and updating q-values across epochs.
Identify all playable actions from the starting position by iterating over cells, using the rewards table to determine move validity, and populate the possible actions list.
Select a random action from the possible auctions using random choice, obtain the reward from the rewards array, and set up the next step in q-learning.
Update the Q-value via temporal difference by computing reward, gamma, and the maximum next-state Q value, then adjust the current Q-table entry for the start state and action.
Demonstrate a Q-learning loop that initializes the current position from the starting position, selects actions with maximum Q-value, moves the agent in the environment Arnav, and updates the current position.
Run the code, test coloring and pathfinding with a simple maze using numpy and pygame, adjust epochs and Q-learning parameters to reveal the best route and understand rewards.
Explore deep q learning by separating the learning and acting components, learn how neural networks update weights, and examine experience replay and action selection policies for exploration and exploitation.
This lecture explains deep Q-learning by feeding state vectors x1, x2 into a neural network to predict action values, compare them to past targets, and update weights via backpropagation.
Learn deep Q-learning intuition: the network updates weights through learning, then acts by selecting actions via softmax from fixed key values, using a state vector to encode the environment.
Explore how deep Q-learning uses experience replay to stabilize learning. Store state, action, next state, and reward experiences; sample batches uniformly; break data correlations; learn from rare events.
Examine action selection policies for deep q-learning, including epsilon-greedy, epsilon-soft, and softmax. Learn how to balance exploration and exploitation as the agent uses q-values to pick actions.
Step 1 introduces deep learning on mountain car from Gym, detailing observations (position, velocity), actions (left, stay, right), and a -1 reward per step until the goal, with 200-step termination.
Import and set up Carus neural network library, build a sequential model with Dense layers, and apply the Adam optimizer to perform back propagation algorithm and update weights and biases.
Define a brain class in python to encapsulate the neural network and its parameters, implement __init__(self, num_inputs, num_outputs, learning_rate), and store them as instance variables.
Create a neural network using a sequential model, add dense layers with relu activations, define input shape and output units, and compile with adam and mean squared error loss.
Initialize the DQN experience replay memory to store past experiences and sample random records for training, and define a DeQuan class with memory size and discount factor.
This lecture defines an experience as current state, action, reward, next state, and game over, and explains remember builds memory and discards oldest entries when memory reaches max size.
Form input batches from randomly selected experiences in the replay memory, and set targets as the expected q-values for each action.
Initialize zero-filled input and target batches with the correct shape for the dqn memory step. Draw current states from memory for inputs and use the network's predicted values for targets.
Explore extracting transitions for DQN memory by sampling random indices from memory and retrieving current state, action, reward, next state, and game over flag using NumPy.
Add the current state to inputs and update targets via Q-learning: if game over, set to reward; otherwise set to reward plus gamma times max Q of next state.
Import libraries for training the AI on the mountain car problem, including the DeQuan experience replay memory, brain neural network, gym environments, and matplotlib plotting.
Set up key training parameters for a neural network agent, including learning rate, memory size, replay memory, gamma, batch size, and epsilon-greedy policy with decay.
initialize the mountain car environment with two observations and three actions, build a brain with two inputs and three outputs plus a learning rate, and set DeQuan memory with gamma.
Initialize the main training loop, set epoch to zero, create current and next state arrays with one row and two columns for car position and speed, and initialize rewards.
Reset the environment and current and next states, then run a while loop to take actions, update the environment, and train the ai while the game is not over.
Use an epsilon-greedy policy to select actions: with probability epsilon take a random action, else pick the highest predicted q value from the neural network for the current state.
Update the game environment by calling the environment's step method with the chosen action, obtain the next state and reward, check game over, and accumulate total reward.
Remember new experience by adding a transition to the experience replay memory; train the model on inputs and targets from get batch, then update current state to next state.
Lower the epsilon through decay to favor learned actions, log epoch, epsilon, and total rewards in the console, and plot rewards over time with Matplotlib.
Explore the intuition behind deep convolutional Q-learning, its power, and why it builds on deep learning. Learn how eligibility traces and convolutional networks process images as inputs.
Explore deep convolutional Q-learning, converting state vectors into image-based inputs processed by convolutional neural networks. Learn to build agents that see, interpret pixels, and act in complex environments like Doom.
Discover how eligibility traces enhance deep Q-learning by evaluating multi-step outcomes, tracing eligibility across actions, and contrasting temporal-difference and Monte Carlo approaches in reinforcement learning.
Explore step-by-step how to build a deep reinforcement learning agent for the classic snake game using convolutional q learning, defining states, actions, and rewards from the environment.
Import the machine learning library and build a CNN with a sequential model by adding convolutional, pooling, flatten, and dense layers, plus loading a saved model and configuring the optimizer.
Designs a brain class that encapsulates a convolutional neural network, with input shape for stacked game frames, a learning rate, and outputs for four actions (up, down, left, right).
Build a convolutional neural network to play snake by initializing a sequential model, adding layers for convolution, pooling, flattening, dense, and compiling with Adam and mean squared error.
learn to build a load_model function that loads a pre-trained neural network from a file path using the model method, returning the trained brain for testing the game AI.
Build the experience replay memory for a DQN by adapting the multicar example code to the snake game, changing inputs to a three-dimensional current state and managing transitions.
Import the environment class, brain class with a convolutional neural network and load model method, and the DeQuan memory class, then bring in numpy and matplotlib.pyplot to visualize training performance.
Define parameters for a convolutional learning model: memory 60000, gamma 0.9, batch size 32, last states 4, an epsilon-greedy policy starting at 1 with decay to 0.5, saved to .h5.
Initialize the environment, brain, and DQN, define the input shape from frame width, height, and stacked frames, set learning rate and gamma, and build the experience replay memory.
Build a Python function to reset the current state and next state in a snake game, using numpy.zeros to initialize a four-dimensional state with the initial frame.
This step initializes the epoch counter, runs an infinite loop to restart the game, trains the AI to play, tracks apples eaten across 100 games, and displays performance graphs.
Reset the environment by initializing the environment object and resetting current and next states to the initial frame. Run a while loop until game over to train the AI.
Apply an epsilon-greedy training step to select actions in a four-action game: with probability epsilon pick a random action, otherwise choose highest q-value from the model for the current state.
Update environment by calling step with the action to obtain the frame, reward, and game-over status. Reshape the frame to a 4D array, append to next_state, and drop oldest frame.
Remember new experiences by storing transitions (current state, action, reward, next state, game over) in replay memory, then sample inputs and targets (Q values) to train the convolutional neural network.
Check the collected variable to see if an apple was eaten and update the score accordingly. Then assign the current state to the next state after updating the environment.
Update epsilon by subtracting epsilon's rate, clamp it with min epsilon, and save the model only when apples eaten in a round beats the record and is greater than two.
Learn how to display training results for a simple game as you track apples eaten over 100 games, compute the average per game, and plot scores over time.
Learn to test a trained AI by loading a saved neural network model in a test file, importing the game environment and brain module, and evaluating performance.
Define testing parameters for ai: set wait time to 75 milliseconds, align last states frames with the trained input, and specify the model file path to test.
Initialize the environment and brain objects, set the wait time and input shapes, then load a convolutional neural network from a file path for testing.
Develop a function to reset current and next game states, reuse a reset states routine, and launch a perpetual main loop to continuously test the AI by playing the game.
Reset the game environment, initialize current and next states, and use a game over flag to loop the AI action and environment updates until the game ends.
Selects the best action by feeding the current game state into the neural network, retrieving Q-values, and choosing the highest value index.
Call the environment step with the action to get the new frame and game_over. Update next state by reshaping the frame, adding it, dropping the oldest to keep four.
run and evaluate a convolutional neural network that plays snake using Keras, Pygame, and Matplotlib. train from scratch or test a pretrained model (model.h5) in a virtual environment.
Ever wish you could harness the power of Deep Learning and Machine Learning to craft intelligent bots built for gaming?
If you’re looking for a creative way to dive into Artificial Intelligence, then ‘Artificial Intelligence for Simple Games’ is your key to building lasting knowledge.
Learn and test your AI knowledge of fundamental DL and ML algorithms using the fun and flexible environment of simple games such as Snake, the Travelling Salesman problem, mazes and more.
1. Whether you’re an absolute beginner or seasoned Machine Learning expert, this course provides a solid foundation of the basic and advanced concepts you need to build AI within a gaming environment and beyond.
2. Key algorithms and concepts covered in this course include: Genetic Algorithms, Q-Learning, Deep Q-Learning with both Artificial Neural Networks and Convolutional Neural Networks.
3. Dive into SuperDataScience’s much-loved, interactive learning environment designed to build knowledge and intuition gradually with practical, yet challenging case studies.
4. Code flexibility means that students will be able to experiment with different game scenarios and easily apply their learning to business problems outside of the gaming industry.
‘AI for Simple Games’ Curriculum
Section #1 — Dive into Genetic Algorithms by applying the famous Travelling Salesman Problem to an intergalactic game. The challenge will be to build a spaceship that travels across all planets in the shortest time possible!
Section #2 — Learn the foundations of the model-free reinforcement learning algorithm, Q-Learning. Develop intuition and visualization skills, and try your hand at building a custom maze and design an AI able to find its way out.
Section #3 — Go deep with Deep Q-Learning. Explore the fantastic world of Neural Networks using the OpenAI Gym development environment and learn how to build AIs for many other simple games!
Section #4 — Finish off the course by building your very own version of the classic game, Snake! Here you’ll utilize Convolutional Neural Networks by building an AI that mimics the same behavior we see when playing Snake.