BeerGame

BeerGame preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 224 times • Downloaded 16 times • Run 0 times
Download the 'BeerGame' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This is an adaptation of a popular game created at MIT in the early 1960s that shows how small delays in a distribution system can create big problems. The participants take on one of four roles in a distribution network for root beer -- the factory, the distributor, the wholesaler, or the retailer. Each participant places and ships orders while trying to keep their costs to minimum. Costs include the holding inventory as well as missing out on sales because you produced too little root beer.

HOW IT WORKS

The game is played in one-week rounds and the players are dividing into teams of four. Each team is a supply chain that consists of a retailer, a wholesaler, a distributor, and a factory. At the beginning of each week, every player on a team faces a demand for root beer that comes from the person downstream from him or her in the supply chain. The demand originates from the (invisible) root beer drinkers who create demand for the retailer every week.

At the end of each week, if you have enough inventory to meet your demand, then the demanded quantity is automatically shipped out of your inventory to the player downstream from you. If you don't have enough cases in inventory to meet demand from the player upstream from you (or from the public if you are the retailer), then a backorder is created. Each backordered case costs the player $1.00 in lost sales opportunity. Each case in inventory costs the player $0.50 to store. The goal of the game is to minimize cost.

As a player, each week you must decide how many cases to order from the person upstream from you. Placing orders creates additional demand for your upstream supplier the next week, but it does not immediately replenish your inventory. There is time lag because of a shipping delay between you and your upstream supplier. (If you are the factory, placing an order is equivalent to producing the root beer, and the lag is due to the time to produce the product.) Once all players have placed orders for the week, time advances to the next week and the product you are shipping goes out the door. Your cost for the week is also calculated and reported.

HOW TO USE IT

Press the SETUP button and then the GO button and have all the participants login. Explain that each week, each role needs to ship cases of root beer based on the demand they face, as well as place orders to replenish their inventory to the desired level. Explain also how costs are accrued and that the goal is to minimize costs. It is a good idea to play a few weeks together until the participants get acquainted with the client interface and the actions needed in each round.

Buttons and Sliders: SETUP - Resets the simulation to the initial conditions and the clock to zero.

GO - Listens for input from clients. Should be pressed to run the simulation.

WEEKS-OF-SIMULATION - Sets the number of rounds in the game.

PERIODS-OF-DELAY - Set the number of weeks between when one player sends an order and the next player in the line receives the order

Plots: COST - Plots the instantaneous cost of each team where cost equals $0.50 per case in inventory plus $1.00 per back-ordered case. ORDERS SHIPPED - Plots the number of orders shipped from the retailer each week. ORDERS TO FACTORY - Plots the number of order produced by the factory each week.

Client Interface: Each client is a member of a TEAM identified by a color; all teams have four members. Each client is assigned a ROLE in that team which is determined by his or her position in the supply chain, the first player to login is the retailer and the last is the factory. Players start out with an initial INVENTORY of 12 and an initial order of 4.

To change the amount of the order you want to place, move the ORDERS-TO-PLACE slider and press the PLACE-ORDER button. The amount of your last order placed appears in the ORDER-PLACED monitor. You can only place one order per week, once you have done so the ORDER-PLACED? monitor will display true, and it will not let you place another order until everyone on your team as placed an order, which ends the week. When the week ends everyone ships and you will receive goods from your supplier the amount you receive will be displayed in the LAST-AMOUNT-RECEIVED monitor, and it will be added to your inventory. The amount you ship is displayed in the LAST-AMOUNT-SHIPPED monitor. At the end of the week if your inventory does not meet the demand the extra orders will become BACK-ORDERS. Finally, the order placed by the player that you supply in the previous week will become your new DEMAND, unless you are the retailer, then you will see the true demand of the public.

Your instantaneous cost is displayed in the MY-COST monitor, this includes all goods that you have shipped but have not yet arrived at their intended destination.

THINGS TO NOTICE

