{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## CS 200: HW3\n", "\n", "

\n", "\n", " \n", "Load the compiled staff solution. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from hw3a import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Agents\n", "\n", "Make some agents." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "james = agent('James Bond')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "joe = agent('Joe Biden')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "agent('James Bond')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "james" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "agent('Joe Biden')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(james)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(joe)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "james.add_friend(joe)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "james2 = james.copy()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Name:\\tJames Bond\\nFriends:\\t[agent('Joe Biden')]\"" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "james2.pp()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tJames Bond\n", "Friends:\t[agent('Joe Biden')]\n" ] } ], "source": [ "print(james2.pp())" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tJoe Biden\n", "Friends:\t[agent('James Bond')]\n" ] } ], "source": [ "print(joe.pp())" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "james == james2" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "james == joe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Stances\n", "\n", "Create some stances." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "s1 = stance('gun control')" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "s2 = stance('abortion', 'pro', 'b')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "stance(\"GUN CONTROL\", \"PRO\", \"A\")" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s1" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "stance(\"ABORTION\", \"PRO\", \"B\")" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s2" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(s1)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(s2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Stances contain issue objects" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "issue(\"GUN CONTROL\")" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s1.issue" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(s1.issue)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dict of issues" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'GUN CONTROL': issue(\"GUN CONTROL\"), 'ABORTION': issue(\"ABORTION\")}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "issue.issues" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "issue(\"ABORTION\")" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "issue.issues['ABORTION']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Add goals to agents" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "joe.add_goal(s1)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "joe.add_goal(s2)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "james.add_goal(s1)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "james.add_goal(s2)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tJoe Biden\n", "Friends:\t[agent('James Bond')]\n", "Goals:\t[stance(\"GUN CONTROL\", \"PRO\", \"A\"), stance(\"ABORTION\", \"PRO\", \"B\")]\n" ] } ], "source": [ "print(joe.pp())" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tJames Bond\n", "Friends:\t[agent('Joe Biden')]\n", "Goals:\t[stance(\"GUN CONTROL\", \"PRO\", \"A\"), stance(\"ABORTION\", \"PRO\", \"B\")]\n" ] } ], "source": [ "print(james.pp())" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "mary = agent('Mary')" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "s3 = stance('abortion', 'con', 'a')" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "s4 = stance('gun control', 'con', 'b')" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "mary.add_goal(s3)\n", "mary.add_goal(s4)" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tMary\n", "Goals:\t[stance(\"ABORTION\", \"CON\", \"A\"), stance(\"GUN CONTROL\", \"CON\", \"B\")]\n" ] } ], "source": [ "print (mary.pp())" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mary.agreewith(joe)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "mary.add_friend(joe)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "mary.adopt_goals()" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mary.agreewith(joe)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe.agreewith(james)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe.disagreewith(james)" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe.disagreewith(mary)" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "james.disagreewith(mary)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe.agreewith(mary)" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"PRO\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joe.agreewith(joe)" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"CON\", \"A\"),\n", " stance(\"ABORTION\", \"PRO\", \"B\"),\n", " stance(\"GUN CONTROL\", \"CON\", \"B\"),\n", " stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mary.agreewith(mary)" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"ABORTION\", \"CON\", \"A\"),\n", " stance(\"ABORTION\", \"PRO\", \"B\"),\n", " stance(\"GUN CONTROL\", \"CON\", \"B\"),\n", " stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mary.disagreewith(mary)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### More Examples" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "a1 = agent('Arthur')" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "hw3a.agent" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(a1)" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.count" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.count" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1 in agent.agents" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[agent('Me'),\n", " agent('Republican'),\n", " agent('Democrat'),\n", " agent('James Bond'),\n", " agent('Joe Biden'),\n", " agent('James Bond'),\n", " agent('Mary'),\n", " agent('Arthur')]" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.agents" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Arthur'" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.name" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.friends" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.goals" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.adoptedgoals" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"agent('Arthur')\"" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "repr(a1)" ] }, { "cell_type": "code", "execution_count": 64, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(a1)" ] }, { "cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Name:\\tArthur'" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.pp()" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tArthur\n" ] } ], "source": [ "print(a1.pp())" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [], "source": [ "a2 = agent('Judy')" ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "agent('Judy')" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2" ] }, { "cell_type": "code", "execution_count": 69, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 69, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(a2)" ] }, { "cell_type": "code", "execution_count": 70, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Judy'" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2.name" ] }, { "cell_type": "code", "execution_count": 71, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "hw3a.agent" ] }, "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(a2)" ] }, { "cell_type": "code", "execution_count": 72, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 72, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2 in agent.agents" ] }, { "cell_type": "code", "execution_count": 73, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9" ] }, "execution_count": 73, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2.count" ] }, { "cell_type": "code", "execution_count": 74, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 74, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.count" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1 in a2.friends" ] }, { "cell_type": "code", "execution_count": 76, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2 in a1.friends" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [], "source": [ "a1.add_friend(a2)" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1 in a2.friends" ] }, { "cell_type": "code", "execution_count": 80, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2 in a1.friends" ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Name:\\tJudy\\nFriends:\\t[agent('Arthur')]\"" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a2.pp()" ] }, { "cell_type": "code", "execution_count": 82, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name:\tJudy\n", "Friends:\t[agent('Arthur')]\n" ] } ], "source": [ "print(a2.pp())" ] }, { "cell_type": "code", "execution_count": 83, "metadata": {}, "outputs": [], "source": [ "b1 = stance('gun control')" ] }, { "cell_type": "code", "execution_count": 84, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "issue(\"GUN CONTROL\")" ] }, "execution_count": 84, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1.issue" ] }, { "cell_type": "code", "execution_count": 85, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "stance(\"GUN CONTROL\", \"PRO\", \"A\")" ] }, "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1" ] }, { "cell_type": "code", "execution_count": 86, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 86, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(b1)" ] }, { "cell_type": "code", "execution_count": 87, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'PRO'" ] }, "execution_count": 87, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1.side" ] }, { "cell_type": "code", "execution_count": 88, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'A'" ] }, "execution_count": 88, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1.importance" ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "hw3a.stance" ] }, "execution_count": 89, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(b1)" ] }, { "cell_type": "code", "execution_count": 90, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(b1) == stance" ] }, { "cell_type": "code", "execution_count": 91, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 91, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1.count" ] }, { "cell_type": "code", "execution_count": 92, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9" ] }, "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stance.count" ] }, { "cell_type": "code", "execution_count": 93, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 93, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1 in stance.stances" ] }, { "cell_type": "code", "execution_count": 94, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"GUN CONTROL\", \"PRO\", \"A\"),\n", " stance(\"ABORTION\", \"PRO\", \"B\"),\n", " stance(\"GUN CONTROL\", \"PRO\", \"A\"),\n", " stance(\"ABORTION\", \"PRO\", \"B\"),\n", " stance(\"ABORTION\", \"CON\", \"A\"),\n", " stance(\"GUN CONTROL\", \"CON\", \"B\"),\n", " stance(\"ABORTION\", \"CON\", \"A\"),\n", " stance(\"GUN CONTROL\", \"CON\", \"B\"),\n", " stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stance.stances" ] }, { "cell_type": "code", "execution_count": 96, "metadata": {}, "outputs": [], "source": [ "b2 = b1.copy()" ] }, { "cell_type": "code", "execution_count": 97, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1 == b2" ] }, { "cell_type": "code", "execution_count": 98, "metadata": {}, "outputs": [], "source": [ "b3 = stance('gun control', 'con', 'b')" ] }, { "cell_type": "code", "execution_count": 99, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "stance(\"GUN CONTROL\", \"CON\", \"B\")" ] }, "execution_count": 99, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b3" ] }, { "cell_type": "code", "execution_count": 100, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(b3)" ] }, { "cell_type": "code", "execution_count": 101, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 101, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1 == b3" ] }, { "cell_type": "code", "execution_count": 102, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 102, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b1 != b3" ] }, { "cell_type": "code", "execution_count": 103, "metadata": {}, "outputs": [], "source": [ "a1.add_goal(b1)" ] }, { "cell_type": "code", "execution_count": 104, "metadata": {}, "outputs": [], "source": [ "b4 = stance('bill of rights')" ] }, { "cell_type": "code", "execution_count": 105, "metadata": {}, "outputs": [], "source": [ "b5 = stance('public health')" ] }, { "cell_type": "code", "execution_count": 106, "metadata": {}, "outputs": [], "source": [ "b6 = stance('SCOTUS appointments')" ] }, { "cell_type": "code", "execution_count": 107, "metadata": {}, "outputs": [], "source": [ "a1.add_goal(b4)\n", "a2.add_goal(b5)\n", "a2.add_goal(b6)" ] }, { "cell_type": "code", "execution_count": 108, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 108, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b4 in a1.goals" ] }, { "cell_type": "code", "execution_count": 109, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b5 in a1.goals" ] }, { "cell_type": "code", "execution_count": 110, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 110, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b5 in a2.goals" ] }, { "cell_type": "code", "execution_count": 102, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 102, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b6 in a2.goals" ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"BILL OF RIGHTS\", \"PRO\", \"A\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 111, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.agreewith(a1)" ] }, { "cell_type": "code", "execution_count": 112, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.agreewith(a2)" ] }, { "cell_type": "code", "execution_count": 113, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 113, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.disagreewith(a2)" ] }, { "cell_type": "code", "execution_count": 106, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 106, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.disagreewith(a1)" ] }, { "cell_type": "code", "execution_count": 114, "metadata": {}, "outputs": [], "source": [ "a3 = agent('Tom')" ] }, { "cell_type": "code", "execution_count": 115, "metadata": {}, "outputs": [], "source": [ "c1 = stance ('gun control', 'con', 'b')" ] }, { "cell_type": "code", "execution_count": 116, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "stance(\"GUN CONTROL\", \"CON\", \"B\")" ] }, "execution_count": 116, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c1" ] }, { "cell_type": "code", "execution_count": 117, "metadata": {}, "outputs": [], "source": [ "a3.add_goal(c1)" ] }, { "cell_type": "code", "execution_count": 118, "metadata": {}, "outputs": [], "source": [ "a1.add_friend(a3)" ] }, { "cell_type": "code", "execution_count": 119, "metadata": {}, "outputs": [], "source": [ "a1.adopt_goals()" ] }, { "cell_type": "code", "execution_count": 120, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"PUBLIC HEALTH\", \"PRO\", \"A\"),\n", " stance(\"SCOTUS APPOINTMENTS\", \"PRO\", \"A\"),\n", " stance(\"GUN CONTROL\", \"CON\", \"B\")]" ] }, "execution_count": 120, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.adoptedgoals" ] }, { "cell_type": "code", "execution_count": 121, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"GUN CONTROL\", \"CON\", \"B\"), stance(\"GUN CONTROL\", \"PRO\", \"A\")]" ] }, "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1.disagreewith(a1)" ] }, { "cell_type": "code", "execution_count": 122, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[stance(\"GUN CONTROL\", \"CON\", \"B\")]" ] }, "execution_count": 122, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a3.agreewith(a1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.7" } }, "nbformat": 4, "nbformat_minor": 4 }