# Rugby

### 1 collaborator

Uri Wilensky (Author)

### Tags

mathematics

Tagged by Reuven M. Lerner about 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 558 times • Downloaded 89 times • Run 0 times

## WHAT IS IT?

"In rugby, after a try has been scored, the scoring team has the opportunity to gain further points by 'kicking a conversion'. The kick can be taken from anywhere on an imaginary line that is perpendicular to the try line (aka the goal line) and goes through the location on the try line where the try was scored. Where should the kick be taken from to maximize the chance of a score?"

## HOW IT WORKS

Instead of trying to solve this problem with calculus or geometry, we'll take a probabilistic approach and use NetLogo turtles and patches. Essentially, we'll have a player stand on each patch along the imaginary kick line (the vertical yellow line), and kick many balls in random directions. Players receive one 'point' for each conversion they score. The idea is that since each kick-angle is randomly chosen, those players who score the most points must be standing in the best positions.

Note that this approach is quite different from the analytic approach. In the standard mathematical solution, one is expected to equate the best chance of scoring with the maximal angle from the kick line to the goal. In the probabilistic solution, this is not assumed. It emerges as the result if the playing field is assumed to be uniform. If, however, the model is extended to include wind or grass grain or decaying kick speeds, this solution adjusts gracefully in contrast to the brittle analytic solution.

## HOW TO USE IT

We use three sliders to initialize the model:

• GOAL-SIZE determines the size of the goal.
• GOAL-POS is the x-coordinate of the left goal-post. It is placed GOAL-POS units away from the leftmost edge of the world.
• KICK-LINE determines the x-coordinate of the kick-line. The kick line is KICK-LINE units away from the leftmost edge of the world.

The left goal-post is at `(goal-pos - 0.5, min-pycor - 0.5)`, and the right goal-post is at `(goal-pos + goal-size - 0.5, min-pycor - 0.5)`. (0.5 is the horizontal or vertical distance between the center of the patch and its edge; this is needed because the goal posts are effectively in the corners of their patches.)

Note that the values of KICK-LINE, GOAL-SIZE, and GOAL-POS may need to be adjusted to fit your current world-width.

Press the SETUP button to initialize the model, after you've chosen appropriate values for the sliders. You'll see one rugby ball on each patch on the try line. When you're ready to star, press the GO forever-button. This will commence the kicking; rounds will be repeated and results accumulated until you stop the GO button. Two monitors show the distance of the winning player, and the distance the analytic solution says should be the winner. Two other monitors display how many balls have been kicked and how many resulted in goals.

Watch the left-hand side of the playing field as the model runs. A histogram is being plotted of total points scored from each position along the kick line. The best scores (to date) for each round are highlighted in yellow (and their distance fromm the goal-line is displayed just to their right)-- the others are drawn in blue.The patch that is theoretically calculated to have the best score is shown in magenta and its distance is also displayed alongside it to the right.

In addition to the sequence of rounds described above, if you turn on the SHOW-LEVEL-CURVES? slider and press SETUP, you will see the level-curves associated with the given set of slider settings. This allows you to visualize the field of solutions for the analytic case of a uniform field. Patches are colored according to how large the goal looks from that position. Along each connected curve of the same color, the goal appears to be the same size. From straight ahead, the goal appears maximally wide. From a shallow angle, the goal looks smaller at the same distance along the try line.

## THINGS TO NOTICE

Given a particular goal-line and kick-line, what are the best positions to kick from? Change the position and size of the goal. How do the 'best positions' change in relation to the goal's position? Then change the position of the kick line, and redo the trial. How does the performance compare when the kick line is farther away? Or closer?

Examine the histogram at the left side of the world. What do you notice about it? What shape does it have? What does it tell you about the best locations to kick from?

How does the experimental solution compare to the analytic solution? Given enough time, will the experimental solution converge to the analytic solution? If so, how long does it take?

## THINGS TO TRY

Can you generalize the results given by the model? What are the relationships between the kick-line, the goal, and the best patch to kick from?