Look at the resulting orders shipped and orders to factory plots. Are the levels fairly constant or fluctuating? Have the retailer record the demand he or she faces each week. Are the changes in the orders shipped and orders to the factory plots map similar to the fluctuations in demand?

THINGS TO TRY

As a team, can you create a strategy that keeps your inventory from fluctuating more than the customer demand? Does it get easier or harder if you increase the PERIODS-OF-DELAY?

EXTENDING THE MODEL

Create a supply chain that is not linear and has multiple players for each role, perhaps introducing competition within roles.

Create a non-HubNet version of this game using the System Dynamics Modeler.

NETLOGO FEATURES

This activity uses NetLogo's network support to move the goods from stage to stage. Each player as a supply link from the player below them in the chain and a demand link from the play above them in the chain. Orders are placed on the demand links and received on the supply links.

RELATED MODELS

Investments Public Good

CREDITS AND REFERENCES

For a discussion of the original MIT Beer Game and additional suggestions for discussion points, see http://web.mit.edu/jsterman/www/SDG/beergame.html

For a bibliography of the beer game in academic publications (last revised July 1992), see http://www.solonline.org/?page=BeerGameBiblio

For instructions and materials for running the original board game version, see http://www.solonline.org?item_id=456354

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Copyright 2003 Uri Wilensky and Walter Stroup.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This activity and associated models and materials were created 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.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  colors         ;; the available team colors (don't use all of them for aesthetic reasons)
  color-names    ;; the colors in words
  roles          ;; the names of the possible roles on each team
]

;; each client is represented by a player turtle
breed [ players player ]
players-own
[
  user-id
  inventory
  back-orders       ;; at the end of each week back-orders will be calculated if
                    ;; your inventory does not meet the demand
  my-team
  order             ;; a direct reflection of the value in the ORDERS-TO-PLACE
                    ;; slider on the client this changes any time the user moves the slider
  last-received     ;; the last number of cases added to your inventory
  order-placed?     ;; whether or not you've placed an order this week, once you have placed an
                    ;; order you cannot change it until the next week. Once all players on a team
                    ;; have placed an order the week is advanced.
  role              ;; factory, distributor, wholesaler, or retailer depending on
                    ;; your place in the chain
  ordered           ;; the number of cases of root beer ordered this week,
                    ;; once you have pressed the PLACE-ORDER button on the client
                    ;; you cannot change this number until next week
]

;; there are four players per team the team breed
;; is mainly used to keep track of information
breed [ teams team ]
teams-own
[
  members       ;; the number of members on the team
  cost          ;; the instantaneous cost of the entire team at the end of the last week.
  demand        ;; the number of cases requested by the public
  last-player   ;; keep track of the last player in the chain so it's easy to add players
  color-name
  clock         ;; each team has their own clock since the end of the week occurs
                ;; only when all players have placed an order
  last-received ;; the last number of cases added to inventory
  inventory     ;; the number of cases currently stored by this player
]

;; there are two types of links in the game
;; there are links that players use to request root beer
;; from the players up the chain, the demand links,
;; and the supply links move the goods from
;; one player to another.

directed-link-breed [ supply-links supply-link ]
supply-links-own
[
  orders-filled ;; a list PERIODS-OF-DELAY long, each time the source player ships the current order
                ;; is placed on the end of the list and the order at the beginning of the list is
                ;; popped off and added to the destination player's inventory
]

directed-link-breed [ demand-links demand-link ]
demand-links-own
[
  orders-placed  ;; the number of cases requested by the player at the source,
                 ;; this is the demand for the player at the destination end of the link
]

;;
;; Setup Procedures
;;

to startup
  hubnet-reset
  ;; setup basic appearance globals
  set-default-shape players "circle"
  set-default-shape teams "square"
  set colors [ red blue green violet pink orange brown yellow ]
  set color-names [ "red" "blue" "green" "violet" "pink" "orange" "brown" "yellow" ]
  set roles [ "retailer" "distributor" "wholesaler" "factory" ]
  setup
end 


