Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Learn Advanced Python by Building Games: LLMs and LangChain
Rating: 5.0 out of 5(3 ratings)
46 students

Learn Advanced Python by Building Games: LLMs and LangChain

From prompts to agents: use LangChain, RAG, and function calling to build smart, competitive game NPCs.
Created bySachin Kafle
Last updated 11/2025
English
English [Auto],

What you'll learn

  • Design and code AI NPCs that use LangChain chains/tools for dialogue, hints, and quest logic
  • Learn OpenAI Function Calling to let LLMs trigger in-game actions
  • Implement semantic retrieval (RAG) for lore, quest text, and item descriptions; store and query embeddings to drive context-aware NPC responses.
  • Learn to create tool wrappers and expose them to the LLM via LangChain with proper schemas and validation.
  • Learn to build sequential and parallel chains using LangChain’s Runnable interfaces, combining LLM calls, tools, and post-processing.
  • Create reusable PromptTemplate / ChatPromptTemplate with variables, few-shot examples, and output schemas
  • Implement structured output (pydantic/JSON schema) and validate LLM responses inside chains.
  • Implement end-to-end RAG pipelines: document loaders → chunking strategies → embeddings → retrievers → answer synthesis.
  • Build tool-using agents (ReAct/Function Calling) with Tool/AgentExecutor to safely invoke game or app functions.

Course content

12 sections • 71 lectures • 7h 43m total length
  • Introduction3:31

    Learn how large language models power adaptive games by connecting prompts, memory, reasoning, tools, retrieval augmented generation, and OpenAI function calling to create AI agents that think, act, and interact.

Requirements

  • Beginner Python skills: variables, lists/dicts, functions, installing packages (pip)
  • OpenAI account + API access: ability to create an API key and add a $5 prepaid top-up (typical practice runs in this course stay within that).

Description

In this project-based course, you'll use LangChain and the OpenAI API to transform game ideas into intelligent, interactive experiences. We'll begin by establishing the fundamentals that make LLM systems predictable and cost-effective: prompt templates that separate content from structure, chains that combine multiple steps into reliable workflows, callbacks for tracing and telemetry, and memory strategies that keep context tight without increasing token costs.

Once these building blocks are ready, you'll move on to RAG (Retrieval-Augmented Generation), enabling NPCs to answer questions and make decisions based on your own game lore and documents. You'll also create agents that safely call in-game tools through validated, schema-driven function calls and strict allowlists. Throughout the course, you'll instrument your code, test behaviors deterministically, and implement guardrails to ensure outputs stay on policy. The course concludes with two platformer mini-games in which an agent and NPCs compete, adapting strategies using memory and retrieval to outplay each other. By the end, you'll have a reusable toolkit—prompts, chains, memory, RAG, and agents, along with portfolio-ready demos you can extend or deploy.

What you'll build & learn

  • OpenAI API fundamentals: streaming, reliable JSON/structured outputs, and function (tool) calling.

  • LangChain I/O & prompts: PromptTemplate, ChatPromptTemplate, few-shot patterns, and output validation.

  • Chains: sequential and router chains, batching/streaming, retries, and cost/latency tuning.

  • Callbacks & tracing: observe runs end-to-end and debug model/tool behavior with clear telemetry.

  • Memory: buffer, summary, and vector-backed memory with persistence, TTLs, and guardrails.

  • RAG: loaders → chunking → embeddings → retrievers → grounded answers with citations and filters.

  • Agents: ReAct/function-calling agents with strict schemas, allowlists, timeouts, and safeguards.

  • Games: two AI platformers where agent/NPC strategies evolve based on retrieved knowledge and remembered context.

You'll finish with practical, production-shaped patterns you can reuse in games, chat assistants, or any interactive LLM application.

Who this course is for:

  • Beginner to intermediate Python learners who want a practical entry into AI—building real, interactive projects instead of just calling a single API.
  • Students & career switchers in CS/IT who prefer hands-on projects to understand chains, prompt templates, memory, and retrieval.
  • Aspiring or indie game developers who want to add intelligent NPC dialogue, dynamic quests, and data-driven behaviors using LangChain and OpenAI function calling.