Mike McGann on Fri, 2 May 2008 07:20:37 -0700 (MST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [s-d] Play Without Work


Logo is still around? Isn't that the thing where you moved the turtle around
on the VIC-20? I should play around with that when I get a chance. Of
course, I've been saying that for years now about Python.

It is much nicer to show the state that way instead of using tables or
preformatted text. Trontrails should be simple enough that parsing the
mailing list won't be necessary. One move per nweek is the pace I like.

- Hose

On Thu, May 1, 2008 at 7:15 PM, Jay Campbell <bnomic@xxxxxxxxxxxxxxx> wrote:

> I whipped up a little chess tracker in NetLogo, random example output
> here:
>
> http://jaycampbell.com/nomic/chessview.png
>
> I can expand this (e.g. track real owner) and make it listen to the
> mailing list for specific commands.
>
> Then we could vote in additions like Hose's trontrails.
>
> Here's the source so far if anybody wants a peek. It's enough to help me
> run the MoP till I throw a some regexp in front of it to parse
> plain(ish) English.
>
> =========
>
> globals [ commander flipper ]
> turtles-own [ health team owner piece-type ]
>
> to setup
>  clear-all
>  set commander "Nobody" ;; by default
>  paint-chess-board
> end
>
> to test
>  setup
>  set commander "jayc"
>  join
>  repeat 20 [ purchase ]
> end
>
> to purchase
>  let new-piece-type item random 20 [ "pawn"  "pawn" "pawn" "pawn"
> "pawn" "pawn" "pawn" "pawn" "pawn" "pawn"
>                        "rook" "rook" "rook" "knight" "knight" "knight"
> "bishop" "bishop" "bishop" "queen" ]
>  create-turtles 1 [ awaken new-piece-type ]
> end
>
> to awaken [new-piece-type]
>  set owner commander
>  set piece-type new-piece-type
>  set health 100
>  set color random 160
>  set shape (word "chess " piece-type)
>  set size 0.7
>  set label who
>
>  ifelse piece-type = "king"
>    [find-safe-patch]
>    [find-safe-patch]
> end
>
> to join
>  ifelse any? turtles with [piece-type = "king" and owner = commander]
>     [ print "This commander already has a King object" ]
>     [ create-turtles 1 [ awaken "king" ]]
> end
>
> to find-safe-patch
>   let counter 0
>   let target 0
>   let candidate 0
>
>   while [ counter < 100 ]
>     [
>       set counter counter + 1
>       set candidate patch random-pxcor random-pycor
>       if count turtles-on candidate = 0
>         [ set target candidate
>           set counter 100 ]
>     ]
>
>   ifelse is-patch? candidate
>     [ move-to candidate ]
>     [ print "Unable to place piece after 100 tries." ]
> end
>
> to paint-chess-board
>  let x 0 let y 0 set flipper false
>  while [ x <= 20 ] [ set y 0
>    while [ y <= 20 ] [
>      ask patch x y [
>         ifelse flipper [ set pcolor gray set flipper false ]
>                        [ set pcolor white set flipper true ]
>      ] set y y + 1
>    ] set x x + 1
>  ]
> end
>
> _______________________________________________
> spoon-discuss mailing list
> spoon-discuss@xxxxxxxxx
> http://lists.ellipsis.cx/mailman/listinfo/spoon-discuss
>
_______________________________________________
spoon-discuss mailing list
spoon-discuss@xxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/spoon-discuss