{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### <p style=\"text-align: right;\"> &#9989; **Put your name here** </p>\n",
    "#### <p style=\"text-align: right;\"> &#9989; Put your group member names here</p>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Day 18 In-Class Assignment: Agent Based Modeling of Superbugs (part 2)\n",
    "\n",
    "<img src=\"http://abstrusegoose.com/strips/you_down_wit_OPC-yeah_you_know_me.png\" width=600px>\n",
    "<p style=\"text-align: right;\">Amusing comic from: http://abstrusegoose.com/ </p>\n",
    "\n",
    "1. **Scientific motivation** \n",
    "    - Antibacterial Resistance\n",
    "    - Digital Evolution\n",
    "2. **Modeling tools** \n",
    "    - Agent Based Modeling\n",
    "    - Asking Scientific questions\n",
    "3. **Programming concepts** \n",
    "    - Exploration, Using other peoples code\n",
    "    - Inheritance and Object Oriented programming\n",
    "4. **Python Programming Concepts** \n",
    "    - Practice with Python Classes and Inheritance\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Agenda for today's class\n",
    "\n",
    "1. Review pre-class assignment\n",
    "1. Revisit your assignment from last class\n",
    "1. Understanding other people's code\n",
    "1. Running the simulation\n",
    "1. Testing Scientific Questions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "# 1. Review pre-class assignment\n",
    "\n",
    "Let's discuss any issues with or questions about the pre-class assignment."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "# 2. Revisit your assignment from the last class\n",
    "\n",
    "Take the beginning of class to review the progress you made last week on initializing your petri dish. If you didn't finish it, try to finish it. If you finished it, review your code and think about ways you might be able to make it better. Reviewing your own code will sometimes feel like looking at someone else's code. You might find that your \"present self\" isn't a huge fan of how your \"past self\" did things (especially if your past self didn't leave you any comments!)\n",
    "\n",
    "Copy your code into this notebook and try to get your petri dish code working or make improvements to a functioning version."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# CODE GOES HERE!\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----\n",
    "# 3. Understanding other people's code\n",
    "\n",
    "In the last class we spent a lot of time working toward building a simulation of the Harvard antibacterial resistance experiment. To start lets import one possible solution to this simulation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import superbugs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** Explore the above software, but **don't just look at the code right now**. Use standard exploration commands (e.g. use help, dir, type, or ? in your notebook) to see if you can figure out what the code does. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# put your exploration code here.\n",
    "superbugs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** Using the superbugs code, initialize the experiment and display the first time step of the board."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# put your initialization code here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----\n",
    "# 4. Running the Simulation\n",
    "\n",
    "&#9989; **Do This:** Using the petri_dish variable initialized above, write an loop that runs the ```timestep``` function followed by the ```draw``` function 10 times.  Make sure to animate the figure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Put your code here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** This simulation gets slower as it runs.  **Comment out the plotting and animation code and rerun the simulation with 100 iterations.**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Question**: Do you notice a change in the simulation run time?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font size=8 color=\"#009600\">&#9998;</font> Do This - Erase the contents of this cell and replace it with your answer to the above question!  (double-click on this text to edit this cell, and hit shift+enter to save the text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Question**: What if you wanted to know exactly how long it took to run the simulation? We've used the `time` module before in our animation code, but we can also use it to time how long certain pieces of code take to run. We can record an initial time with something like:\n",
    "\n",
    "`start = time.time()`\n",
    "\n",
    "And then record the time the code finishes with:\n",
    "\n",
    "`end = time.time()`\n",
    "\n",
    "Try adding this to your code above to time exactly how long the simulation took. Add a line to **print the total run time at the end**. Try comparing the total run time to the simulation that includes the plotting and animation components.\n",
    "\n",
    "What is the difference in the timing between the versions with and without the plotting?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font size=8 color=\"#009600\">&#9998;</font> Do This - Erase the contents of this cell and replace it with your answer to the above question!  (double-click on this text to edit this cell, and hit shift+enter to save the text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Question**: What if you wanted to know how long each step of the simulation took (i.e. each iteration of the loop)? How would you track this information in your code? **If you have time, try implementing some code that tracks the time that each step took and prints the end results.**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. Testing Scientific Questions\n",
    "\n",
    "For the remainder of the class, we are going to use this code to ask some scientific questions."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** Discuss as a group/class the types of scientific question can you ask of this type of simulation.  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font size=8 color=\"#009600\">&#9998;</font> Do This - Erase the contents of this cell and replace it with your answer to the above question!  (double-click on this text to edit this cell, and hit shift+enter to save the text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Question:** Given the above questions, what types of measurements or modifications might we need to add to the superbug code? "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font size=8 color=\"#009600\">&#9998;</font> Do This - Erase the contents of this cell and replace it with your answer to the above question!  (double-click on this text to edit this cell, and hit shift+enter to save the text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** Write some code to show, in one graph, the progress of the simulation.  For example, plot the number of iterations on the x axis and the progress the bugs have made toward the center of the simulation on the y axis.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Put your code here.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#9989; **Do This:** Do this, modify or use the simulation in some way that allows you to test a scientific question of the simulation.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# put your scientific experiment code here.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Question** What scientific question does your new usage or modification demonstrate and what can you conclude from the simulation?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font size=8 color=\"#009600\">&#9998;</font> Do This - Erase the contents of this cell and replace it with your answer to the above question!  (double-click on this text to edit this cell, and hit shift+enter to save the text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "-----\n",
    "### Congratulations, we're done!\n",
    "\n",
    "Now, you just need to submit this assignment by uploading it to the course <a href=\"https://d2l.msu.edu/\">Desire2Learn</a> web page for today's submission folder (Don't forget to add your names in the first cell).\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "&#169; Copyright Michigan State University Board of Trustees"
   ]
  }
 ],
 "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.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