Re-read the problem description given in the first paragraph of "What Is It?" Do you think that this model adequately answers the question asked? Why or why not? What alternative solutions could you provide?

It's important to understand that this NetLogo project isn't exactly the standard method for solving problems of this sort. (A more 'classical' approach would be to use techniques from geometry or calculus.) However, there are many advantages offered by the NetLogo method. Consider the following other variables that might affect the solution to the problem: wind speed, grass height, or the size/weight/skill of the player kicking. (Such a problem that considers 'real-world' parameters such as these may quickly become intractable under classical mathematics.) Try and think of how you'd solve the 'rugby' problem in its idealized version without using NetLogo. Then try and solve it, taking into account one or more of these extra features.

In general, what advantages does the NetLogo solution have over the other methods? What disadvantages does it have?

## EXTENDING THE MODEL

Implement some of the features descibed above under "Things To Try"- e.g. wind speed, or the size of the player to kick the conversion from a particular position.

There are a variety of plots you could have 'rugby' draw in a plot. Implement plotting procedures for some or all of the following: the number of successful kicks compared to the overall kicks, the plot of both types of kicks over time, or the difference in histograms depending on the locations of the kick-line (i.e. the value of KICK-LINE) and the goal-posts (GOAL-POS and GOAL-SIZE).

## NETLOGO FEATURES

We draw our histogram straight to the view, unlike most other NetLogo models where the histogram is drawn in a separate plot.

In order to make the actual patch coordinate system more consistent with the conceptual coordinate system (the distances used in the model). The origin is at the bottom left corner of the world, so all coordinates are positive.

## CREDITS AND REFERENCES

The problem is taken from a British mathematics textbook.

For a fuller discussion, see Wilensky, U. (1996). Modeling Rugby: Kick First, Generalize Later? International Journal of Computers for Mathematical Learning. Vol. 1, No. 1. p. 124 - 131. http://ccl.northwestern.edu/cm/papers/rugby/

## 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:

• Wilensky, U. (1997). NetLogo Rugby model. http://ccl.northwestern.edu/netlogo/models/Rugby. 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.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was developed at the MIT Media Lab using CM StarLogo. See Wilensky, U. (1993). Thesis - Connected Mathematics: Building Concrete Relationships with Mathematical Knowledge. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project. Adapted to NetLogo, 2001, as part of the Participatory Simulations Project.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

Click to Run Model

