{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Copy of FINAL Template_for CIS521_midterm notes.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "brNDGX-kvzds"
      },
      "source": [
        "# Template for Notes for CIS 521 Midterm 1\n",
        "\n",
        "The midterm exam for CIS 521 will be **open notes**. No other matierals are allowed for the exam - you may not use the textbook, the internet, a Python envionement, or communicate with anyone during the exam. \n",
        "\n",
        "This python notebook is where you should save all of your notes.  It provides a structured template that allows you to add summaries for each of the textbook sections that are part of the required reading, plus room for lecture notes and definitions.\n",
        "\n",
        "Your summaries must be written in your own words.  Do not copy and paste from the textbook.  Do not share your notes with classmates, or copy any of your classmates' notes.  "
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "aPtM8g7R0Pds"
      },
      "source": [
        "# Instructions\n",
        "\n",
        "1. Make a copy of this Google Colab file. From the colab menu, pick **File > Save a copy in Drive**.  That will save a copy of this notebook in your Google drive.\n",
        "2. Go through each section of the notebook, and fill in all the summaries for each chapter and its corresponding sections.  Be sure to save your work frequently!\n",
        "3. Read the notes below about how you can format your summaries.\n",
        "4. In addition to these notes, you are allowed 1 page (both sides) for figures or handwritten notes.\n",
        "5. Submit your version of this notebook to Gradescope before you start the exam.\n",
        "6. If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print: \n",
        "* Run the last cell of this notebook\n",
        "* Click the \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n",
        "\n",
        "## Formatting Notes\n",
        "\n",
        "1. The max length for each section's summary is 500 words / 3000 characters.\n",
        "2. You can also write a 2000 word summary of the lectures for each module.\n",
        "3. You may also write definitions of concepts for each module.  The definitions should be written in your own words (not copy and pasted), and they should be no more than 20 words long for each concept. \n",
        "2. You can use Markdown formatting for your summaries. \n",
        "3. You can use Latex formatting for equations. Put two dollar signs before and after your equation like this: \n",
        "$$ \\epsilon = \\frac{1}{mc^2} $$\n",
        "4. When you write python code or psuedocode algorithms, you should surround it with triple backticks like this:\n",
        "```\n",
        "def function():\n",
        "      print('hello world')\n",
        "```\n",
        "5. Write \\ whenever you want to keep writing on the next line without a newline being inserted."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cw5IpDLCZa4W"
      },
      "source": [
        "## Example summary\n",
        "\n",
        "This is a sample summary of [Section 2.1.1](https://web.stanford.edu/~jurafsky/slp3/2.pdf ) of Jurfasky and Martin's Speech and Language Processing's book\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lzaavW96tcxM",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "7c5cdea4-fab7-49d0-daab-45049c3068af"
      },
      "source": [
        "chapter_2_1_example = \"\"\"\n",
        "Regular expressions are an algebraic notation for characterizing \\\n",
        "a set of strings that are useful for searching for a pattern or through a corpus.\\\n",
        "Only the first matching result will be shown. The search string is case sensitive, \\\n",
        "but it can consist of a single character or a sequence of characters. \\\n",
        "While square braces specify a disjunction of characters, the dash can more easily look \\\n",
        "for characters over a range. The caret specifies the non-existence of a character. \\\n",
        "Additionally, the (?) is used to for flexibility on a single character, meaning \\\n",
        "\"the preceding character or nothing\". More importantly, the Kleene star means zero or \\\n",
        "more occurrences of the immediately previous character or regular expression in square braces.\\\n",
        "...\n",
        "\"\"\"\n",
        "\n",
        "length = len(chapter_2_1_example.split(\" \"))\n",
        "print(\"The example summary is {len} words long, so you could write an additional \\\n",
        "{remaining} words.\".format(len=length, remaining=(500-length)))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The example summary is 116 words long, so you could write an additional 384 words.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "s3Uk9gQTevcj"
      },
      "source": [
        "## Example summary length\n",
        "\n",
        "The maximum summary length for each section is 500 words / 3000 characters.  Hopefully you'll find that to be quite generous. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8DvZ57A-djo1",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "0fba2813-5f70-45b4-a740-0e496effad3c"
      },
      "source": [
        "# This is an example of a 500 word placeholder\n",
        "placeholder = \"\"\"ultrices vitae auctor eu augue ut lectus arcu bibendum at varius \\\n",
        " vel pharetra vel turpis nunc eget lorem dolor sed viverra ipsum nunc aliquet \\\n",
        " bibendum enim facilisis gravida neque convallis a cras semper auctor neque vitae \\\n",
        " tempus quam pellentesque nec nam aliquam sem et tortor consequat id porta nibh \\\n",
        " venenatis cras sed felis eget velit aliquet sagittis id consectetur purus ut \\\n",
        " faucibus pulvinar elementum integer enim neque volutpat ac tincidunt vitae semper \\ \n",
        " quis lectus nulla at volutpat diam ut venenatis tellus in metus vulputate eu \\\n",
        " scelerisque felis imperdiet proin fermentum leo vel orci porta non pulvinar neque \\ \n",
        " laoreet suspendisse interdum consectetur libero id faucibus nisl tincidunt eget \\\n",
        " nullam non nisi est sit amet facilisis magna etiam tempor orci eu lobortis \\\n",
        " elementum nibh tellus molestie nunc non blandit massa enim nec dui nunc mattis \\\n",
        " enim ut tellus elementum sagittis vitae et leo duis ut diam quam nulla porttitor \\\n",
        " massa id neque aliquam vestibulum morbi blandit cursus risus at ultrices mi tempus \\\n",
        " imperdiet nulla malesuada pellentesque elit eget gravida cum sociis natoque \\\n",
        " penatibus et magnis dis parturient montes nascetur ridiculus mus mauris vitae \\\n",
        " ultricies leo integer malesuada nunc vel risus commodo viverra maecenas accumsan \\\n",
        " lacus vel facilisis volutpat est velit egestas dui id ornare arcu odio ut sem nulla \\\n",
        " pharetra diam sit amet nisl suscipit adipiscing bibendum est ultricies integer \\\n",
        " quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet massa \\\n",
        " tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc \\\n",
        " consequat interdum varius sit amet mattis vulputate enim nulla aliquet porttitor \\\n",
        " lacus luctus accumsan tortor posuere ac ut consequat semper viverra nam libero \\\n",
        " justo laoreet sit amet cursus sit amet dictum sit amet justo donec enim diam \\\n",
        " vulputate ut pharetra sit amet aliquam id diam maecenas ultricies mi eget mauris \\\n",
        " pharetra et ultrices neque ornare aenean euismod elementum nisi quis eleifend quam \\\n",
        " adipiscing vitae proin sagittis nisl rhoncus mattis rhoncus urna neque viverra justo \\\n",
        " nec ultrices dui sapien eget mi proin sed libero enim sed faucibus turpis in \\\n",
        " eu mi bibendum neque egestas congue quisque egestas diam in arcu cursus euismod \\\n",
        " quis viverra nibh cras pulvinar mattis nunc sed blandit libero volutpat sed cras \\\n",
        " ornare arcu dui vivamus arcu felis bibendum ut tristique et egestas quis ipsum \\\n",
        " suspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque \\\n",
        " dignissim enim sit amet venenatis urna cursus eget nunc scelerisque viverra mauris \\\n",
        " in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in \\\n",
        " pellentesque massa placerat duis ultricies lacus sed turpis tincidunt id aliquet \\\n",
        " risus feugiat in ante metus dictum at tempor commodo ullamcorper a lacus vestibulum \\\n",
        " sed arcu non odio euismod lacinia at quis risus sed vulputate odio ut enim blandit \\\n",
        " volutpat maecenas volutpat blandit aliquam etiam erat velit scelerisque in \\\n",
        " dictum non consectetur a erat nam at lectus urna\"\"\"\n",
        "\n",
        "print(\"The length in words is\", len(placeholder.split(' ')))\n",
        "print(\"The length in characters is\", len(placeholder))"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The length in words is 500\n",
            "The length in characters is 3030\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "5yG3-YncJfTB"
      },
      "source": [
        "# Permissions to use your summaries\n",
        "\n",
        "We'd like to use your summaries to help develop better educational resources like [remember.school](https://remember.school) or a question-answering system about the textbook.  \n",
        "\n",
        "1. Please enter your name.  \n",
        "\n",
        "2. If you grant permission for us to use your summaries under a [Creative Commons License](https://creativecommons.org/licenses/by/4.0/), please set ```permission = True```.  If you do not grant permission, please set it to false. Your answer won't affect your grade.\n",
        "\n",
        "3. If you grant us permission, and you'd like to remain anonymous, set ```anonymous = True```.  We'll remove your name before sharing your summaries with anyone. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2RECnJArJew4"
      },
      "source": [
        "name = \"\"\n",
        "permission = True\n",
        "anonymous = True"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GZZXyrV-xuAp"
      },
      "source": [
        "# Module 1 - Intro to AI"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Y2NfE1CKxzS-"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, Chapter 1 “Introduction”, Section 1.1 “What is AI”\n",
        "\n",
        "if not('chapter1_1' in locals()):\n",
        "  chapter1_1 = \"\"\n",
        "chapter1_1 = \"\"\" A Computer Agent Should:\n",
        "- operate autonomously\n",
        "- have percepts\n",
        "- exist for a period of time\n",
        "- adapt to a changing environment\n",
        "- create & pursue goals\n",
        "\n",
        "The goal of an agent isn't to mimmic human behaviour, but to act rationally. Rationality is mathematically defined, whereas human \n",
        "behaviour may not always be rational, and is much harder to represent.\n",
        "\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter1_1.split(\" \"))} words'\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 27 “Philosophical Foundations”, Sections 27.1 “The Limits of AI” and 27.2 “Can Machines Really Think?”\n",
        "chapter27_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter27_2 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Russell and Norvig, AIMA 4th Edition, Chapter 2 “Intelligent Agents” (whole chapter)\n",
        "if not('chapter2_1' in locals()):\n",
        "  chapter2_1 = \"\"\n",
        "chapter2_1 = \"\"\" An agents action can be decided based on its percept sequence and current percepts, however not on future information it hasn't yet received\n",
        "\n",
        "The agent function is an abstract mathematical concept, whereas the agent program is a concrete implementation, such as compiled code which executes \n",
        "the agent function.\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter2_1.split(\" \"))} words'\n",
        "\n",
        "if not('chapter2_2' in locals()):\n",
        "  chapter2_2 = \"\"\n",
        "chapter2_2 = \"\"\" When designing a performance measure it is better to base it off of the goal within the environment as opposed to how the\n",
        "computer should behave.\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter2_2.split(\" \"))} words'\n",
        "\n",
        "if not('chapter2_3' in locals()):\n",
        "  chapter2_3 = \"\"\n",
        "chapter2_3 = \"\"\" A Task Environment is Described By:\n",
        "- Performance Measure, Environment, Actuators & Sensors\n",
        "- the task environment is the problem that the computer attempts to solve\n",
        "\n",
        "Fully vs. Partially Observable:\n",
        "- fully = sensors provide <u><b>all relevant</b></u> info. about the environment, where partial only provides some or environment is non-deterministic\n",
        "- partially observable is more challenging because the agent has to maintain state information about the env.\n",
        "\n",
        "Stochastic is not exactly equal to Non-Deterministic, stochastic explicitly implies probabilities\n",
        "\n",
        "Episodic vs. Sequential:\n",
        "- in episodic, the agent takes in info. and makes desicion and decision do not depend on previous actions, whereas sequential does\n",
        "\n",
        "Static vs. Dynamic:\n",
        "- dynamic can be similar to non-deterministic, but is when the environment changes during the computers turn, when it is deciding\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter2_3.split(\" \"))} words'\n",
        "\n",
        "if not('chapter2_4' in locals()):\n",
        "  chapter2_4 = \"\"\n",
        "chapter2_4 = \"\"\" For simple reflex agents, the <u><b>condition-action rule</b></u> is like an if->else for controlling actions flow\n",
        "\n",
        "Random actions may be beneficial for simple reflex agents as it can help them escape from infinite loops.\n",
        "\n",
        "Model based agents utilize a transition model and sensor model to keep track of the partially observable part of the environment it cannot currently see\n",
        "\n",
        "A goal based agent considers states that are desireable\n",
        "\n",
        "Utility based agents use a utility function to provide a measure of how good states are\n",
        "- good when there are conflicting goals\n",
        "- when there are multiple goals but they all may not be reachable, expected utility takes into account the probability\n",
        "\n",
        "Learning based agents take into account a learning element which provides feedback on how well the agent is doing. Based on this the agent can\n",
        "adjust its model.\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter2_4.split(\" \"))} words'\n",
        "\n",
        "# Lecture notes \n",
        "if not('module1_lecture_notes' in locals()):\n",
        "  module1_lecture_notes = \"\"\n",
        "module1_lecture_notes = \"\"\" When something can have it's own performance measure it should be considered an agent in the problem\n",
        "\n",
        "Environment for problems we attempt to solve in class:\n",
        "- Static, Fully Observable, Deterministic, Discrete\n",
        "- think chess game... the board does not change during an agent's turn, the entire board is visible, each move is 100% executed and discrete\n",
        "\n",
        " \"\"\"+ f'\\n\\nlength = {len(module1_lecture_notes.split(\" \"))} words'\n",
        "\n",
        "\n",
        "# Definitions of concepts from Module 1.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module1_definitions = {\n",
        "\"agent\" : \"anything that can perceive it's environment and act on it's environment\",\n",
        "\"agent function\" : \"maps a specific percept sequence to a resulting action\",\n",
        "\"agent program\" : \"the concrete implementation of the agent function\",\n",
        "\"agent architecture\" : \"physical hardware and sensors the agent uses\",\n",
        "\"percept\" : \"information gathered about the environment from sensor(s)\",\n",
        "\"percept sequence\" : \"list of all the percepts an agent has gathered in history\",\n",
        "\"rational agent\" : \" makes actions which maximize the outcome or the expected outcome. can include randome decisions in game theory!\",\n",
        "\"rationality\" : \"doing the <i>right</i> thing\",\n",
        "\"Turing Test\" : \"thought experiment designed to discriminate between human and computer, passed if human cannot tell the difference in responses to qs\",\n",
        "\"value alignment problem\" : \"the balance of designing to meet our <u><b>true</b></u> goal vs. the object we program a machine to reach \",\n",
        "\"simple reflex agent\" : \"makes decisions based solely off of current precept, no history\",\n",
        "\"transition model\" : \"models the effects of the agents actions\",\n",
        "\"sensor model\" : \"models how the state of the world is reflected in the sensor information received by the agent\",\n",
        "}\n",
        "\n"
      ],
      "execution_count": 21,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "elCCgY64spuq"
      },
      "source": [
        "## Preview of your notes for Module 1\n",
        "\n",
        "Here's a preview of your how your notes will be displayed.  At the end of this Python notebook, we'll aggregate your notes for all modules together into a single display.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "gYYeNcdM_maE",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "cellView": "form",
        "outputId": "a8d8904d-1aa6-42a1-80d6-9768f3d40c7a"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "from IPython.display import display, Markdown, Latex\n",
        "\n",
        "module1_sections = [\n",
        "  (\"AIMA Chapter 1.1 What is AI?\", chapter1_1),\n",
        "  (\"AIMA Chapter 27.1 The Limits of AI\", chapter27_1),\n",
        "  (\"AIMA Chapter 27.1 Can Machines Really Think?\", chapter27_2),\n",
        "  (\"AIMA 2.1 Agents and Environments\", chapter2_1),\n",
        "  (\"AIMA 2.2 Good Behavior: The Concept of Rationality\", chapter2_2),\n",
        "  (\"AIMA 2.3 The Nature of Environments\", chapter2_3),\n",
        "  (\"AIMA 2.4 The Structure of Agents\", chapter2_4),\n",
        "  (\"Module 1 Lecture Notes\", module1_lecture_notes),\n",
        "]\n",
        "\n",
        "\n",
        "def length_check(sections):\n",
        "  warnings = \"\"\n",
        "  for section, summary in sections:\n",
        "    max_word_length = 500\n",
        "    max_character_length = 3000\n",
        "    if \"lecture\" in section.lower():\n",
        "      # It's OK to do longer summaries of the lectures\n",
        "      max_word_length = 2000\n",
        "      max_character_length = 12000  \n",
        "    if (len(summary) > max_character_length or len(summary.split(' ')) > max_word_length):\n",
        "      warnings += \"WARNING: Your summary of '{section}' is too long!\\n\".format(section=section)\n",
        "  return warnings\n",
        "\n",
        "def length_check_definitions(definitions):\n",
        "  warnings = \"\"\n",
        "  for concept, definition in definitions.items():\n",
        "    if(len(definition.split(' ')) > 20):\n",
        "      warnings += \"WARNING: Your definition of '{concept}' is too long!\\n\".format(concept=concept)\n",
        "  return warnings\n",
        "\n",
        "\n",
        "def format_module(module_num, title, sections, definitions, show_placeholder=False):\n",
        "  markdown = \"\"\n",
        "\n",
        "  # Check summary lengths\n",
        "  warnings = length_check(sections)\n",
        "  if warnings != \"\":\n",
        "    markdown += \"## \" + warnings\n",
        "\n",
        "  # Check definition lengths\n",
        "  warnings = length_check_definitions(definitions)\n",
        "  if warnings != \"\":\n",
        "    markdown += \"## \" + warnings\n",
        "\n",
        "  markdown += \"# Module {num}: {title}\\n\".format(num=module_num, title=title)\n",
        "\n",
        "\n",
        "  for section, summary in sections:\n",
        "    if show_placeholder and summary == \" Your summary here \":\n",
        "      summary = placeholder\n",
        "    markdown += \"## {section}\\n{summary}\\n\\n\".format(section=section, summary=summary)\n",
        "  \n",
        "  markdown += \"## Module {num} Definitions\\n\".format(num=module_num)\n",
        "  for concept, definition in definitions.items():\n",
        "    markdown += \"* **{concept}** - {definition}\\n\".format(concept=concept.capitalize(), definition=definition)\n",
        "  return markdown\n",
        "\n",
        "\n",
        "module1_markdown = format_module(1, \"Rational Agents and Task Environments\", module1_sections, module1_definitions)\n",
        "display(Markdown(module1_markdown))"
      ],
      "execution_count": 22,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n A Computer Agent Should:\n- operate autonomously\n- have percepts\n- exist for a period of time\n- adapt to a changing environment\n- create & pursue goals\n\nThe goal of an agent isn't to mimmic human behaviour, but to act rationally. Rationality is mathematically defined, whereas human \nbehaviour may not always be rational, and is much harder to represent.\n\n \n\nlength = 59 words\n\n## AIMA Chapter 27.1 The Limits of AI\n Your summary here \n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Your summary here \n\n## AIMA 2.1 Agents and Environments\n An agents action can be decided based on its percept sequence and current percepts, however not on future information it hasn't yet received\n\nThe agent function is an abstract mathematical concept, whereas the agent program is a concrete implementation, such as compiled code which executes \nthe agent function.\n \n\nlength = 52 words\n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n When designing a performance measure it is better to base it off of the goal within the environment as opposed to how the\ncomputer should behave.\n \n\nlength = 30 words\n\n## AIMA 2.3 The Nature of Environments\n A Task Environment is Described By:\n- Performance Measure, Environment, Actuators & Sensors\n- the task environment is the problem that the computer attempts to solve\n\nFully vs. Partially Observable:\n- fully = sensors provide <u><b>all relevant</b></u> info. about the environment, where partial only provides some or environment is non-deterministic\n- partially observable is more challenging because the agent has to maintain state information about the env.\n\nStochastic is not exactly equal to Non-Deterministic, stochastic explicitly implies probabilities\n\nEpisodic vs. Sequential:\n- in episodic, the agent takes in info. and makes desicion and decision do not depend on previous actions, whereas sequential does\n\nStatic vs. Dynamic:\n- dynamic can be similar to non-deterministic, but is when the environment changes during the computers turn, when it is deciding\n \n\nlength = 122 words\n\n## AIMA 2.4 The Structure of Agents\n For simple reflex agents, the <u><b>condition-action rule</b></u> is like an if->else for controlling actions flow\n\nRandom actions may be beneficial for simple reflex agents as it can help them escape from infinite loops.\n\nModel based agents utilize a transition model and sensor model to keep track of the partially observable part of the environment it cannot currently see\n\nA goal based agent considers states that are desireable\n\nUtility based agents use a utility function to provide a measure of how good states are\n- good when there are conflicting goals\n- when there are multiple goals but they all may not be reachable, expected utility takes into account the probability\n\nLearning based agents take into account a learning element which provides feedback on how well the agent is doing. Based on this the agent can\nadjust its model.\n \n\nlength = 135 words\n\n## Module 1 Lecture Notes\n When something can have it's own performance measure it should be considered an agent in the problem\n\nEnvironment for problems we attempt to solve in class:\n- Static, Fully Observable, Deterministic, Discrete\n- think chess game... the board does not change during an agent's turn, the entire board is visible, each move is 100% executed and discrete\n\n \n\nlength = 59 words\n\n## Module 1 Definitions\n* **Agent** - anything that can perceive it's environment and act on it's environment\n* **Agent function** - maps a specific percept sequence to a resulting action\n* **Agent program** - the concrete implementation of the agent function\n* **Agent architecture** - physical hardware and sensors the agent uses\n* **Percept** - information gathered about the environment from sensor(s)\n* **Percept sequence** - list of all the percepts an agent has gathered in history\n* **Rational agent** -  makes actions which maximize the outcome or the expected outcome. can include randome decisions in game theory!\n* **Rationality** - doing the <i>right</i> thing\n* **Turing test** - thought experiment designed to discriminate between human and computer, passed if human cannot tell the difference in responses to qs\n* **Value alignment problem** - the balance of designing to meet our <u><b>true</b></u> goal vs. the object we program a machine to reach \n* **Simple reflex agent** - makes decisions based solely off of current precept, no history\n* **Transition model** - models the effects of the agents actions\n* **Sensor model** - models how the state of the world is reflected in the sensor information received by the agent\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9xRbdqDox2zD"
      },
      "source": [
        "#Module 2 - Python"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DpBvu7EMx7sy"
      },
      "source": [
        "# No readings for this module.  Instead you can summarize the lecture instead.\n",
        "\n",
        "# Lecture notes \n",
        "module2_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Each definition should be at most 20 words long.\n",
        "module2_definitions = {\n",
        "\"mutability\" : \"your definition here\",\n",
        "}"
      ],
      "execution_count": 23,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ydOK__lwWgdp",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 210
        },
        "outputId": "1ee9187f-92c3-4742-e252-ee14356524c2"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "\n",
        "module2_sections = [\n",
        "  (\"Module 2 Lecture Notes\", module2_lecture_notes),\n",
        "]\n",
        "\n",
        "module2_markdown = format_module(2, \"Python\", module2_sections, module2_definitions)\n",
        "display(Markdown(module2_markdown))"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 2: Python\n## Module 2 Lecture Notes\n Your summary here \n\n## Module 2 Definitions\n* **Mutability** - your definition here\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "46MQLR-Gx8dZ"
      },
      "source": [
        "#Module 3 - Search Problems"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "BN0b1eVYx-nd"
      },
      "source": [
        "# Russell and Norvig, AIMA 4th Edition, AIMA Chapter 3 “Problem Solving by Search” (3.1-3.4)\n",
        "if not('chapter3_1' in locals()):\n",
        "  chapter3_1 = \"\"\n",
        "chapter3_1 = \"\"\" Problem solving agents go through a 4-Stage process; \n",
        "1. Goal Formulation\n",
        "2. Problem Formulation = description of states and actions needed to reach the goal\n",
        "3. Search = Process of building the sequence of actions\n",
        "4. Execution = Carrying out the actions to reach the goal\\n\n",
        "\n",
        "Open Loop == Fully Observable\n",
        "Non Deterministic = Partially Observable \n",
        "\n",
        "<b>\\nProblem is Formally Defined by:</b>\n",
        "\\n-> State Space, all possible states\n",
        "\\n-> Initial State,\n",
        "\\n-> Goal State\n",
        "\\n-> Actions\n",
        "\\n-> Transition Model\n",
        "\\n-> Action Cost Function \"\"\" + f'\\n\\nlength = {len(chapter3_1.split(\" \"))} words'\n",
        "\n",
        "if not('chapter3_2' in locals()):\n",
        "  chapter3_2 = \"\"\n",
        "chapter3_2 = \"\"\" Standardized Problems:\n",
        "- grid world, vaccuum world, sliding tile puzzle\n",
        "\n",
        "Real World Problems:\n",
        "- route-finding, touring (TSP), vlsi layout, robot navigation, automatic assembly sequencing \"\"\" + f'\\n\\nlength = {len(chapter3_2.split(\" \"))} words'\n",
        "\n",
        "if not('chapter3_3' in locals()):\n",
        "  chapter3_3 = \"\"\n",
        "chapter3_3 = \"\"\" There are a few different data structures used for search\n",
        "\\nPriority Queue - ordered by cost        (Best First Search/Uniform Cost) \n",
        "\\nFIFO Queue - first in first out         (Breadth First Search)\n",
        "\\nLIFO Queue - expands deepest node first (Depth First Search)\n",
        "\n",
        "\\nCompleteness - does the algorithm <b>always</b> find a solution when there is one\n",
        "\\nCost Optimality - is the solution guaranteed to be the minimum cost solution\n",
        "\\nTime & Space Complexity\"\"\" + f'\\n\\nlength = {len(chapter3_3.split(\" \"))} words'\n",
        "\n",
        "if not('chapter3_4' in locals()):\n",
        "  chapter3_4 = \"\"\n",
        "chapter3_4 = \"\"\" \n",
        "<b>Breadth First Search</b>\n",
        "- spreads out over uniform depth\n",
        "- Memory Complexity - O(b^d) is much more concern than \n",
        "- Time Complexity - O(b^d)\n",
        "- Optimal & Complete!\n",
        "- Use if there are some solutions with short paths, or possible infinite sols\n",
        "\n",
        "<b>Depth First Search</b>\n",
        "- expands the deepest node first\n",
        "- Memory Complexity - O(b*m)\n",
        "- Time Complexity - O(b^m)\n",
        "- Not Optimal, Not Complete!\n",
        "- Use if many solutions with long depth\n",
        "\n",
        "<b>Djikstra\\'s (Best First Search/Uniform Cost Search)</b>\n",
        "- expands nodes with least cost\n",
        "- Complete & Optimal!\n",
        "\n",
        "\\n* b=branching factor, m=deepest node in tree, d=depth of min solution\"\"\" + f'\\n\\nlength = {len(chapter3_4.split(\" \"))} words'\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module3_lecture_notes = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Definitions of concepts from Module 3.\n",
        "# You can define any bolded term in the textbook, \n",
        "# but you most use your own words for the definitions.\n",
        "# Each definition should be at most 20 words long.\n",
        "module3_definitions = {\n",
        "\"problem-solving agent\" : \"an agent that can formulate a plan via search\",\n",
        "\"search\" : \"the process of determining a sequence of actions that form a path to a goal state\",\n",
        "\"Informed Search\" : \"search when the agent has an idea of how close it is to the goal state\",\n",
        "\"Uninformed Search\" : \"search when the agent has no idea of how close it is to the goal state\"\n",
        "}\n",
        "\n"
      ],
      "execution_count": 25,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lvtN3p7ET3Tx",
        "cellView": "form",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "168f7f98-c04d-4d40-9ed5-c32ab9840d9b"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module3_sections = [\n",
        "  (\"AIMA Chapter 3.1 Problem-Solving Agents\", chapter3_1),\n",
        "  (\"AIMA Chapter 3.2 Example Problems\", chapter3_2),\n",
        "  (\"AIMA Chapter 3.3 Search Algorithms\", chapter3_3),\n",
        "  (\"AIMA Chapter 3.4 Uninformed Search Strategies\", chapter3_4),\n",
        "  (\"Module 3 Lecture Notes\", module3_lecture_notes),\n",
        "]\n",
        "\n",
        "module3_markdown = format_module(3, \"Search Problems\", module3_sections, module3_definitions)\n",
        "display(Markdown(module3_markdown))"
      ],
      "execution_count": 26,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Problem solving agents go through a 4-Stage process; \n1. Goal Formulation\n2. Problem Formulation = description of states and actions needed to reach the goal\n3. Search = Process of building the sequence of actions\n4. Execution = Carrying out the actions to reach the goal\n\n\nOpen Loop == Fully Observable\nNon Deterministic = Partially Observable \n\n<b>\nProblem is Formally Defined by:</b>\n\n-> State Space, all possible states\n\n-> Initial State,\n\n-> Goal State\n\n-> Actions\n\n-> Transition Model\n\n-> Action Cost Function \n\nlength = 76 words\n\n## AIMA Chapter 3.2 Example Problems\n Standardized Problems:\n- grid world, vaccuum world, sliding tile puzzle\n\nReal World Problems:\n- route-finding, touring (TSP), vlsi layout, robot navigation, automatic assembly sequencing \n\nlength = 26 words\n\n## AIMA Chapter 3.3 Search Algorithms\n There are a few different data structures used for search\n\nPriority Queue - ordered by cost        (Best First Search/Uniform Cost) \n\nFIFO Queue - first in first out         (Breadth First Search)\n\nLIFO Queue - expands deepest node first (Depth First Search)\n\n\nCompleteness - does the algorithm <b>always</b> find a solution when there is one\n\nCost Optimality - is the solution guaranteed to be the minimum cost solution\n\nTime & Space Complexity\n\nlength = 84 words\n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n \n<b>Breadth First Search</b>\n- spreads out over uniform depth\n- Memory Complexity - O(b^d) is much more concern than \n- Time Complexity - O(b^d)\n- Optimal & Complete!\n- Use if there are some solutions with short paths, or possible infinite sols\n\n<b>Depth First Search</b>\n- expands the deepest node first\n- Memory Complexity - O(b*m)\n- Time Complexity - O(b^m)\n- Not Optimal, Not Complete!\n- Use if many solutions with long depth\n\n<b>Djikstra's (Best First Search/Uniform Cost Search)</b>\n- expands nodes with least cost\n- Complete & Optimal!\n\n\n* b=branching factor, m=deepest node in tree, d=depth of min solution\n\nlength = 91 words\n\n## Module 3 Lecture Notes\n Your summary here \n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Search** - the process of determining a sequence of actions that form a path to a goal state\n* **Informed search** - search when the agent has an idea of how close it is to the goal state\n* **Uninformed search** - search when the agent has no idea of how close it is to the goal state\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "WHREsHSSyA-h"
      },
      "source": [
        "#Module 4 - Informed Search"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tuFC8w7CyCns"
      },
      "source": [
        "# Russell and Norvig, AIMA Chapter 3 “Problem Solving by Search” (3.5-3.6)\n",
        "if not('chapter3_5' in locals()):\n",
        "  chapter3_5 = \"\"\n",
        "chapter3_5 = \"\"\" \n",
        "<b>Greedy Best First Search</b>\n",
        "- uses heuristic to try to reach goal in shortest distiance possible\n",
        "- Ignores cost to get to node, only relies on heuristic\n",
        "- Not Optimal! In finite spaces complete, but in infinite... Incomplete!\n",
        "\n",
        "<b>A*</b>\n",
        "- best first search that uses an evaluation function (heuristic)\n",
        "- must have an admissible heuristic to be Optimal\n",
        "- is efficient because it prunes non-necessary nodes\n",
        "\n",
        "Heuristics:\n",
        "- if for all n, h_2(n) >= h_1(n), then h_2 dominates h_1\n",
        "- it is better to use h_2 as long as it is consistent, because it will prune better\n",
        "- the cost of a heuristic for a relaxed problem is admissible \"\"\" + f'\\n\\nlength = {len(chapter3_5.split(\" \"))} words'\n",
        "\n",
        "chapter3_6 = \"\"\n",
        "chapter3_6 = \"\"\" Your summary here \"\"\" + f'\\n\\nlength = {len(chapter3_6.split(\" \"))} words'\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "if not('module4_lecture_notes' in locals()):\n",
        "  module4_lecture_notes = \"\"\n",
        "module4_lecture_notes = \"\"\" \n",
        "If a heuristic is admissible , A* using Tree Search is Optimal \n",
        "- inadmissible heuristics trap good plans in frontier\n",
        "- heuristic is admissible/optimistic if, 0 <= h(n) <= h*(n), where h* is the actual cost to the goal \"\"\" + f'\\n\\nlength = {len(module4_lecture_notes.split(\" \"))} words'\n",
        "\n",
        "# Definitions\n",
        "module4_definitions = {\n",
        "\"admissibility/optimistic\" : \"heuristic <b>never</b> overestimates actual distance to goal\",\n",
        "\"consistency\" : \"h(n) <= c(n, a, n\\') + h(n\\'), every consistent heuristic is admissible, but not reverse\"\n",
        "}\n",
        "\n"
      ],
      "execution_count": 28,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vqtEs0gHs9sO",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 693
        },
        "cellView": "form",
        "outputId": "6b2681b3-233d-42f4-f736-d5870b602b09"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module4_sections = [\n",
        "  (\"AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\", chapter3_5),\n",
        "  (\"AIMA Chapter 3.6 Heuristic Functions\", chapter3_6),\n",
        "  (\"Module 4 Lecture Notes\", module4_lecture_notes),\n",
        "]\n",
        "\n",
        "module4_markdown = format_module(4, \"Informed Search\", \n",
        "                         module4_sections, \n",
        "                         module4_definitions)\n",
        "display(Markdown(module4_markdown))"
      ],
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 4: Informed Search\n## AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\n \n<b>Greedy Best First Search</b>\n- uses heuristic to try to reach goal in shortest distiance possible\n- Ignores cost to get to node, only relies on heuristic\n- Not Optimal! In finite spaces complete, but in infinite... Incomplete!\n\n<b>A*</b>\n- best first search that uses an evaluation function (heuristic)\n- must have an admissible heuristic to be Optimal\n- is efficient because it prunes non-necessary nodes\n\nHeuristics:\n- if for all n, h_2(n) >= h_1(n), then h_2 dominates h_1\n- it is better to use h_2 as long as it is consistent, because it will prune better\n- the cost of a heuristic for a relaxed problem is admissible \n\nlength = 103 words\n\n## AIMA Chapter 3.6 Heuristic Functions\n Your summary here \n\nlength = 1 words\n\n## Module 4 Lecture Notes\n \nIf a heuristic is admissible , A* using Tree Search is Optimal \n- inadmissible heuristics trap good plans in frontier\n- heuristic is admissible/optimistic if, 0 <= h(n) <= h*(n), where h* is the actual cost to the goal \n\nlength = 43 words\n\n## Module 4 Definitions\n* **Admissibility/optimistic** - heuristic <b>never</b> overestimates actual distance to goal\n* **Consistency** - h(n) <= c(n, a, n') + h(n'), every consistent heuristic is admissible, but not reverse\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F3FPMzG9yUls"
      },
      "source": [
        "#Module 5 - Adversarial Search and Games"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "iEIOpL7vyWcc"
      },
      "source": [
        "# Russell and Norvig, AIMA chapter 5 \"Adversarial Search\"”\" (5.1-5.3, and 5.5).\n",
        "if not('chapter5_1' in locals()):\n",
        "  chapter5_1 = \"\"\n",
        "chapter5_1 = \"\"\" <b>pruning</b> makes search more efficient by ignoreing subtrees which make no difference to the search\n",
        "\n",
        "A Game is Fully Defined by:\n",
        "- S_0 which is the initial state of the game\n",
        "- Which player moves on turn s\n",
        "- Set of legal moves in state s\n",
        "- Transition model which maps resulting states from actions taken in state s\n",
        "- Terminal test which tells when the game is over\n",
        "- Utility function which returns the score to a player when the game is over\n",
        " \"\"\"\n",
        "if not('chapter5_2' in locals()):\n",
        "  chapter5_2 = \"\"\n",
        "chapter5_2 = \"\"\" If min is not an optimal oppoenent, then there may exist a better outcome for max \n",
        "if it chooses the non-minimax move (i.e. takes a risk) \n",
        "\n",
        "<b>Minimax Algorithm</b>\n",
        "Time Complexity = O(b^m)\n",
        "Space Complexity = O(b*m), if all sol generated at once\n",
        "Space Complexity = O(m), if only one sol generated at a time\n",
        "\n",
        "<b>Alpha Beta Pruning</b>\n",
        "Time Complexity = O(b^(m/2)), best case\n",
        "* efficieny does depend on order of moves!\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter5_2.split(\" \"))} words'\n",
        "\n",
        "chapter5_3 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "if not('chapter5_5' in locals()):\n",
        "  chapter5_5 = \"\"\n",
        "chapter5_5 = \"\"\" Stochastic games capture uncertainty in actions through probability. Instead of using\n",
        "the utility of an outcome, the expected value is computed, which is the weighted average of all outcomes for a node.\n",
        "\n",
        "For stochastic games minimax = O(b^m * n^m), where n equals the number of distinct probabilistic outcomes.\n",
        "With probability, the number of possibilities explodes.\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter5_5.split(\" \"))} words'\n",
        "\n",
        "# Russell and Norvig, AIMA Chapter 16 “Making Simple Decisions” (16.1-16.3)\n",
        "chapter16_1 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "if not('chapter16_2' in locals()):\n",
        "  chapter16_2 = \"\"\n",
        "chapter16_2 = \"\"\" 6 Constraints for Preference:\n",
        "- Orderability = given two lotteries, the agent must either rate one better or both equal\n",
        "- Transitivity = if an agent rates A > B and B > C, then A > C must be true\n",
        "- Continuity = If an agent rates A > C and B is somerwhere in betwee, then there exists a probability that A ~= B\n",
        "- Substitutability = If A ~= B then B can be substituted for A\n",
        "- Monotinicity = If two lotteries have equal values A == B, then an agent will prefer the lottery which has the greater probability\n",
        "- Decomposability = a probability can be broken down into simpler probabilities\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter16_2.split(\" \"))} words'\n",
        "\n",
        "chapter16_3 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "if not('module5_lecture_notes' in locals()):\n",
        "  module5_lecture_notes = \"\"\n",
        "module5_lecture_notes = \"\"\" Simplest Adversarial Game:\n",
        "- Static = game does not change during player's turn\n",
        "- Discrete = finite amount of actions\n",
        "- Fully Observable = complete state of environment is known\n",
        "- Strategic = definite transition model, no randomness\n",
        "\n",
        "<b>Minimax</b>\n",
        "- Max, backed up value is max() of it's children\n",
        "- Min, vacked up value is the min() of it's children\n",
        " \n",
        "<b>Alpha-Beta Pruning</b>\n",
        "- Max, never chooses value less than alpha,\n",
        "- Min, never chooses value greater than beta\n",
        "\"\"\" + f'\\n\\nlength = {len(module5_lecture_notes.split(\" \"))} words'\n",
        "\n",
        "# Definitions\n",
        "module5_definitions = {\n",
        "\"perfect information\" : \"fully observable\",\n",
        "\"zero-sum game\" : \"what is good for one player is equally bad for the other\",\n",
        "\"stochastic games\" : \"include unpredictability/uncertainty through the use of random events & probability\",\n",
        "\"expected value\" : \"the average of all possible outcomes for a node\",\n",
        "\"Maximum Expected Utility\" : \"a rational agent should choose the action which maximizes the MEU\",\n",
        "}\n",
        "\n"
      ],
      "execution_count": 31,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "KUc_LgzDvWf-",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "64dcd2ae-9acd-47a1-ca27-fdd050f38fc8"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module5_sections = [\n",
        "  (\"AIMA Chapter 5.1 Game Theory\", chapter5_1),\n",
        "  (\"AIMA Chapter 5.2 Optimal Decisions in Games\", chapter5_2),\n",
        "  (\"AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\", chapter5_3),\n",
        "  (\"AIMA Chapter 5.5 Stochastic Games\", chapter5_5),\n",
        "  (\"AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\", chapter16_1),\n",
        "  (\"AIMA Chapter 16.2 The Basis of Utility Theory\", chapter16_2),\n",
        "  (\"AIMA Chapter 16.3 Utility Functions\", chapter16_3),\n",
        "  (\"Module 5 Lecture Notes\", module5_lecture_notes),\n",
        "]\n",
        "\n",
        "module5_markdown = format_module(5, \"Adversarial Search and Games\", \n",
        "                         module5_sections, \n",
        "                         module5_definitions)\n",
        "display(Markdown(module5_markdown))"
      ],
      "execution_count": 33,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n <b>pruning</b> makes search more efficient by ignoreing subtrees which make no difference to the search\n\nA Game is Fully Defined by:\n- S_0 which is the initial state of the game\n- Which player moves on turn s\n- Set of legal moves in state s\n- Transition model which maps resulting states from actions taken in state s\n- Terminal test which tells when the game is over\n- Utility function which returns the score to a player when the game is over\n \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n If min is not an optimal oppoenent, then there may exist a better outcome for max \nif it chooses the non-minimax move (i.e. takes a risk) \n\n<b>Minimax Algorithm</b>\nTime Complexity = O(b^m)\nSpace Complexity = O(b*m), if all sol generated at once\nSpace Complexity = O(m), if only one sol generated at a time\n\n<b>Alpha Beta Pruning</b>\nTime Complexity = O(b^(m/2)), best case\n* efficieny does depend on order of moves!\n\n\nlength = 69 words\n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Stochastic games capture uncertainty in actions through probability. Instead of using\nthe utility of an outcome, the expected value is computed, which is the weighted average of all outcomes for a node.\n\nFor stochastic games minimax = O(b^m * n^m), where n equals the number of distinct probabilistic outcomes.\nWith probability, the number of possibilities explodes.\n \n\nlength = 58 words\n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n 6 Constraints for Preference:\n- Orderability = given two lotteries, the agent must either rate one better or both equal\n- Transitivity = if an agent rates A > B and B > C, then A > C must be true\n- Continuity = If an agent rates A > C and B is somerwhere in betwee, then there exists a probability that A ~= B\n- Substitutability = If A ~= B then B can be substituted for A\n- Monotinicity = If two lotteries have equal values A == B, then an agent will prefer the lottery which has the greater probability\n- Decomposability = a probability can be broken down into simpler probabilities\n\n\nlength = 114 words\n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n Simplest Adversarial Game:\n- Static = game does not change during player's turn\n- Discrete = finite amount of actions\n- Fully Observable = complete state of environment is known\n- Strategic = definite transition model, no randomness\n\n<b>Minimax</b>\n- Max, backed up value is max() of it's children\n- Min, vacked up value is the min() of it's children\n \n<b>Alpha-Beta Pruning</b>\n- Max, never chooses value less than alpha,\n- Min, never chooses value greater than beta\n\n\nlength = 73 words\n\n## Module 5 Definitions\n* **Perfect information** - fully observable\n* **Zero-sum game** - what is good for one player is equally bad for the other\n* **Stochastic games** - include unpredictability/uncertainty through the use of random events & probability\n* **Expected value** - the average of all possible outcomes for a node\n* **Maximum expected utility** - a rational agent should choose the action which maximizes the MEU\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qVSQhTVSyYYO"
      },
      "source": [
        "#Module 6 - \"Constraint Satisfaction Problems\""
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Wm4mfW82yaRH"
      },
      "source": [
        "# Russell and Norvig, AIMA, Chapter 6 “Constraint Satisfaction Problems” (6.1-6.5)\n",
        "if not('chapter6_1' in locals()):\n",
        "  chapter6_1 = \"\"\n",
        "if not('chapter6_2' in locals()):\n",
        "  chapter6_2 = \"\"\n",
        "if not('chapter6_3' in locals()):\n",
        "  chapter6_3 = \"\"\n",
        "if not('chapter6_4' in locals()):\n",
        "  chapter6_4 = \"\"\n",
        "if not('chapter6_5' in locals()):\n",
        "  chapter6_5 = \"\"  \n",
        "if not('module6_lecture_notes' in locals()):\n",
        "  module6_lecture_notes = \"\"  \n",
        "\n",
        "chapter6_1 = \"\"\" CSPs are able to more efficiently prune ineffective solutions from problems\n",
        " \"\"\" + f'\\n\\nlength = {len(chapter6_1.split(\" \"))} words'\n",
        "\n",
        "chapter6_2 = \"\"\" Constraint propogation can be used to reduce the number of possible states to explore.\n",
        "\n",
        "It can either come before search or after, and can even solve the entire problem!\n",
        "\n",
        "Time Complexity:\n",
        "- O(b^2) time for checking arc consistency for a node -> O(cd^3) total time worst case\n",
        "* n nodes, d domain values, c binary constraints\n",
        "\n",
        "Path consistency is used to narrow down binary constraints by chaining the constraints for 3 variables in a path\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter6_2.split(\" \"))} words'\n",
        "\n",
        "\n",
        "chapter6_3 = \"\"\" If there are still variables with multiple values left after constraint propogation, then you must use search.\n",
        "\n",
        "One strategy that can simplify things is Minimum Remaining Values (MRV), where you choose the variable that is most constrictive. \n",
        "\n",
        "Commutivity also helps to reduce the branching factor of the tree, since the order of variable assignment doesn't matter, only the values themselves.\n",
        "\n",
        "\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter6_3.split(\" \"))} words'\n",
        "\n",
        "chapter6_4 = \"\"\" Local search assigns all variables a value, and then attempts to de-conflict any problems.\n",
        "\n",
        "<b>tabu</b> search is a technique which remembers bad states and prevents the alg from returning\n",
        "\n",
        "Local search is also good when you have an initial map to start with and only need to make a few modifications for a new solution.\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter6_4.split(\" \"))} words'\n",
        "\n",
        "chapter6_5 = \"\"\" Another technique for efficiently solving CSPs is defining sub-problems. Think of the Tazmania example from lecture...\n",
        "\n",
        "By noting connected components the larger problem can be divided into solving sub-problems, which drastically decreases time complexity.\n",
        "\"\"\" + f'\\n\\nlength = {len(chapter6_5.split(\" \"))} words'\n",
        "\n",
        "\n",
        "# Lecture notes \n",
        "module6_lecture_notes = \"\"\" CSP Consists of:\n",
        "- finite set of variables\n",
        "- non-empty domain of values for each node\n",
        "- finite set of constraints\n",
        "\n",
        "consistent assignment - assignment that does not violate any of the constraints\n",
        "\n",
        "One benefit of CSP is that it automatically prunes off bad subtrees -> more efficient\n",
        "\n",
        "For a finite domain with <i>n</i> variables with <i>d</i> possible values, there are O(d^n) possible assignments\n",
        "\n",
        "Heuristics:\n",
        "- most constraining variables should be chosen next\n",
        "- least constraining value should be assigned\n",
        "- forward checking then can be used to early detect bad paths\n",
        "\n",
        "AC-3 Time Complexity = O(n^2d^3)\n",
        "\"\"\" + f'\\n\\nlength = {len(module6_lecture_notes.split(\" \"))} words'\n",
        "\n",
        "# Definitions\n",
        "module6_definitions = {\n",
        "\"complete assignment\" : \"a state where every variable is assigned a value\",\n",
        "\"solution\" : \"a consistent, complete assignment\",\n",
        "\"unary constraint\" : \"constraint that restricts the value of a single variable\", \n",
        "\"binary constraint\" : \"ralates two variables\",\n",
        "\"constraint propogation\" : \"uses constraints to narrow down the possible values of a variable, which in turn affects the values of neighbors\",\n",
        "\"node consistency\" : \"when all of the possible values of a node satisfy the unary constraints\",\n",
        "\"arc consistency\" : \"when the values of a node satisfy the binary constraints of attached edges\",\n",
        "\"resource constraint\" : \"At-most constraint, such as a global max for price of purchases\",\n",
        "\"forward checking\" : \"applies arc consistency check after a variable is assigned a value\",\n",
        "\n",
        "}\n"
      ],
      "execution_count": 35,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "kKWbCsbfxL3R",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "5c30aadd-0277-40b2-a683-2e8a2d931565"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module6_sections = [\n",
        "  (\"AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\", chapter6_1),\n",
        "  (\"AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\", chapter6_2),\n",
        "  (\"AIMA Chapter 6.3 Backtracking Search for CSPs\", chapter6_3),\n",
        "  (\"AIMA Chapter 6.4 Local Search for CSPs\", chapter6_4),\n",
        "  (\"AIMA Chapter 6.5 The Structure of Problems\", chapter6_5),\n",
        "  (\"Module 6 Lecture Notes\", module6_lecture_notes),\n",
        "]\n",
        "\n",
        "module6_markdown = format_module(6, \"Constraint Satisfaction Problems\", \n",
        "                         module6_sections, \n",
        "                         module6_definitions)\n",
        "display(Markdown(module6_markdown))"
      ],
      "execution_count": 36,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 6: Constraint Satisfaction Problems\n## AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\n CSPs are able to more efficiently prune ineffective solutions from problems\n \n\nlength = 16 words\n\n## AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\n Constraint propogation can be used to reduce the number of possible states to explore.\n\nIt can either come before search or after, and can even solve the entire problem!\n\nTime Complexity:\n- O(b^2) time for checking arc consistency for a node -> O(cd^3) total time worst case\n* n nodes, d domain values, c binary constraints\n\nPath consistency is used to narrow down binary constraints by chaining the constraints for 3 variables in a path\n\n\nlength = 74 words\n\n## AIMA Chapter 6.3 Backtracking Search for CSPs\n If there are still variables with multiple values left after constraint propogation, then you must use search.\n\nOne strategy that can simplify things is Minimum Remaining Values (MRV), where you choose the variable that is most constrictive. \n\nCommutivity also helps to reduce the branching factor of the tree, since the order of variable assignment doesn't matter, only the values themselves.\n\n\n\n\nlength = 63 words\n\n## AIMA Chapter 6.4 Local Search for CSPs\n Local search assigns all variables a value, and then attempts to de-conflict any problems.\n\n<b>tabu</b> search is a technique which remembers bad states and prevents the alg from returning\n\nLocal search is also good when you have an initial map to start with and only need to make a few modifications for a new solution.\n\n\nlength = 57 words\n\n## AIMA Chapter 6.5 The Structure of Problems\n Another technique for efficiently solving CSPs is defining sub-problems. Think of the Tazmania example from lecture...\n\nBy noting connected components the larger problem can be divided into solving sub-problems, which drastically decreases time complexity.\n\n\nlength = 37 words\n\n## Module 6 Lecture Notes\n CSP Consists of:\n- finite set of variables\n- non-empty domain of values for each node\n- finite set of constraints\n\nconsistent assignment - assignment that does not violate any of the constraints\n\nOne benefit of CSP is that it automatically prunes off bad subtrees -> more efficient\n\nFor a finite domain with <i>n</i> variables with <i>d</i> possible values, there are O(d^n) possible assignments\n\nHeuristics:\n- most constraining variables should be chosen next\n- least constraining value should be assigned\n- forward checking then can be used to early detect bad paths\n\nAC-3 Time Complexity = O(n^2d^3)\n\n\nlength = 90 words\n\n## Module 6 Definitions\n* **Complete assignment** - a state where every variable is assigned a value\n* **Solution** - a consistent, complete assignment\n* **Unary constraint** - constraint that restricts the value of a single variable\n* **Binary constraint** - ralates two variables\n* **Constraint propogation** - uses constraints to narrow down the possible values of a variable, which in turn affects the values of neighbors\n* **Node consistency** - when all of the possible values of a node satisfy the unary constraints\n* **Arc consistency** - when the values of a node satisfy the binary constraints of attached edges\n* **Resource constraint** - At-most constraint, such as a global max for price of purchases\n* **Forward checking** - applies arc consistency check after a variable is assigned a value\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RYESi2kMybL8"
      },
      "source": [
        "#Module 7 - Logical Agents"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qIRJ4YYCzNHL"
      },
      "source": [
        "# Russell and Norvig, AIMA Chapter 7 “Logical Agents” (Sections 7.1-7.5)\n",
        "if not('chapter6_1' in locals()):\n",
        "  chapter7_1 = \"\"\n",
        "if not('chapter6_2' in locals()):\n",
        "  chapter7_2 = \"\"\n",
        "if not('chapter6_3' in locals()):\n",
        "  chapter7_3 = \"\"\n",
        "if not('chapter6_4' in locals()):\n",
        "  chapter7_4 = \"\"\n",
        "if not('chapter6_5' in locals()):\n",
        "  chapter7_5 = \"\"  \n",
        "if not('module6_lecture_notes' in locals()):\n",
        "  module7_lecture_notes = \"\"  \n",
        "\n",
        "\n",
        "chapter7_1 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_2 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_3 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_4 = \"\"\" Your summary here \"\"\"\n",
        "chapter7_5 = \"\"\" Your summary here \"\"\"\n",
        "\n",
        "# Lecture notes \n",
        "module7_lecture_notes = \"\"\" Representation language has a <b>syntax</b> which serves as a structure to define meaning\n",
        "\n",
        "the knowledge base of the agent consists of sentences in a representation language\n",
        "\n",
        "If alpha entails beta, then that means that alpha is stronger than beta, or more specific\n",
        "\n",
        "Logical Connectives:\n",
        " -.  = not\n",
        " ^ = and\n",
        " V = or\n",
        " => implies\n",
        " <=> if and only if\n",
        " \n",
        " Logical Equivalence:\n",
        " \n",
        "alpha ^ beta == beta ^ alpha\n",
        "alpha V beta == beta V alpha\n",
        "((alpha ^ beta) ^ gamma) == (alpha ^(beta ^ gamma))\n",
        "((alpha V beta) V gamma) == (alpha V(beta V gamma))\n",
        "not(not(alpha)) == alpha\n",
        "(alpha => beta) == (not(beta) => not(alpha))\n",
        "(alpha => beta) == (not(alpha) V beta)\n",
        "(alpha <=> beta) == ((alpha => beta) ^ (beta => alpha))\n",
        "not(alpha ^ beta) = (not(alpha) V not(beta))\n",
        "not(alpha V beta) = (not(alpha) ^ not(beta))\n",
        "((alpha ^ beta) V gamma) == ((alpha ^ beta ) V (alpha ^ gamma))\n",
        "((alpha V beta) ^ gamma) == ((alpha V beta) ^ (alpha V gamma))\n",
        "\"\"\"\n",
        "\n",
        "# Definitions\n",
        "module7_definitions = {\n",
        "\"axioms\" : \"a sentence that is given\",\n",
        "\"derived sentences\" : \"sentences that are derived from other sentences\",\n",
        "\n",
        "}\n",
        "\n"
      ],
      "execution_count": 38,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "cellView": "form",
        "id": "lXNcHuKjyNXa",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 731
        },
        "outputId": "e79e96c1-c53d-40a7-d5b1-90f4082252fb"
      },
      "source": [
        "#@title Preview of your summary\n",
        "#@markdown You don't need to modify anything in this cell. Just press play.\n",
        "module7_sections = [\n",
        "  (\"AIMA Chapter 7.1 Knowledge-Based Agents\", chapter7_1),\n",
        "  (\"AIMA Chapter 7.2 The Wumpus World\", chapter7_2),\n",
        "  (\"AIMA Chapter 7.3 Logic\", chapter7_3),\n",
        "  (\"AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\", chapter7_4),\n",
        "  (\"AIMA 7.5 Propositional Theorem Proving\", chapter7_5),\n",
        "  (\"Module 7 Lecture Notes\", module7_lecture_notes),\n",
        "]\n",
        "\n",
        "module7_markdown = format_module(7, \"Logical Agents\", \n",
        "                         module7_sections, \n",
        "                         module7_definitions)\n",
        "display(Markdown(module7_markdown))"
      ],
      "execution_count": 39,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 7: Logical Agents\n## AIMA Chapter 7.1 Knowledge-Based Agents\n Your summary here \n\n## AIMA Chapter 7.2 The Wumpus World\n Your summary here \n\n## AIMA Chapter 7.3 Logic\n Your summary here \n\n## AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\n Your summary here \n\n## AIMA 7.5 Propositional Theorem Proving\n Your summary here \n\n## Module 7 Lecture Notes\n Representation language has a <b>syntax</b> which serves as a structure to define meaning\n\nthe knowledge base of the agent consists of sentences in a representation language\n\nIf alpha entails beta, then that means that alpha is stronger than beta, or more specific\n\nLogical Connectives:\n -.  = not\n ^ = and\n V = or\n => implies\n <=> if and only if\n \n Logical Equivalence:\n \nalpha ^ beta == beta ^ alpha\nalpha V beta == beta V alpha\n((alpha ^ beta) ^ gamma) == (alpha ^(beta ^ gamma))\n((alpha V beta) V gamma) == (alpha V(beta V gamma))\nnot(not(alpha)) == alpha\n(alpha => beta) == (not(beta) => not(alpha))\n(alpha => beta) == (not(alpha) V beta)\n(alpha <=> beta) == ((alpha => beta) ^ (beta => alpha))\nnot(alpha ^ beta) = (not(alpha) V not(beta))\nnot(alpha V beta) = (not(alpha) ^ not(beta))\n((alpha ^ beta) V gamma) == ((alpha ^ beta ) V (alpha ^ gamma))\n((alpha V beta) ^ gamma) == ((alpha V beta) ^ (alpha V gamma))\n\n\n## Module 7 Definitions\n* **Axioms** - a sentence that is given\n* **Derived sentences** - sentences that are derived from other sentences\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vX7lbnJd4sT5"
      },
      "source": [
        "# Your Exam Notes\n",
        "\n",
        "Here are your full set of exam notes that you can use on your midterm.  Choose **Runtime > Run all**, then your notes will be displayed.\n",
        "\n",
        "If you are taking the exam in person, then you must print a copy of your notes for yourself.   Here's how to print:\n",
        "* Run the cell below. \n",
        "* Click its \"Mirror cell in tab\" button (this is located in the upper right corner of the cell, immediately to the right of the trash can).  This will open the cell.  \n",
        "* In Chrome, you can then print your notes using the **File > Print** option from the browser's menu.  \n",
        "* In the print options, change the layout from Landscape to Portrait. \n",
        "* Clicking the Save, will save a PDF that you can then print.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "T3cm1WV542_a",
        "outputId": "48749fd1-4639-4ac2-9e78-885cdf5d7609"
      },
      "source": [
        "# This will generate the full set of notes that you can use for your exam.\n",
        "full_markdown = \"\\n\\n\".join([module1_markdown, \n",
        "                             module2_markdown, \n",
        "                             module3_markdown, \n",
        "                             module4_markdown, \n",
        "                             module5_markdown,\n",
        "                             module6_markdown,\n",
        "                             module7_markdown,]\n",
        "                       )\n",
        "display(Markdown(full_markdown))"
      ],
      "execution_count": 41,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/markdown": "# Module 1: Rational Agents and Task Environments\n## AIMA Chapter 1.1 What is AI?\n A Computer Agent Should:\n- operate autonomously\n- have percepts\n- exist for a period of time\n- adapt to a changing environment\n- create & pursue goals\n\nThe goal of an agent isn't to mimmic human behaviour, but to act rationally. Rationality is mathematically defined, whereas human \nbehaviour may not always be rational, and is much harder to represent.\n\n \n\nlength = 59 words\n\n## AIMA Chapter 27.1 The Limits of AI\n Your summary here \n\n## AIMA Chapter 27.1 Can Machines Really Think?\n Your summary here \n\n## AIMA 2.1 Agents and Environments\n An agents action can be decided based on its percept sequence and current percepts, however not on future information it hasn't yet received\n\nThe agent function is an abstract mathematical concept, whereas the agent program is a concrete implementation, such as compiled code which executes \nthe agent function.\n \n\nlength = 52 words\n\n## AIMA 2.2 Good Behavior: The Concept of Rationality\n When designing a performance measure it is better to base it off of the goal within the environment as opposed to how the\ncomputer should behave.\n \n\nlength = 30 words\n\n## AIMA 2.3 The Nature of Environments\n A Task Environment is Described By:\n- Performance Measure, Environment, Actuators & Sensors\n- the task environment is the problem that the computer attempts to solve\n\nFully vs. Partially Observable:\n- fully = sensors provide <u><b>all relevant</b></u> info. about the environment, where partial only provides some or environment is non-deterministic\n- partially observable is more challenging because the agent has to maintain state information about the env.\n\nStochastic is not exactly equal to Non-Deterministic, stochastic explicitly implies probabilities\n\nEpisodic vs. Sequential:\n- in episodic, the agent takes in info. and makes desicion and decision do not depend on previous actions, whereas sequential does\n\nStatic vs. Dynamic:\n- dynamic can be similar to non-deterministic, but is when the environment changes during the computers turn, when it is deciding\n \n\nlength = 122 words\n\n## AIMA 2.4 The Structure of Agents\n For simple reflex agents, the <u><b>condition-action rule</b></u> is like an if->else for controlling actions flow\n\nRandom actions may be beneficial for simple reflex agents as it can help them escape from infinite loops.\n\nModel based agents utilize a transition model and sensor model to keep track of the partially observable part of the environment it cannot currently see\n\nA goal based agent considers states that are desireable\n\nUtility based agents use a utility function to provide a measure of how good states are\n- good when there are conflicting goals\n- when there are multiple goals but they all may not be reachable, expected utility takes into account the probability\n\nLearning based agents take into account a learning element which provides feedback on how well the agent is doing. Based on this the agent can\nadjust its model.\n \n\nlength = 135 words\n\n## Module 1 Lecture Notes\n When something can have it's own performance measure it should be considered an agent in the problem\n\nEnvironment for problems we attempt to solve in class:\n- Static, Fully Observable, Deterministic, Discrete\n- think chess game... the board does not change during an agent's turn, the entire board is visible, each move is 100% executed and discrete\n\n \n\nlength = 59 words\n\n## Module 1 Definitions\n* **Agent** - anything that can perceive it's environment and act on it's environment\n* **Agent function** - maps a specific percept sequence to a resulting action\n* **Agent program** - the concrete implementation of the agent function\n* **Agent architecture** - physical hardware and sensors the agent uses\n* **Percept** - information gathered about the environment from sensor(s)\n* **Percept sequence** - list of all the percepts an agent has gathered in history\n* **Rational agent** -  makes actions which maximize the outcome or the expected outcome. can include randome decisions in game theory!\n* **Rationality** - doing the <i>right</i> thing\n* **Turing test** - thought experiment designed to discriminate between human and computer, passed if human cannot tell the difference in responses to qs\n* **Value alignment problem** - the balance of designing to meet our <u><b>true</b></u> goal vs. the object we program a machine to reach \n* **Simple reflex agent** - makes decisions based solely off of current precept, no history\n* **Transition model** - models the effects of the agents actions\n* **Sensor model** - models how the state of the world is reflected in the sensor information received by the agent\n\n\n# Module 2: Python\n## Module 2 Lecture Notes\n Your summary here \n\n## Module 2 Definitions\n* **Mutability** - your definition here\n\n\n# Module 3: Search Problems\n## AIMA Chapter 3.1 Problem-Solving Agents\n Problem solving agents go through a 4-Stage process; \n1. Goal Formulation\n2. Problem Formulation = description of states and actions needed to reach the goal\n3. Search = Process of building the sequence of actions\n4. Execution = Carrying out the actions to reach the goal\n\n\nOpen Loop == Fully Observable\nNon Deterministic = Partially Observable \n\n<b>\nProblem is Formally Defined by:</b>\n\n-> State Space, all possible states\n\n-> Initial State,\n\n-> Goal State\n\n-> Actions\n\n-> Transition Model\n\n-> Action Cost Function \n\nlength = 76 words\n\n## AIMA Chapter 3.2 Example Problems\n Standardized Problems:\n- grid world, vaccuum world, sliding tile puzzle\n\nReal World Problems:\n- route-finding, touring (TSP), vlsi layout, robot navigation, automatic assembly sequencing \n\nlength = 26 words\n\n## AIMA Chapter 3.3 Search Algorithms\n There are a few different data structures used for search\n\nPriority Queue - ordered by cost        (Best First Search/Uniform Cost) \n\nFIFO Queue - first in first out         (Breadth First Search)\n\nLIFO Queue - expands deepest node first (Depth First Search)\n\n\nCompleteness - does the algorithm <b>always</b> find a solution when there is one\n\nCost Optimality - is the solution guaranteed to be the minimum cost solution\n\nTime & Space Complexity\n\nlength = 84 words\n\n## AIMA Chapter 3.4 Uninformed Search Strategies\n \n<b>Breadth First Search</b>\n- spreads out over uniform depth\n- Memory Complexity - O(b^d) is much more concern than \n- Time Complexity - O(b^d)\n- Optimal & Complete!\n- Use if there are some solutions with short paths, or possible infinite sols\n\n<b>Depth First Search</b>\n- expands the deepest node first\n- Memory Complexity - O(b*m)\n- Time Complexity - O(b^m)\n- Not Optimal, Not Complete!\n- Use if many solutions with long depth\n\n<b>Djikstra's (Best First Search/Uniform Cost Search)</b>\n- expands nodes with least cost\n- Complete & Optimal!\n\n\n* b=branching factor, m=deepest node in tree, d=depth of min solution\n\nlength = 91 words\n\n## Module 3 Lecture Notes\n Your summary here \n\n## Module 3 Definitions\n* **Problem-solving agent** - an agent that can formulate a plan via search\n* **Search** - the process of determining a sequence of actions that form a path to a goal state\n* **Informed search** - search when the agent has an idea of how close it is to the goal state\n* **Uninformed search** - search when the agent has no idea of how close it is to the goal state\n\n\n# Module 4: Informed Search\n## AIMA Chapter 3.5 Informed (Heuristic) Search Strategies\n \n<b>Greedy Best First Search</b>\n- uses heuristic to try to reach goal in shortest distiance possible\n- Ignores cost to get to node, only relies on heuristic\n- Not Optimal! In finite spaces complete, but in infinite... Incomplete!\n\n<b>A*</b>\n- best first search that uses an evaluation function (heuristic)\n- must have an admissible heuristic to be Optimal\n- is efficient because it prunes non-necessary nodes\n\nHeuristics:\n- if for all n, h_2(n) >= h_1(n), then h_2 dominates h_1\n- it is better to use h_2 as long as it is consistent, because it will prune better\n- the cost of a heuristic for a relaxed problem is admissible \n\nlength = 103 words\n\n## AIMA Chapter 3.6 Heuristic Functions\n Your summary here \n\nlength = 1 words\n\n## Module 4 Lecture Notes\n \nIf a heuristic is admissible , A* using Tree Search is Optimal \n- inadmissible heuristics trap good plans in frontier\n- heuristic is admissible/optimistic if, 0 <= h(n) <= h*(n), where h* is the actual cost to the goal \n\nlength = 43 words\n\n## Module 4 Definitions\n* **Admissibility/optimistic** - heuristic <b>never</b> overestimates actual distance to goal\n* **Consistency** - h(n) <= c(n, a, n') + h(n'), every consistent heuristic is admissible, but not reverse\n\n\n# Module 5: Adversarial Search and Games\n## AIMA Chapter 5.1 Game Theory\n <b>pruning</b> makes search more efficient by ignoreing subtrees which make no difference to the search\n\nA Game is Fully Defined by:\n- S_0 which is the initial state of the game\n- Which player moves on turn s\n- Set of legal moves in state s\n- Transition model which maps resulting states from actions taken in state s\n- Terminal test which tells when the game is over\n- Utility function which returns the score to a player when the game is over\n \n\n## AIMA Chapter 5.2 Optimal Decisions in Games\n If min is not an optimal oppoenent, then there may exist a better outcome for max \nif it chooses the non-minimax move (i.e. takes a risk) \n\n<b>Minimax Algorithm</b>\nTime Complexity = O(b^m)\nSpace Complexity = O(b*m), if all sol generated at once\nSpace Complexity = O(m), if only one sol generated at a time\n\n<b>Alpha Beta Pruning</b>\nTime Complexity = O(b^(m/2)), best case\n* efficieny does depend on order of moves!\n\n\nlength = 69 words\n\n## AIMA Chapter 5.3 Heuristic Alpha–Beta Tree Search\n Your summary here \n\n## AIMA Chapter 5.5 Stochastic Games\n Stochastic games capture uncertainty in actions through probability. Instead of using\nthe utility of an outcome, the expected value is computed, which is the weighted average of all outcomes for a node.\n\nFor stochastic games minimax = O(b^m * n^m), where n equals the number of distinct probabilistic outcomes.\nWith probability, the number of possibilities explodes.\n \n\nlength = 58 words\n\n## AIMA Chapter 16.1 Combining Beliefs and Desires under Uncertainty\n Your summary here \n\n## AIMA Chapter 16.2 The Basis of Utility Theory\n 6 Constraints for Preference:\n- Orderability = given two lotteries, the agent must either rate one better or both equal\n- Transitivity = if an agent rates A > B and B > C, then A > C must be true\n- Continuity = If an agent rates A > C and B is somerwhere in betwee, then there exists a probability that A ~= B\n- Substitutability = If A ~= B then B can be substituted for A\n- Monotinicity = If two lotteries have equal values A == B, then an agent will prefer the lottery which has the greater probability\n- Decomposability = a probability can be broken down into simpler probabilities\n\n\nlength = 114 words\n\n## AIMA Chapter 16.3 Utility Functions\n Your summary here \n\n## Module 5 Lecture Notes\n Simplest Adversarial Game:\n- Static = game does not change during player's turn\n- Discrete = finite amount of actions\n- Fully Observable = complete state of environment is known\n- Strategic = definite transition model, no randomness\n\n<b>Minimax</b>\n- Max, backed up value is max() of it's children\n- Min, vacked up value is the min() of it's children\n \n<b>Alpha-Beta Pruning</b>\n- Max, never chooses value less than alpha,\n- Min, never chooses value greater than beta\n\n\nlength = 73 words\n\n## Module 5 Definitions\n* **Perfect information** - fully observable\n* **Zero-sum game** - what is good for one player is equally bad for the other\n* **Stochastic games** - include unpredictability/uncertainty through the use of random events & probability\n* **Expected value** - the average of all possible outcomes for a node\n* **Maximum expected utility** - a rational agent should choose the action which maximizes the MEU\n\n\n# Module 6: Constraint Satisfaction Problems\n## AIMA Chapter 6.1 Defining Constraint Satisfaction Problems\n CSPs are able to more efficiently prune ineffective solutions from problems\n \n\nlength = 16 words\n\n## AIMA Chapter 6.2 Constraint Propagation: Inference in CSPs\n Constraint propogation can be used to reduce the number of possible states to explore.\n\nIt can either come before search or after, and can even solve the entire problem!\n\nTime Complexity:\n- O(b^2) time for checking arc consistency for a node -> O(cd^3) total time worst case\n* n nodes, d domain values, c binary constraints\n\nPath consistency is used to narrow down binary constraints by chaining the constraints for 3 variables in a path\n\n\nlength = 74 words\n\n## AIMA Chapter 6.3 Backtracking Search for CSPs\n If there are still variables with multiple values left after constraint propogation, then you must use search.\n\nOne strategy that can simplify things is Minimum Remaining Values (MRV), where you choose the variable that is most constrictive. \n\nCommutivity also helps to reduce the branching factor of the tree, since the order of variable assignment doesn't matter, only the values themselves.\n\n\n\n\nlength = 63 words\n\n## AIMA Chapter 6.4 Local Search for CSPs\n Local search assigns all variables a value, and then attempts to de-conflict any problems.\n\n<b>tabu</b> search is a technique which remembers bad states and prevents the alg from returning\n\nLocal search is also good when you have an initial map to start with and only need to make a few modifications for a new solution.\n\n\nlength = 57 words\n\n## AIMA Chapter 6.5 The Structure of Problems\n Another technique for efficiently solving CSPs is defining sub-problems. Think of the Tazmania example from lecture...\n\nBy noting connected components the larger problem can be divided into solving sub-problems, which drastically decreases time complexity.\n\n\nlength = 37 words\n\n## Module 6 Lecture Notes\n CSP Consists of:\n- finite set of variables\n- non-empty domain of values for each node\n- finite set of constraints\n\nconsistent assignment - assignment that does not violate any of the constraints\n\nOne benefit of CSP is that it automatically prunes off bad subtrees -> more efficient\n\nFor a finite domain with <i>n</i> variables with <i>d</i> possible values, there are O(d^n) possible assignments\n\nHeuristics:\n- most constraining variables should be chosen next\n- least constraining value should be assigned\n- forward checking then can be used to early detect bad paths\n\nAC-3 Time Complexity = O(n^2d^3)\n\n\nlength = 90 words\n\n## Module 6 Definitions\n* **Complete assignment** - a state where every variable is assigned a value\n* **Solution** - a consistent, complete assignment\n* **Unary constraint** - constraint that restricts the value of a single variable\n* **Binary constraint** - ralates two variables\n* **Constraint propogation** - uses constraints to narrow down the possible values of a variable, which in turn affects the values of neighbors\n* **Node consistency** - when all of the possible values of a node satisfy the unary constraints\n* **Arc consistency** - when the values of a node satisfy the binary constraints of attached edges\n* **Resource constraint** - At-most constraint, such as a global max for price of purchases\n* **Forward checking** - applies arc consistency check after a variable is assigned a value\n\n\n# Module 7: Logical Agents\n## AIMA Chapter 7.1 Knowledge-Based Agents\n Your summary here \n\n## AIMA Chapter 7.2 The Wumpus World\n Your summary here \n\n## AIMA Chapter 7.3 Logic\n Your summary here \n\n## AIMA Chapter 7.4 Propositional Logic: A Very Simple Logic\n Your summary here \n\n## AIMA 7.5 Propositional Theorem Proving\n Your summary here \n\n## Module 7 Lecture Notes\n Representation language has a <b>syntax</b> which serves as a structure to define meaning\n\nthe knowledge base of the agent consists of sentences in a representation language\n\nIf alpha entails beta, then that means that alpha is stronger than beta, or more specific\n\nLogical Connectives:\n -.  = not\n ^ = and\n V = or\n => implies\n <=> if and only if\n \n Logical Equivalence:\n \nalpha ^ beta == beta ^ alpha\nalpha V beta == beta V alpha\n((alpha ^ beta) ^ gamma) == (alpha ^(beta ^ gamma))\n((alpha V beta) V gamma) == (alpha V(beta V gamma))\nnot(not(alpha)) == alpha\n(alpha => beta) == (not(beta) => not(alpha))\n(alpha => beta) == (not(alpha) V beta)\n(alpha <=> beta) == ((alpha => beta) ^ (beta => alpha))\nnot(alpha ^ beta) = (not(alpha) V not(beta))\nnot(alpha V beta) = (not(alpha) ^ not(beta))\n((alpha ^ beta) V gamma) == ((alpha ^ beta ) V (alpha ^ gamma))\n((alpha V beta) ^ gamma) == ((alpha V beta) ^ (alpha V gamma))\n\n\n## Module 7 Definitions\n* **Axioms** - a sentence that is given\n* **Derived sentences** - sentences that are derived from other sentences\n",
            "text/plain": [
              "<IPython.core.display.Markdown object>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}