battle shape with communication

No preview image

1 collaborator

Default-person HYOSEONG SEO (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 69 times • Downloaded 6 times • Run 0 times
Download the 'battle shape with communication' modelDownload this modelEmbed this model

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


Comments and Questions

I want to add a communication function to the battle model. Please help.

1. Allied and enemy bases exist as centers 2. Relay stations are displayed as patches (want to be displayed at random locations) 3. When each object of the allies and enemies is randomly located in the relay station and the number of relay stations reaches 10 Allies attack the enemy's center, and the enemy attacks the friendly center. 4. If the cneter is destroyed first, you lose. In the end, I want to show that the closer the relay station is, the faster it gathers, and the quicker it is to attack the center to achieve the goal. I'm a newbe so I'm not good at it. Is there an expert who can fix the code? help

Posted over 1 year ago

I want to add a communication function to the battle model. Please help.

1. Allied and enemy bases exist as centers 2. Relay stations are displayed as patches (want to be displayed at random locations) 3. When each object of the allies and enemies is randomly located in the relay station and the number of relay stations reaches 10 Allies attack the enemy's center, and the enemy attacks the friendly center. 4. If the cneter is destroyed first, you lose. In the end, I want to show that the closer the relay station is, the faster it gathers, and the quicker it is to attack the center to achieve the goal. I'm a newbe so I'm not good at it. Is there an expert who can fix the code? help

Posted over 1 year ago

Click to Run Model

globals [
  allies
  enemies
]
patches-own [
  pheromone            ;; amount of pheromone on this patch
  center                ;; amount of food on this patch (0, 1, or 2)
  relaystation
]

turtles-own [
  team
  health
]

to setup
  clear-all
  set-default-shape turtles "person"
  setup-center
  setup-relaystation
  reset-ticks
end 

to setup-center
  ask patch (0.8 * min-pxcor) (0.8 * max-pycor) [
    set plabel "Alies center"
    make-center-source blue
  ]
  ask patch(0.8 * max-pxcor) (0.8 * min-pycor) [
    set plabel "Enemies center"
    make-center-source red
  ]
end 

to make-center-source [ center-source-color ] ;; patch procedure
  ask patches with [ distance myself < 5 ] [
    set center 2
    set pcolor center-source-color
  ]
end 

to setup-relaystation
  ask patch (0.7 * min-pxcor) (0.3 * max-pycor) [
    set plabel "relaystation1"
    make-relaystation-source sky
  ]
  ask patch (0.7 * max-pxcor) (0.7 * max-pycor) [
    set plabel "relaystation3"
    make-relaystation-source green
  ]
  ask patch(0.7 * max-pxcor) (0.3 * min-pycor) [
    set plabel "relaystation2"
    make-relaystation-source orange
  ]
  ask patch (0.7 * min-pxcor) (0.7 * min-pycor) [
    set plabel "relaystation4"
    make-relaystation-source green
  ]
end 

to  make-relaystation-source [ relaystation-source-color ] ;; patch procedure
  ask patches with [ distance myself < 5 ] [
    set relaystation 2
    set pcolor relaystation-source-color
  ]
end 

to create-person
  create-turtles 1 [
    set team "allies"
    setxy -35 35
    set health 10
    set color blue
    set size 4
  ]
    create-turtles 1 [
    set team "enemies"
    setxy 35 -35
    set health 10
    set color red
    set size 4
  ]
end 

to go
  if count turtles < population [ create-person ]
  ask turtles [
    if health <= 0 [die]
    move
    attack
    move-towards-relaystation
  ]
  tick
end 

to move
  wander
end 

to wander  ;; turtle procedure
  rt random 40
  lt random 40
  if not can-move? 1 [ rt 180 ]
  fd 1
end 

to move-towards-relaystation
  let relaystation-patch nobody
  let gather-threshold 10

  if team = "allies" [
    set relaystation-patch min-one-of patches with [plabel = "relaystation1" or plabel = "relaystation2" or plabel = "relaystation3" or plabel = "relaystation4"] [distance myself]
  ]
  if team = "enemies" [
    set relaystation-patch min-one-of patches with [plabel = "relaystation1" or plabel = "relaystation2" or plabel = "relaystation3" or plabel = "relaystation4"] [distance myself]
  ]

  if relaystation-patch != nobody [
    if count turtles-on relaystation-patch < gather-threshold [
      face relaystation-patch
      fd 1
    ]
    ; 추가된 부분
    if count turtles-on relaystation-patch = gather-threshold [
      ; gather-threshold에 도달했을 때 움직임을 멈추도록 설정
      stop
    ]
  ]
end 

to attack
  let target one-of other turtles-here with [team != [team] of myself]
  if target != nobody [
    ask target [
      set health health - 10
    ]
  ]
end 

to attack-center [center-label x y]
  let target-center patch x y
  if target-center != nobody and [plabel] of target-center = center-label [
    ask target-center [
      set center 0 ; center를 0으로 변경하여 공격한 것을 표시
    ]
  ]
end 

There is only one version of this model, created over 1 year ago by HYOSEONG SEO.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.