```turtles-own [start-patch] ;; original position of ball on kick line
patches-own [score        ;; score for this position along the kick line
left-angle   ;; angle towards left goal-post
right-angle  ;; angle towards right goal-post
goal-angle   ;; size of arc between left-angle and right-angle
slope]       ;; slope of line from this patch towards a goal-post
globals [current-max      ;; the best patch-score so far
col              ;; current color for our level-curves
ang              ;; viewing angle of the current level curve
best-dist        ;; distance from try-line of best kick
analytic         ;; what the best distance should be, analytically
try-line         ;; agentset containing only those patches on the try line
histogram-area   ;; agentset containing only patches inside the histogram
kicks            ;; total number of balls kicked
goals]           ;; total number of goals scored

;; the origin of this model is set in the bottom left corner so
;; the y distance to the goal corresponds to the y-coordinate of the patch
;; this makes many of the calculations simpler.

to setup
clear-all
setup-field
setup-balls
set current-max 0
set best-dist -1
set kicks 0
ask try-line [ set score 0 ]
find-analytic-solution
if show-level-curves? [ draw-level-curves ]
reset-ticks
end

to setup-field
;; Draw lines for border, kick line, and goal line
if count neighbors != 8
[set pcolor red ]
if (pycor = min-pycor) and
(pxcor >= goal-pos) and
(pxcor < (goal-pos + goal-size))
[set pcolor green]
]
set try-line patches with [ pxcor = kick-line and pcolor = black ]
ask try-line [ set pcolor yellow ]
set histogram-area patches with [ pxcor < kick-line and pcolor = black ]
end

;; turtle procedure that resets all balls to kick line at end of each round

to setup-balls
set-default-shape turtles "circle"
[ sprout 1
[ set color orange
set start-patch patch-here
set heading (random-float 90) + 90 ] ]
plot-scores
end

to go
while [any? turtles] [
display
]
set kicks kicks + count try-line
set goals sum [score] of try-line
setup-balls
tick
end

;; turtle procedure that moves all balls

to move
;; for speed, only check success/failure once we're near the
;; edge of the playing field
if pxcor >= max-pxcor - 1 or pycor >= min-pycor + 1
[ ;; in this model we approximate continuous motion by making
;; the turtles jump forward a step at a time.  but this can
;; throw the results off a little because sometimes a ball
;; will jump over the corner of a patch.  so to get correct
;; results, we need to check two patches.  "next-patch" is
;; the patch we would hit if we actually moved continuously.
;; "patch-ahead 1" is the patch we're going to land on when
;; we make our discrete jump.
check-patch next-patch
fd 1
end

to check-patch [the-patch]  ;; turtle procedure
if ([pcolor] of the-patch = red)
[ die ]       ;; the ball has hit the border wall
if ([pcolor] of the-patch = green) ;; the ball has reached the goal
[ ;; increment the number of times a goal has been scored from this point on the kick line
[ set score score + 1 ]
die ]
end

;; see Next Patch Example, in the Code Examples section of
;; the Models Library, for a discussion of this code.

to-report next-patch  ;; turtle procedure
if heading < towardsxy (pxcor + 0.5) (pycor + 0.5)
[ report patch-at 0 1 ]
if heading < towardsxy (pxcor + 0.5) (pycor - 0.5)
[ report patch-at 1 0 ]
if heading < towardsxy (pxcor - 0.5) (pycor - 0.5)
[ report patch-at 0 -1 ]
if heading < towardsxy (pxcor - 0.5) (pycor + 0.5)
[ report patch-at -1 0 ]
report patch-at 0 1
end

;; do histogramming in the view

to plot-scores
;; set the maximum goals scored from any patch
set current-max (max [score] of try-line)
if current-max = 0
[
ask histogram-area [ set pcolor black ]
stop  ; otherwise we'll get division-by-zero errors below
]
ifelse score = current-max
[ set best-dist pycor
ask patch-at 2 0 [ set plabel pycor ] ]
[ if pcolor != magenta
[ ask patch-at 2 0 [ set plabel "" ] ] ]
]
[;; make the histogram bar
ifelse  pxcor > (kick-line - (([score] of patch-at (kick-line - pxcor) 0) * (kick-line - min-pxcor) / current-max))
;; make the yellow histogram bars at the maximal locations
[ifelse ([score] of patch-at (kick-line - pxcor) 0 = current-max)
[set pcolor yellow]
;; other locations get blue bars
[set pcolor blue] ]
[set pcolor black]
]
end

to find-analytic-solution
ask patches with [pycor > min-pycor]
[ calc-goal-angle ]
;; calculate the analytic solution for best kicking point
let winning-patch min-one-of try-line [goal-angle]
[ set pcolor magenta
ask patch-at 2 0 [ set plabel pycor ] ]
set analytic [ pycor ] of winning-patch
end

to draw-level-curves
ask patches with [(pxcor > kick-line) and (pcolor < 10) ]
[ if goal-angle > 270
[ set pcolor (360 - goal-angle mod 10) * 0.8 ] ]
end

;; calculate angle between patch and goal

to calc-goal-angle
set left-angle  towardsxy (goal-pos - 0.5)
(min-pycor + 0.5)
set right-angle towardsxy (goal-pos + goal-size - 0.5)
(min-pycor + 0.5)
set goal-angle (right-angle - left-angle) mod 360
end

```

There are 11 versions of this model.

Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 12 years ago Updated version tag Download this version
Uri Wilensky almost 12 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 12 years ago Updated to NetLogo 5.0 Download this version