;; start the game over with the same players
;; initial conditions, each player has placed an order of 4
;; and has an inventory of 12.

to setup
  ask supply-links
    [ set orders-filled n-values periods-of-delay [ 0 ]  ]
  ask demand-links
    [ set orders-placed 4 ]
  ask teams [
    set cost 0
    set clock 1
    if not any? out-demand-link-neighbors
    [ die ]
  ]
  ask players
  [
    set inventory 12
    set back-orders 0
    set last-received 0
    set order-placed? false
    set color [color] of my-team + 2
    set ordered 4
    update-player
  ]
  reset-plot
end 

;;
;; Runtime Procedures
;;

to go
  ;; the flow of the activity is completely controlled by actions
  ;; of the clients. when everyone on the team has placed an order
  ;; the entire team moves on the next week. Teams may be on different days
  listen-to-clients
  every 0.1
  [
    display
  ]
end 

to listen-to-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [ create-new-student ]
    [
      ifelse hubnet-exit-message?
      [ remove-student ]
      [
        execute-command hubnet-message-tag
      ]
    ]
  ]
end 

to end-week ;; team procedure
  ;; calculate the cost for the entire team
  set cost sum [ inventory * 0.5 + back-orders ] of
                   players with [ my-team = myself ]

  plot-cost
  plot-shipped
  ;; the last player is the factory
  ask last-player [ plot-orders ]

  ;; update the external demand to the retailer that drives the game
  ask my-out-demand-links
  [
    ;; the demand starts at 4 cases per week. In week 7 it rises to
    ;; 8 cases and remains there the rest of the time.
    set orders-placed ifelse-value ([clock] of myself <= 5) [ 4 ][ 8 ]
  ]

  ;; produce the goods at the factory level
  let orders-requested sum [ orders-placed ] of my-in-demand-links

  ask my-out-supply-links
  [ set orders-filled lput orders-requested orders-filled ]

  ;; move goods into the factory, even though the factory
  ;; has the ability to produce an infinite amount of goods
  ;; there are still PERIODS-OF-DELAY weeks between the time
  ;; they place the order for goods and the time it is produced.
  ask out-supply-link-neighbors
  [
     set last-received sum [ first orders-filled  ] of my-in-supply-links
     ask my-in-supply-links [ set orders-filled but-first orders-filled ]
     set inventory inventory + last-received
  ]

  ;; everything is purchased on the retailer level
  set inventory 0

  ;; advance the week
  set clock clock + 1
  ;; update the client information for the next round
  ask players with [ my-team = myself ]
  [
    set order-placed? false
    set color [color] of my-team + 2
    ask my-out-demand-links [ set orders-placed [ordered] of myself ]
  ]
end 

to place-order ;; player procedure
  ;; only change the order if we haven't
  ;; done so this week as each player can only
  ;; place 1 order per day and cannot change it
  ;; once it is placed
  if not order-placed?
  [
    set order-placed? true
    set color [color] of my-team
    set ordered order
    update-player
  ]

  let teammates players with [ my-team = [my-team] of myself ]

  ;; once the last player has placed an order
  ;; all players ship and advance the week
  if not any? teammates with [ not order-placed? ]
  [
    ask teammates
    [
      ship
      ask my-out-demand-links
        [ set orders-placed [ordered] of myself ]
    ]
    ask my-team
    [
      if clock <= weeks-of-simulation
      [ end-week ]
    ]
    ;; make sure the info on the client gets updated
    ask teammates
    [ update-player ]
  ]
end 

to ship
  ;; move all the supplies along the chain.
  ask out-supply-link-neighbors
  [
    ;; grab the shipment at the beginning of the list
    ;; and add it to my inventory
    set last-received sum [ first orders-filled  ] of my-in-supply-links
    ask my-in-supply-links
      [ set orders-filled but-first orders-filled ]
    set inventory inventory + last-received
  ]

  ;; determine how many orders you need to send upstream
  ;; this will be no more than the number of orders requested
  ;; plus back orders or your inventory whichever is smaller
  let new-orders [orders-placed] of one-of my-in-demand-links
  let orders-requested new-orders + back-orders

  ;; determine how much we can send given our current inventory
  let orders-to-ship min list orders-requested inventory

  ;; if there's not enough inventory they become back-orders
  set back-orders max list 0 ( back-orders - inventory + new-orders )

  ;; add the shipment to the shipping queue
  ask my-out-supply-links
    [ set orders-filled lput orders-to-ship orders-filled ]
  set inventory inventory - orders-to-ship
