No preview image

1 collaborator

Army_coat_pix R. Wade Schuette (Author)



Tagged by R. Wade Schuette over 1 year ago


"this model show how to re-use control scripts"

Tagged by R. Wade Schuette over 1 year ago


Tagged by R. Wade Schuette over 1 year ago


Tagged by R. Wade Schuette over 1 year ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 71 times • Downloaded 4 times • Run 0 times
Download the 'automater' 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

This won't run over the web

This model uses File I/O which means you cannot run it over the web. If you download it, it should run just fine

Posted over 1 year ago

Help! The command file is missing!

You can generate your own command file, such as the one called test-01-input.txt in the model. Three sample lines are shown at the top of the code in the notes. Just copy and paste those lines into a new text file, remove the semicolons, and save the file.

Posted over 1 year ago

Click to Run Model

;; Please read HOW TO USE IT in the INFO tab!

;; the sample command file is called test-01-input.txt and contains the following lines, without the
;; semicolons
;;  print "This is just a test command file"
;;  repeat 4 [go]
;;  clean-up-files  stop
;; this code will generate such a file if you want it to, over-writing any old one of that name

globals [
  working-directory   ;; the operating system working directory
  command-file        ;; where the commands will be read from
  output-file         ;; optional, where output from the go step can be written
  log-file            ;; a log of what commands were executed
  run-title           ;; whatever you want to name this run
  show-commands-as-run?        ;; controls whether you want to see commands as they are run
  use-sample-input-file?       ;; if true, generates a file called test-01-input.txt to use
                               ;; as input for this model.
                               ;; This will destroy an existing file of that name!

to setup

  set run-title "Automated validation example"
  print (word run-title "\n"  "at " date-and-time "\n" )

  set show-commands-as-run? false  ;; shows each command as it is read in from the command file

to automate-run

  if not file-exists? command-file  [ type "Can't find the command file: " print  command-file stop]
  print " "
  print (word " is set to " show-commands-as-run? )
  print ".....Reading command input now..."

  repeat 10000  ;;  reads this many lines from the command-file, if available.
    ;; read the next command from the command file
    file-open command-file
    if  file-at-end? [ clean-up-files stop]
    let line file-read-line

    ;; track progress in the log file
    file-open log-file

    ;; ok to comment out the next line
    file-print (word "Executing: " line)

    ;; track the upcoming command in the Command Center if you want to
    ;; ok to comment out the next line
    if show-commands-as-run? = true [print (word "..................................Executing: " line) ]

    ;; execute that command
    run line

    ;; track completion of the command in the Command Center if you want to
    ;; print (word "...............................Executed: " line)

to go
  create-turtles 1 [ set size 3 setxy random-xcor random-ycor]

  ;; your code may produce output.  Here's how to do that
  file-open output-file
  file-print "executed the go command once"


to set-up-files

  ;; replace these with the path name and file-names of your own files

  set working-directory "C:\\Users\\condor\\Google Drive\\ABModels\\models\\netlogo\\caveman\\versions\\automater"

  if (working-directory = "C:\\Users\\condor\\Google Drive\\ABModels\\models\\netlogo\\caveman\\versions\\automater")
  [ user-message "You MUST set your own working directory in the set-up-files section!"]

  ;; possibly
  ;; set working-directory ""  ;; use the directory containing the model engine itself

  set command-file "test-01-input.txt"   ;; this file should exist
  set output-file "test-01-output.txt"   ;; this can be missing. If it exists it will be replaced.
  set log-file "test-01-log.txt"         ;; this can be missing. If it exists it will be replaced.

  print ("Using these files defined in set-up-files ")
  print (word "working directory: " working-directory)
  print (word "commands : "  command-file )
  print (word "output   : "  output-file)
  print (word "log      : "  log-file   )

  set-current-directory working-directory  ;; has to be done where file-at-end? is trested

  ;; open files for writing

  if  file-exists?   log-file  [ file-delete log-file  ]
  file-open log-file
  file-print run-title
  file-print date-and-time
  file-print "  "

  if  file-exists?   output-file [ file-delete output-file  ]
  file-open output-file
  file-print run-title
  file-print date-and-time
  file-print " "

to init-log
  file-open log-file
  file-print (word "current directory: " working-directory)
  file-print (word "commands : "  command-file)
  file-print (word "output   :"  output-file)
  file-print (word "log      :"  log-file)
  file-print " "

to clean-up-files
   print ".....Finished reading control input"
   print ".....Cleaning up"

;; Written by R. Wade Schuette 10-November-2019
;; no copyright is claimed.

There is only one version of this model, created over 1 year ago by R. Wade Schuette.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.