📄 ---model.nlogo
字号:
; ]; ; ] if mouse-down? [ set startx mouse-xcor set starty mouse-ycor while [mouse-down?] [ cct 1 [ set draw_turtle self ] ask draw_turtle [ set color green set xcor startx set ycor mouse-ycor stamp color die ] cct 1 [ set draw_turtle self ] ask draw_turtle [ set color red set ycor starty set xcor mouse-xcor stamp color die ] set endx mouse-xcor set endy mouse-ycor ] cct 1 [ set draw_turtle self ] ask draw_turtle [ set color red set xcor startx + 1 set ycor starty while [ xcor < endx ] [ set heading 180 repeat (starty - endy) [ fd 1 set areas fput current_area areas ifelse pcolor = 0 [set pcolor 59] [set pcolor pcolor + 20] ] set xcor xcor + 1 set ycor starty ] die ] cct 1 [set draw_turtle self] ask draw_turtle [ set color yellow set xcor mouse-xcor set ycor mouse-ycor pd set heading 0 fd starty - endy lt 90 fd endx - startx die ] cct 1 [set draw_turtle self] ask draw_turtle [ set color blue set xcor mouse-xcor set ycor mouse-ycor pd set heading 270 fd endx - startx rt 90 fd starty - endy die ] set current_area current_area + 1 ; change_biases]endto send_shapeslocals [move_turtle to_go] foreach values-from nodes [self] [ ask ? [ hatch 1 [ set size 5 set heading towardsxy 0 0 set move_turtle self ] ask move_turtle [ set to_go 0 while [ to_go < 100 ][ fd 1 set to_go to_go + 1 ] die ] ] ] endto change_biases ; node procedurelocals [in_node] ask nodes with [member? 0 areas] [ set in_node self ask nodes with [member? 0 areas and self != myself] [ set biases replace-item who biases (item who biases * bias) ] ] ; [set shape_inventory replace-item 3 shape_inventory (item 3 shape_inventory + quant) ] endto set-environment if environ = "in-out" [ cp ask patches [ set areas[] if (pycor >= (- screen-edge-y + 10) and pycor <= screen-edge-y and pxcor >= (0 - 10) and (pxcor <= screen-edge-x - 12)) [set areas[0] set pcolor pcolor + 61] if ((pycor = (- screen-edge-y + 10) or pycor = screen-edge-y) and (pxcor >= (0 - 10) and (pxcor <= screen-edge-x - 12))) [ set pcolor red ] if ((pycor >= (- screen-edge-y + 10) and pycor <= screen-edge-y) and ((pxcor = screen-edge-x - 12) or pxcor = (0 - 10) ))[ set pcolor red ] ; draw the collocating red box on the screen if on-screen-data? [ ; this is a short proceedure to draw a line around the area where the data is if (pxcor = (- screen-edge-x + 10 )) [ set pcolor 45] ] ] ] if environ = "travelers" [ cp ask patches [ set areas[] if ((pycor >= (- screen-edge-y + 55) and pycor <= screen-edge-y) and ((pxcor <= screen-edge-x - 12) and pxcor >= (- screen-edge-x + 12))) [set areas[0] set pcolor pcolor + 11.1 ] ; colors the patches if ((pycor = (- screen-edge-y + 55) or pycor = screen-edge-y) and (((pxcor <= screen-edge-x - 12) and pxcor >= (- screen-edge-x + 12)) or pxcor = (- screen-edge-x + 12 ))) [ set pcolor blue ] ; draw top line and bottom line if ((pycor >= (- screen-edge-y + 55) and pycor <= screen-edge-y) and ((pxcor = screen-edge-x - 12) or pxcor = (- screen-edge-x + 12 )))[ set pcolor blue ] ; draw left and right lines ; draw the collocators blue box on the screen if on-screen-data? [ ; this is a short proceedure to draw a line around the area where the data is if (pxcor = (- screen-edge-x + 10 )) [ set pcolor 45] ] ] ] if environ = "doubles" [ cp ask turtles with [shape = "circle"] [ set heading heading + 180 fd 25 without-interruption [ foreach out-edges [ ask ? [ reposition ] ] foreach in-edges [ ask ? [reposition ] ] ] ] ask patches [ set areas[] if (pycor >= (- screen-edge-y + 20) and pycor <= screen-edge-y and pxcor >= (0 - 10) and pxcor <= (screen-edge-x - 12)) [set areas[0] set pcolor pcolor + 101] if ((pycor = (- screen-edge-y + 20) or pycor = screen-edge-y) and (pxcor >= (0 - 10) and pxcor <= (screen-edge-x - 12))) [ set pcolor green ] if ((pycor >= (- screen-edge-y + 20) and pycor <= screen-edge-y) and ((pxcor = screen-edge-x - 12) or pxcor = (0 - 10) ))[ set pcolor green ] ; draw the collocating red box on the screen if on-screen-data? [ ; this is a short proceedure to draw a line around the area where the data is if (pxcor = (- screen-edge-x + 10 )) [ set pcolor 45] ] ] ]set current_area current_area + 1endto update-totals set run_c_c run_c_c + c_c ; this procedures updates the running totals from the current experiment set run_c_t run_c_t + c_t set run_t_c run_t_c + t_c set run_t_t run_t_t + t_t set run_c_inv run_c_inv + c_inv set run_t_inv run_t_inv + t_invendto log-round-data cct-round-data 1 [ set shape "box" set color ((current_round * 10) + 5) set size 5 set xcor ( - screen-edge-x + 7) set ycor ( - screen-edge-y + 5 + (current_round * 5 )) set col-col c_c set col-tel c_t set tel-col t_c set tel-tel t_t set col_inventory c_inv set tel_inventory t_inv set label current_round ] update-data-summary endto update-data-summary ask round-data with [label = "S"] ;;; this code will append to the summary turtle the data from the current round [ set cc-list lput c_c cc-list set ct-list lput c_t ct-list set tc-list lput t_c tc-list set tt-list lput t_t tt-list set cinv-list lput c_inv cinv-list set tinv-list lput t_inv tinv-list ]end;--------------begninning of t-test procedure--------------;purpose: do t-test;when called: during the play;called by: the "run-exhaustive-t-tests" procedure;receives: two lists of data;returns: none;remarks: to ttest [y1list y2list] ; the purpose of this proceedure is to return whether there is a significant difference between two resuts. locals [s1 s2 y1bar y2bar n1 n2 s sd tvalue df ttable critical] set ttable [100 12.706 4.303 3.182 2.776 2.571 2.447 2.365 2.306 2.262 2.228 2.201 2.179 2.160 2.145 2.131 2.120 2.110 2.101 2.093 2.086 2.08 2.074 2.069 2.064 2.06 2.056 2.052 2.048 2.045 2.042 2.021 2 1.98 1.96] ; two-tail critical values at 0.05 set s1 variance y1list set s2 variance y2list set y1bar mean y1list set y2bar mean y2list set n1 length y1list set n2 length y2list set df (n1 - 1) + (n2 - 1) set s ((n1 - 1) * s1 + (n2 - 1) * s2) / ((n1 - 1) + (n2 - 1)) set sd sqrt (s * (n1 + n2) / (n1 * n2)) set tvalue abs (y1bar - y2bar) / sd if (df <= 30) [set critical item df ttable if (tvalue > critical) [set stat-flag true ] ] if (df > 30 and df <= 40) [set critical item 31 ttable if (tvalue > critical) [set stat-flag true; show "Statistical significance found" ]; [show "Not Statistically significant"] ] if (df > 40 and df <= 60) [set critical item 32 ttable if (tvalue > critical) [set stat-flag true; show "Statistical significance found" ]; [show "Not Statistically significant"] ] if (df > 60 and df <= 120) [set critical item 33 ttable if (tvalue > critical) [set stat-flag true ] ] if (df > 120) [set critical item 34 ttable if (tvalue > critical) [set stat-flag true ] ] end;---------------------end of t-test procedure---------------------------to run-exhaustive-t-tests locals [flag? test-list-1 test-list-2 cc-temp ct-temp tc-temp tt-temp cinv-temp tinv-temp] set flag? false; set up four local list with the infomation from the summary stat turtle, this will be easier to manipulate ask round-data with [label = "S"] [ set cc-temp cc-list set ct-temp ct-list set tc-temp tc-list set tt-temp tt-list set cinv-temp cinv-list set tinv-temp tinv-list ] ; run the six different test conditions and if any of them are significant, set significance reporter to true ttest cc-temp ct-temp set cc-ct-stat false if (stat-flag) ;; this little if statment is just a kluge to set the individual flags [ set flag? true set cc-ct-stat true set stat-flag false ] ttest cc-temp tc-temp set cc-tc-stat false if (stat-flag) [ set flag? true set cc-tc-stat true set stat-flag false ] ttest cc-temp tt-temp set cc-tt-stat false if (stat-flag) [ set flag? true set cc-tt-stat true set stat-flag false ] ttest ct-temp tc-temp set ct-tc-stat false if (stat-flag) [ set flag? true set ct-tc-stat true set stat-flag false ] ttest tt-temp ct-temp if (stat-flag) [ set flag? true set ct-tt-stat true set stat-flag false ] ttest tt-temp tc-temp set tc-tt-stat false if (stat-flag) [ set flag? true set tc-tt-stat true set stat-flag false ] ttest cinv-temp tinv-temp set col-tel-stat false if (stat-flag) [ set flag? true set col-tel-stat true set stat-flag false ] if (flag?) [set stat-flag true] endto make-summary-data-turtle ; the purpose of this function is to get information from the data-turtles to use for the t-test cct-round-data 1 [ set shape "Circle" set color 133 set size 8 set xcor ( - screen-edge-x + 5) set ycor ( - screen-edge-y + 4) set cc-list [] set ct-list [] set tc-list [] set tt-list [] set cinv-list [] set tinv-list [] set label "S" ]end@#$#@#$#@GRAPHICS-WINDOW496101241
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -