Skip to content

Commit

Permalink
Merge pull request #78 from ASPP/improved-draw_coords
Browse files Browse the repository at this point in the history
Improved draw_coords function
  • Loading branch information
Debilski authored Jul 12, 2024
2 parents 1e33474 + 2e7909d commit 8502934
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions notebooks/nb1_matplotlib_and_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
},
"outputs": [],
"source": [
"def draw_coords(coords, ax, params={}):\n",
"def draw_coords(ax, coords, **params):\n",
" \"\"\"\n",
" Takes a list of coordinates and draws them as scatter elements onto a pyplot ax object\n",
"\n",
" Input:\n",
" - coords: list of tuples of x,y coordinates\n",
" - ax: a pyplot ax object\n",
" - coords: list of tuples of x,y coordinates\n",
" - params: parameters to be passed to the scatter function (e.g. shape, size, color, etc.)\n",
" Returns:\n",
" - ax: a pyplot ax object\n",
Expand Down Expand Up @@ -104,7 +104,7 @@
" - bot : pelita bot object\n",
" - ax : a pyplot axis object\n",
" Returns:\n",
" -ax : a pyplot axis object\n",
" - ax : a pyplot axis object\n",
" \"\"\"\n",
" # Depending which team we are, we need to color the board appropriately\n",
" if bot.is_blue:\n",
Expand All @@ -124,13 +124,13 @@
"\n",
" # Then we call the draw_coords function for each type of element we want to draw.\n",
" # Each can be customized with whichever color, shape and size you want.\n",
" ax = draw_coords([bot.position], ax, {\"c\": col_home_b1, \"marker\": \"*\", \"s\": 400})\n",
" ax = draw_coords(bot.walls, ax, {\"c\": \"black\", \"marker\": \"s\", \"s\": 250})\n",
" ax = draw_coords([bot.other.position], ax, {\"c\": col_home_b2, \"marker\": \"*\", \"s\": 400})\n",
" ax = draw_coords(bot.food, ax, {\"c\": col_home_food, \"s\": 100})\n",
" ax = draw_coords(bot.enemy[0].food, ax, {\"c\": col_enemy_food, \"s\": 100})\n",
" ax = draw_coords([bot.enemy[0].position], ax, {\"c\": col_enemy_b1, \"marker\": \"*\", \"s\": 400})\n",
" ax = draw_coords([bot.enemy[1].position], ax, {\"c\": col_enemy_b2, \"marker\": \"*\", \"s\": 400})\n",
" ax = draw_coords(ax, [bot.position], c=col_home_b1, marker=\"*\", s=400)\n",
" ax = draw_coords(ax, bot.walls, c=\"black\", marker=\"s\", s=250)\n",
" ax = draw_coords(ax, [bot.other.position], c=col_home_b2, marker=\"*\", s=400)\n",
" ax = draw_coords(ax, bot.food, c=col_home_food, s=100)\n",
" ax = draw_coords(ax, bot.enemy[0].food, c=col_enemy_food, s=100)\n",
" ax = draw_coords(ax, [bot.enemy[0].position], c=col_enemy_b1, marker=\"*\", s=400)\n",
" ax = draw_coords(ax, [bot.enemy[1].position], c=col_enemy_b2, marker=\"*\", s=400)\n",
" ax.axvline(np.sum(ax.get_xlim()) / 2, c=\"black\")\n",
" # This is to get the coordinate system to have it's origin in the top left\n",
" yd, yu = ax.get_ylim()\n",
Expand Down

0 comments on commit 8502934

Please sign in to comment.