end 

;;
;; HubNet Procedures
;;

to create-new-student
  ;; if there are no incomplete teams
  ;; create a new one
  if not any? teams with [ members < 4 ]
  [ create-team ]

  add-student-to one-of teams with [ members < 4 ]
end 

to create-team
 ;; there is one team per row in the world, if
 ;; we've run out of rows the user should
 ;; just make the size of the world larger
 let p one-of patches with [ pxcor = max-pxcor and not any? teams-here ]
 ifelse p != nobody
 [
  create-teams 1
  [
    set members 0
    set cost 0
    set demand 4
    set last-player self
    move-to p
    set-color
    set size 0.5
    create-plot-pens
    set clock 1
  ]
 ]
 [ user-message "There is no more space for a new team, please increase the size of the world" ]
end 

;; grab a random color from the list of distinguishable colors

to set-color
  ;; if the size of the world is increased we have to reuse colors
  if length colors = 0
  [
    set colors [ red blue green violet pink orange brown yellow ]
    set color-names [ "red" "blue" "green" "violet" "pink" "orange" "brown" "yellow" ]
  ]
  let index random length colors
  set color item index colors
  set color-name item index color-names
  set colors remove-item index colors
  set color-names remove-item index color-names
end 

to add-student-to [this-team]
  create-players 1
  [
    set user-id hubnet-message-source
    set label user-id
    set inventory 12
    set back-orders 0
    set order 4
    set ordered 0
    ;; attach the new player to the end of the chain.
    ask [last-player] of this-team
    [
       create-demand-link-to myself
         [ set orders-placed 4 ]
       create-supply-link-from myself
         [ set orders-filled n-values periods-of-delay [ 0 ] ]
    ]
    ;; set up directly left of the current last player
    setxy [xcor] of [last-player] of this-team - 1 [ycor] of [last-player] of this-team
    set my-team this-team
    set role my-role [members] of my-team
    ask this-team
    [
      set last-player myself
      set members members + 1
      ask my-out-supply-links [ die ]
      ask my-in-demand-links [ die ]
      create-supply-link-to myself
        [ set orders-filled n-values periods-of-delay [ 0 ] hide-link ]
      create-demand-link-from myself
        [ set orders-placed 4 hide-link ]
    ]
    set order-placed? false
    set color [color] of this-team + 2
    init-player
  ]
end 

;; set size appropriate to your position in the chain.
;; factories are biggest and retailers smallest
;; report the name of the role

to-report my-role [degree]
  set size degree * 0.1 + 0.5
  report item degree roles
end 

;; if a player leaves the game we may need to
;; get new roles since the new player will be
;; added to the end rather than where the last player left.

to reassign-role
  let degree [xcor] of my-team - xcor - 1
  set role my-role degree
  set role item degree roles
end 

to remove-student
  ask players with [ user-id = hubnet-message-source ]
    [ remove-self ]
end 

