<commit_before>extensions [nw]

breed [nodes node]
breed [halos halo]

nodes-own [ node-radius node-max-degree node-degree ]

;; Setup the environment
to setup
  clear-all
  set-default-shape turtles "default"
  set-default-shape halos "thin ring"
  create-nodes nodes-number
  ask nodes [ ;; make the turtle initial position random to spread them out on the torus
    setxy random-xcor random-ycor 
    ifelse ( all-different = true ) [ ;; if all-different is set every node has got different radius and max-degree
      set node-radius random radius
      set node-max-degree random max-degree
    ]
    [
      set node-radius radius
      set node-max-degree max-degree
    ]
    set node-degree 0 
    make-halo node-radius
  ] 
  reset-ticks
end


to make-halo [ halo-radius ]  ;; node procedure
  ;; when you use HATCH, the new turtle inherits the
  ;; characteristics of the parent.  so the halo will
  ;; be the same color as the turtle it encircles (unless
  ;; you add code to change it
  hatch-halos 1
  [ set size halo-radius
    ;; Use an RGB color to make halo three fourths transparent
    set color lput 64 extract-rgb color
    __set-line-thickness 0.2
    ;; We create an invisible directed link from the node
    ;; to the halo.  Using tie means that whenever the
    ;; runner moves, the halo moves with it.
    create-link-from myself
    [ tie
      hide-link ] ]
end

;; Move each node as many moves-no as set
to move [ moves-no ]
  repeat moves-no [
    ask nodes[
      rt random 360
      fd 1
    ]
    tick
  ]
end
@#$#@#$#@
GRAPHICS-WINDOW
380
5
1067
666
18
17
36.86
1
14
1
1
1
0
1
1
1
-18
18
-17
17
0
0
1
ticks
30.0

SLIDER
6
62
179
95
radius
radius
1
100
11
1
1
NIL
HORIZONTAL

SLIDER
195
15
368
48
max-degree
max-degree
1
100
5
1
1
NIL
HORIZONTAL

SLIDER
6
14
179
47
nodes-number
nodes-number
1
100
9
1
1
NIL
HORIZONTAL

BUTTON
7
285
130
322
Setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

BUTTON
152
285
276
323
Step
move step-size
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

SLIDER
195
62
368
95
step-size
step-size
1
100
1
1
1
NIL
HORIZONTAL

SWITCH
12
115
162
148
all-different
all-different
0
1
-1000

@#$#@#$#@
## WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

## HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

## HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

## THINGS TO NOTICE

(suggested things for the user to notice while running the model)

## THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

## EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

## NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
<commit_msg>to fix connection<commit_after>extensions [nw]

breed [nodes node]
breed [halos halo]
undirected-link-breed [halolinks halolink]
undirected-link-breed [connections connection]


;;nodes local vars
nodes-own [ node-radius node-max-degree node-degree ]



to make-halo [ halo-radius ]  ;; node procedure
  ;; when you use HATCH, the new turtle inherits the
  ;; characteristics of the parent.  so the halo will
  ;; be the same color as the turtle it encircles (unless
  ;; you add code to change it
  hatch-halos 1
  [ set size halo-radius + 2 ;; the +1 its just for visualization purposes
    ;; Use an RGB color to make halo three fourths transparent
    set color lput 64 extract-rgb color
    __set-line-thickness 0.2
    ;; We create an invisible undirected link from the node
    ;; to the halo.  Using tie means that whenever the
    ;; runner moves, the halo moves with it.
    create-halolink-with myself
    [ tie
      hide-link ] ]
end

;; Setup the environment
to setup
  clear-all
  set-default-shape turtles "default"
  set-default-shape halos "thin ring"
  create-nodes nodes-number
  ask nodes [ ;; make the turtle initial position random to spread them out on the torus
    setxy random-xcor random-ycor
    ifelse ( all-different = true ) [ ;; if all-different is set every node has got different radius and max-degree
      set node-radius ( (random radius) + 1 )
      set node-max-degree ( (random max-degree) + 1 )
    ]
    [
      set node-radius radius
      set node-max-degree max-degree
    ]
    set node-degree 0 
    make-halo node-radius
  ] 
  reset-ticks
end

;; Move each node as many moves-no as set
to move [ moves-no ]
  repeat moves-no [
    ask nodes[
      rt random 360
      fd 1
    ]
    tick
  ]
end

;;link the node with node in its radius
to link-neighbours
  ask nodes[
    if ( node-degree < node-max-degree) [  
      let prev-links-no count connections
      
      ask other nodes in-radius node-radius [ connect myself ] ;;ask just found node to connect
      
      if ( count connections > prev-links-no )[ ;;let's check if the node has been truly connected
        set node-degree node-degree + 1
      ]  
    ]
  ]
end

to connect [ from-node ] 
  print "request from node" 
  print from-node
  print "to"
  print who
  
  ifelse ( node-degree < node-max-degree) [
    create-connection-with from-node
    set node-degree node-degree + 1
  ][
    show my-connections 
    ask one-of my-connections [ die ]
    set node-degree node-degree - 1
  ]
end
@#$#@#$#@
GRAPHICS-WINDOW
386
14
825
440
18
17
23.46
1
14
1
1
1
0
1
1
1
-18
18
-17
17
0
0
1
ticks
30.0

SLIDER
6
62
179
95
radius
radius
1
100
11
1
1
NIL
HORIZONTAL

SLIDER
195
15
368
48
max-degree
max-degree
1
100
1
1
1
NIL
HORIZONTAL

SLIDER
6
14
179
47
nodes-number
nodes-number
1
100
3
1
1
NIL
HORIZONTAL

BUTTON
7
285
130
322
Setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

BUTTON
152
285
270
322
Step
move step-size\nlink-neighbours
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

SLIDER
195
62
368
95
step-size
step-size
1
100
3
1
1
NIL
HORIZONTAL

SWITCH
12
115
162
148
all-different
all-different
1
1
-1000

BUTTON
8
337
130
370
Go
move 1\nlink-neighbours
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1

@#$#@#$#@
## WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

## HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

## HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

## THINGS TO NOTICE

(suggested things for the user to notice while running the model)

## THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

## EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

## NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

{'fraction_non_alphanumeric': 0.0667433831990794, 'fraction_numerical': 0.04919447640966628, 'mean_word_length': 2.9349179400113186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5026816', 'n_tokens_mistral': 2686, 'n_tokens_neox': 2408, 'n_words': 1025}