无法删除netlogo扫雷器代码

无法删除netlogo扫雷器代码,netlogo,minesweeper,Netlogo,Minesweeper,我是netlogo的新手,尝试通过将瓷砖改为六边形而不是方形来扩展扫雷舰代码。我似乎无法获得清除所有适当瓷砖或设置所有应设置标签的清除程序。我是如何解释它的工作原理的,当调用clear时,首先会有单击的六边形骰子,如果存在标记,那么它也会骰子,然后它要求每个六边形计算其上有炸弹的邻居的数量,并将其总变量设置为该数,如果总数大于0,则应使用该数字标记自身,否则也应清除该数字。我错过了什么 globals [ clock ;; how many seconds the g

我是netlogo的新手,尝试通过将瓷砖改为六边形而不是方形来扩展扫雷舰代码。我似乎无法获得清除所有适当瓷砖或设置所有应设置标签的清除程序。我是如何解释它的工作原理的,当调用clear时,首先会有单击的六边形骰子,如果存在标记,那么它也会骰子,然后它要求每个六边形计算其上有炸弹的邻居的数量,并将其总变量设置为该数,如果总数大于0,则应使用该数字标记自身,否则也应清除该数字。我错过了什么

globals [
  clock             ;; how many seconds the game has lasted so far
  game-started?     ;; initially false, becomes true when player first presses GO
  game-over?        ;; initially false, becomes true if the player loses
  ;;total
]

breed [ hexagons hex ]    ;; these are the green squares the player hasn't tested yet
hexagons-own [hex-neighbors]
breed [ mines mine ]             ;; the mines (initially invisible)
breed [ markers marker ]          ;; show where the player thinks mines are

to setup
  clear-all
  set clock 0
  set game-started? false
  set game-over? false
  set-default-shape hexagons "hex"

  set-default-shape mines "bomb"
  set-default-shape markers "flag"
  ask patches
    [ sprout-hexagons 1
        [ set color magenta + 3 ;; 
        ;; shift even columns down
          if pxcor mod 2 = 0
            [ set ycor ycor - 0.5 ] 
         ]
        set pcolor sky - 3
     ]
  ;; now set up the hex-neighbors agentsets
  ask hexagons
    [ ifelse pxcor mod 2 = 0
        [ set hex-neighbors hexagons-on patches at-points [[0 1] [1 0] [1 -1] [0 -1] [-1 -1] [-1       0]] ]
        [ set hex-neighbors hexagons-on patches at-points [[0 1] [1 1] [1  0] [0 -1] [-1  0] [-1 1]] ] ]


  ;; make the number of mines determined by the mine-count slider
  ask n-of mine-count patches [
    sprout-mines 1 [
      set color black
      if pxcor mod 2 = 0
            [ set ycor ycor - 0.5 ]
      hide-turtle
    ]
  ]

  top-scores
  reset-ticks
end

to go
  if game-over? [
    ask markers with [any? mines-here] [ die ]
    ask markers [ set color gray  - 2 ]
    ask mines [ show-turtle ]
    set game-over? true
    ask patches [ set pcolor red ]
    stop
  ]
  if not game-started? [
    ;; this must be the first time through GO, so start the clock
    reset-timer
    set game-started? true
  ]
  set clock timer
  if all? hexagons [any? mines-here] [
    ;; you win!!!
    ask mines [ show-turtle ]
    ask patches [ set pcolor blue ]
    write-to-file
    stop
  ]
  if mouse-down? [
    ask patch (mouse-xcor) (mouse-ycor) [
      ifelse any? mines-here
        [ set game-over? true ]   ;; aiggghhhh!
        [ clear ]                 ;; whew!
    ]
  ]
  tick
end

to clear  ;; patch procedure
  ask hexagons-here [ die ]
  ask markers-here [ die ]
  ask hexagons
    [let total count hex-neighbors with [any? mines-here]
      ifelse total > 0
        [set plabel word total "  "]          
    ;; if none of our neighbors have mines on them, then they can
    ;; be cleared too, to save the user from extra clicking
        [ ask hex-neighbors with [any? hexagons-here]
          [ clear ] ]]

end

to mark/unmark
  if not mouse-inside? [ stop ]
  ask patch mouse-xcor mouse-ycor [
      if any? hexagons-here [
      ifelse any? markers-here
        [ ask markers-here [ die ] ]
        [ sprout-markers 1 [ set color yellow ]] ] ]
end


to write-to-file
  file-open "highScores.txt"
  file-print (word "Bomb count: " mine-count "     Time: " clock)
  file-print("")
  file-close
end


to top-scores
  file-open "highScores.txt"
  while [not file-at-end?]
  [output-print file-read-line]
  file-close
end

您能否更具体地说明您所面临的编码问题的具体内容和位置?我相信问题在于清晰的程序。特别与十六进制的邻居有关。它应该让六边形检查附近地区是否有炸弹,如果有标签,如果没有,那么is应该清除这些六边形。我遇到的问题是,并不是所有应该清除的六边形都被清除了,也不是所有靠近炸弹的海龟都被贴上了标签。