to remove-self
  ;; if I am the last player make my neighbor
  ;; to the right the last player
  if [last-player] of my-team = self
  [
    ask my-team
    [
      set last-player [ one-of out-supply-link-neighbors ] of myself
    ]
  ]

  ask my-team
  [
    set members members - 1
    ;; if I am the last player take the team with me.
    if members = 0
    [
      ;; return the colors to the available list
      set colors lput color colors
      set color-names lput color-name color-names
      die
      ;; we've shifted perspective to make the above code
      ;; simpler so we must use myself to kill the player
      ;; as well as the team.  if we're the last player in
      ;; the team we don't have to do the rest of the bookkeeping
      ;; below so we do want to abort immediately
      ask myself [ die ]
    ]
  ]

  ;; if this was the last player on the team this code never
  ;; gets executed because the above code kills the turtle

  ;; players up the chain from me move into their
  ;; new position so there aren't gaps
  let affected-players players with [ my-team = [my-team] of myself and xcor < [xcor] of myself ]
  ask affected-players
    [ set xcor xcor + 1 ]

  ;; link my supply and demand neighbors to
  ;; each other instead of me.
  let n one-of out-supply-link-neighbors
  ask in-supply-link-neighbors
  [
    if n != nobody and not out-supply-link-neighbor? n
    [ create-supply-link-to n
      [ set orders-filled n-values periods-of-delay [ 0 ] ] ]
  ]

  set n one-of out-demand-link-neighbors
  ask in-demand-link-neighbors
  [
    if n != nobody and not out-demand-link-neighbor? n
    [ create-demand-link-to n [] ]
  ]

  ask affected-players
  [
    reassign-role
    init-player
  ]
  die
end 

;; there are only two client actions.
;; moving the ORDERS-TO-PLACE slider
;; and placing the order.

to execute-command [cmd]
  ask players with [ user-id = hubnet-message-source ]
  [
    ;; don't let players keep going once they've reached the
    ;; end of the simulation
    if [clock] of my-team <= weeks-of-simulation
    [
      ;; catch changes to the slider
      ifelse hubnet-message-tag = "orders-to-place"
      [ set order hubnet-message ]
      ;; lock in the order
      [ if hubnet-message-tag = "place-order"
        [
          ask players with [ user-id = hubnet-message-source ]
            [ place-order ]
        ]
      ]
    ]
  ]
end 

;; send everything

to init-player
  hubnet-send user-id "team" [color-name] of my-team
  hubnet-send user-id "role" role
  update-player
end 

;; send the stuff that changes

to update-player
  if [clock] of my-team <= weeks-of-simulation
  [
    hubnet-send user-id "demand" [orders-placed] of one-of my-in-demand-links
    hubnet-send user-id "inventory" inventory
    hubnet-send user-id "back-orders" back-orders
    hubnet-send user-id "my-cost" inventory * 0.5 + back-orders
    hubnet-send user-id "last-amount-shipped" sum [ last orders-filled ] of my-out-supply-links

    hubnet-send user-id "last-amount-received" round last-received
    hubnet-send user-id "week" round [clock] of my-team
    hubnet-send user-id "order-placed?" order-placed?
    hubnet-send user-id "order-placed" ordered
  ]
end 

;;
;; Plotting Procedures
;;

;; use temporary plot pens for each team
;; so the legend is neat and the plot pen color
;; matches the color of the team

to create-plot-pens
  create-plot-pen "Orders to Factory"
  create-plot-pen "Cost"
  create-plot-pen "Orders Shipped"
end 

to create-plot-pen [my-plot]
  set-current-plot my-plot
  create-temporary-plot-pen color-name
  set-plot-pen-color color
end 

to plot-orders
  set-current-plot "Orders to Factory"
  plot last-received
end 

to plot-cost
  set-current-plot "Cost"
  set-current-plot-pen color-name
  plot cost
end 

to plot-shipped
  set-current-plot "Orders Shipped"
  set-current-plot-pen color-name
  plot sum [ last orders-filled ] of my-in-supply-links
end 

;; clearing the plot also clears the temporary
;; plot pens, so recreate them.

to reset-plot
  clear-all-plots
  ask teams [ create-plot-pens ]
end 


; Copyright 2003 Uri Wilensky and Walter Stroup.
; See Info tab for full copyright and license.

There is only one version of this model, created over 2 years ago by Mirosław Drożak.

Attached files

File Type Description Last updated
BeerGame.png preview Preview for 'BeerGame' over 2 years ago, by Mirosław Drożak Download

This model does not have any ancestors.

This model does not have any descendants.