# PANDA BEAR Solo ### 2 collaborators Uri Wilensky (Author) Josh Unterman (Author)

### Tags

mathematics

Tagged by Reuven M. Lerner almost 9 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 200 times • Downloaded 20 times • Run 1 time Download this modelEmbed this model

## WHAT IS IT?

This is a Solo version of the HubNet activity called Perimeters and Areas by Embodied Agent Reasoning, or PANDA BEAR. PANDA BEAR Solo can be used as a standalone activity or as an introduction to PANDA BEAR.

PANDA BEAR is a microworld for mathematics learning that lies at the intersection of dynamic geometry environments and participatory simulation activities. Whereas PANDA BEAR involves many people controlling individual vertices of a shared, group-polygon, in PANDA BEAR Solo, an individual user controls all of the vertices of a polygon. The measures of perimeter and area of the polygon are foregrounded in the environment. The model user can be given challenges regarding the polygon's perimeter and area as suggested in the THINGS TO TRY section.

## HOW TO USE IT

SETUP initializes the model to create a polygon containing NUMBER-VERTICES vertices. GO allows the user to move the vertices around with the mouse. The PERIMETER and AREA monitors update automatically as the vertices move around. The PANDA plot shows both of those measures over time as a record of the user's actions as they work towards a goal. SETUP-PLOT resets the plot to start a new challenge with the same polygon. The MOVE-FD, MOVE-BK, TURN-RIGHT, and TURN-RIGHT buttons change the red vertex's location and heading. The STEP-SIZE and TURN-AMOUNT input boxes control the amount of movement of the MOVE-FD, MOVE-BK, TURN-RIGHT, and TURN-RIGHT buttons.

## THINGS TO NOTICE

In a triangle, for an individual vertex, moving "between" the other two vertices minimizes the perimeter for a given area.

In a triangle, when all three vertices attempt to form an isosceles triangle, and equilateral triangle is formed.

Strategies that work for challenges at the triangle level often work at the square level as well.

As the number of vertices is increased, the polygon that maximizes the area given a perimeter and minimizes the perimeter given an area gets closer and closer to a circle.

## THINGS TO TRY

With three vertices, make the area as big as possible while keeping the perimeter at or below 25.

With three vertices, make the perimeter as small as possible while keeping the area at or above 25.

Increase the number of vertices in the polygon from three to four (and beyond - approaching a circle) and do the above.

Modify the challenges in a patterned way. For example, with four vertices, doubling the allowed perimeter should quadruple the maximum area.

## EXTENDING THE MODEL

Add different methods of movement. For example, instead of turning and going forward and backward, the user could be allowed to move the red vertex in the 4 cardinal directions.

Allow the user to give the vertices movement rules to follow over and over so that the group-polygon "dances".

## NETLOGO FEATURES

This model uses links to form the sides of the polygon, each vertex is linked to exactly two other vertices. The sum of the lengths of all the links is the perimeter of the polygon.

The area calculation is based on information found here: http://mathworld.wolfram.com/PolygonArea.html

PANDA BEAR

## CREDITS AND REFERENCES

Thanks to Josh Unterman for his work on this model.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

• Unterman, J. and Wilensky, U. (2007). NetLogo PANDA BEAR Solo model. http://ccl.northwestern.edu/netlogo/models/PANDABEARSolo. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
• Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL. Click to Run Model

```;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variable and Breed declarations ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

globals [
red-vertex          ;; the red vertex
]

breed [ vertices vertex ]

;; vertices keep track of who is next in line
;; because the area calculation requires it.
vertices-own [ next-vertex ]

;;
;; Setup Procedures
;;

;; Initializes the display, and creates a list that contains the names of the shapes
;; used by turtles in this activity.  Also initializes the data lists.

to setup
clear-all
set-default-shape vertices "circle"
create-vertices number-vertices [
setup-vertex-vars
]
;; one of the vertices is specially controlled by the
;; controls in the interface, designate it here.
set color red
set shape "monster"
set red-vertex self
]
;; make the polygon
ask one-of vertices [ edgify ]
;; update the data in the display
update
end

;; sets the turtle variables to appropriate initial values

to setup-vertex-vars  ;; vertex procedure
set color brown
setxy random-xcor random-ycor
set label-color white
set next-vertex nobody
end

;; recursive procedure that links all the vertices together
;; one at a time.

to edgify
;; each vertex is linked to once and then, in turn links to
;; another vertex that has not yet been linked, when we
;; run out of vertices we've made a line and we just need
;; to close the polygon by linking back to the beginning
let candidates other vertices with [ not any? link-neighbors ]
ifelse any? candidates
[
set next-vertex one-of candidates
]
[
set next-vertex one-of other vertices with [ count link-neighbors = 1 ]
]
end

set color white
set label-color white
]
end

;;
;; Runtime Procedures
;;

to go
if mouse-down? [
;; clicking "picks up" the closest vertex
ask min-one-of vertices [ distancexy mouse-xcor mouse-ycor ] [
;; if the mouse is more than 1 patch away from any
;; vertex just ignore the click.
if distancexy mouse-xcor mouse-ycor < 1
[
while [mouse-down?] [
;; use EVERY to limit how much data we end up plotting
every 0.05 [
;; don't move vertices directly on top of one another
if all? other vertices [ xcor != mouse-xcor or ycor != mouse-ycor ] [
setxy mouse-xcor mouse-ycor
update
]
]
]
]
]
]
end

to update
]
;; make sure the angle is positive
let angle (subtract-headings towards first my-neighbors towards last my-neighbors) mod 360
;; make sure the angle is the interior angle
if angle > 180 [ set angle 360 - angle ]
set label less-precise angle
]
display
update-plots
end

;;; used to keep the labels from having too much cluttering detail

to-report less-precise [ precise-num ]
report precision precise-num 1
end

to-report perimeter
end

;; this area calculation is based on the formula found here:
;; http://mathworld.wolfram.com/PolygonArea.html

to-report area
let result 0
let addend ((xcor * [ycor] of next-vertex) -
(ycor * [xcor] of next-vertex))
]
report abs (result / 2)
end

;; red-vertex commands

to move-fd
;; pre-check that no other vertices are on the point we're headed to
let new-xcor (xcor + step-size * dx)
let new-ycor (ycor + step-size * dy)
if all? vertices [xcor != new-xcor or ycor != new-ycor] [
fd step-size
]
]
update
end

to move-bk
;; pre-check that no other vertices are on the point we're headed to
let new-xcor (xcor + step-size * (- dx))
let new-ycor (ycor + step-size * (- dy))
if all? vertices [xcor != new-xcor or ycor != new-ycor] [
bk step-size
]
]
update
end

to turn-right
rt turn-amount
]
end

to turn-left
lt turn-amount
]
end

```

There are 10 versions of this model.

Uri Wilensky over 9 years ago Updated version tag Download this version
Uri Wilensky over 9 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 10 years ago Updated to NetLogo 5.0 Download this version