Craig Maloney snapl@identi.ca

Just another Linux / Ubuntu / Python hacker. Host of http://openmetalcast.com and co-host of http://lococast.net

  • [Blog] Day 25/100: Accepting Input

    2017-06-26T01:15:28Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/fLbDLlGN6iE/)

    Today I made some strides in getting this to accept input. It's starting to look like a game now:

    #lang racket
    
    #| Init Block |#
    
    (define tiles '())
    (define die1 0)
    (define die2 0)
    (define turn-number 1)
    (define took-turn #f)
    (define end-of-game #f)
    
    (define (start-game)
    (set! tiles '(1 2 3 4 5 6 7 8 9)))
    
    (define (dice)
    (+ 1 (random 6)))
    
    (define (dice-roll)
    (set! die1 (dice))
    (set! die2 (dice)))
    
    (define (sum-of-dice)
    (+ die1 die2))
    
    (define (sum-of-tiles tilelist)
    (apply + tilelist))
    
    (define (list-check l1 l2)
    (andmap (lambda (x) (not (boolean? (memq x l2)))) l1))
    
    (define (shut-tiles tilelist)
    (if (not took-turn) 
        (if (list-check tilelist tiles)
        (for ([i tilelist])
            (if (index-of tiles i)
                (begin
                (set! tiles (remove i tiles))
                (set! took-turn #t))
                (error "Tile already shut")))
        (println "Tile not available to be shut"))
    (println "Already took your turn")))
    
    (define (check-roll dice-sum tile-sum)
    (= dice-sum tile-sum))
    
    (define (player-turn tilelist)
    (if (check-roll (sum-of-dice) (sum-of-tiles tilelist))
        (shut-tiles tilelist)
        (println "Roll does not equal shut tiles. Try again.")))
    
    (define (my-read-line)
    (let ([contents (read-line)])
        (if (string=? contents "")
        (read-line)
        contents)))
    
    (define (input) 
    (map string->number (string-split (my-read-line))))
    
    (define (next-turn)
    (set! turn-number (+ 1 turn-number))
    (set! took-turn #f)
    (dice-roll)
    (show-turn))
    
    (define (show-turn)
    (printf "Turn: ")
    (println turn-number)
    (println tiles)
    (printf "Dice roll ~v ~v = ~v\n" die1 die2 (sum-of-dice) ))
    
    (start-game)
    (dice-roll)
    (let loop()
    
    (show-turn)
    (define tilelist (input))
    (player-turn tilelist)
    (next-turn)
    (when (not end-of-game) (loop))
    )
    
  • [Blog] Day 24/100: Small Steps

    2017-06-25T03:12:47Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/9ghleyeYaDg/)

    Did a little bit more on my presentation, but nothing earth-shattering. Read some more of The Little Schemer and finally realized that the book is about taking small concepts to build bigger programs. Unfortunately it reads like some form of cult worksheet to brainwash someone into a new way of thinking. Perhaps that's what Scheme was all along. ;)

    Charles Stanhope likes this.

  • [Blog] Day 23/100: Working on my Scheme presentation

    2017-06-24T04:16:43Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/SnHES0BhouA/)

    Spent most of today working on my Scheme / Racket presentation that I'll be giving at MUG in July. So no major progress to report.

    Claes Wallin (韋嘉誠), Christopher Allan Webber likes this.

  • [Blog] Day 22/100: Still more Shut the Box

    2017-06-23T02:45:26Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/t3DAmL39PVg/)

    Did a little more development with Scheme / Racket and Shut the Box. I fixed a few bugs in the previous implementation where you could remove tiles by flipping unflipped tiles before the flipped tiles are checked. I also put in a check so that the tiles that are flipped set a flag so additional tiles can't be flipped.

    #lang racket
    
    #| Init Block |#
    
    (define tiles '())
    (define die1 0)
    (define die2 0)
    (define turn-number 1)
    (define took-turn #f)
    
    (define (start-game)
    (set! tiles '(1 2 3 4 5 6 7 8 9)))
    
    (define (dice)
    (+ 1 (random 6)))
    
    (define (dice-roll)
    (set! die1 (dice))
    (set! die2 (dice)))
    
    (define (sum-of-dice)
    (+ die1 die2))
    
    (define (sum-of-tiles tilelist)
    (apply + tilelist))
    
    (define (list-check l1 l2)
    (andmap (lambda (x) (not (boolean? (memq x l2)))) l1))
    
    (define (shut-tiles tilelist)
    (if (not took-turn) 
        (if (list-check tilelist tiles)
        (for ([i tilelist])
            (if (index-of tiles i)
                (begin
                (set! tiles (remove i tiles))
                (set! took-turn #t))
                (error "Tile already shut")))
        (error "Tile not available to be shut"))
    (error "Already took your turn")))
    
    (define (check-roll dice-sum tile-sum)
    (= dice-sum tile-sum))
    
    (define (player-turn tilelist)
    (if (check-roll (sum-of-dice) (sum-of-tiles tilelist))
        (shut-tiles tilelist)
        (print "Roll does not equal shut tiles. Try again.")))
    
    (start-game)
    (dice-roll)
    
    (define (next-turn)
    (set! turn-number (+ 1 turn-number))
    (set! took-turn #f)
    (dice-roll)
    (show-turn))
    
    (define (show-turn)
    (printf "Turn: ")
    (println turn-number)
    (println tiles)
    (printf "Dice roll ~v ~v = ~v" die1 die2 (sum-of-dice) ))
    
  • [Blog] Day 21/100: Slow progress

    2017-06-22T03:00:08Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/u15wYpPfznc/)

    More progress on the Shut the Box program in Racket.

    Still need to figure out how to get everything together, but at least it's starting to make some sense.

    #lang racket
    
    #| Init Block |#
    
    (define tiles '())
    (define die1 0)
    (define die2 0)
    (define turn-number 1)
    
    (define (start-game)
    (set! tiles '(1 2 3 4 5 6 7 8 9)))
    
    
    (define (dice)
    (+ 1 (random 6)))
    
    (define (dice-roll)
    (set! die1 (dice))
    (set! die2 (dice)))
    
    (define (sum-of-dice)
    (+ die1 die2))
    
    (define (sum-of-tiles tilelist)
    (apply + tilelist))
    
    (define (check-roll dice-sum tile-sum)
    (= dice-sum tile-sum))
    
    (define (shut-tiles tilelist)
    (for ([i tilelist])
        (if (index-of tiles i)
            (set! tiles (remove i tiles))
            (print "Tile already shut"))))
    
    (define (player-turn tilelist)
    (if (check-roll (sum-of-dice) (sum-of-tiles tilelist))
        (shut-tiles tilelist)
        (print "Roll does not equal shut tiles. Try again.")))
    
    (start-game)
    (dice-roll)
    
    (define (next-turn)
    (set! turn-number (+ 1 turn-number))
    (dice-roll)
    (show-turn))
    
    (define (show-turn)
    (printf "Turn: ")
    (println turn-number)
    (println tiles)
    (printf "Dice roll ~v ~v = ~v" die1 die2 (sum-of-dice) ))
    

    Claes Wallin (韋嘉誠), serpiente_negra, Ben Sturmfels likes this.

    You're really making progress on your challenge. Ive enjoyed reading your updates. I just today found time to organize my thoughts around this. At this rate, I might not start until July 1st. Come to think of it, that might not be bad idea. :)

    Charles Stanhope at 2017-06-22T04:06:10Z

    Craig Maloney likes this.

    Thank you. I just realized one silly thing though which is that if you select two tiles and the second is already shut it will still remove the first one.

    Bugs. Gotta love 'em. :)

    Craig Maloney at 2017-06-22T11:34:32Z

    Charles Stanhope likes this.

  • [Blog] Day 20/100: Continued Shut the Box

    2017-06-21T04:00:06Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/Z0S3CNzQ7zM/)

    Still working on the Shut the Box program in Scheme / Racket, and I'm getting stuck.

    I know that mutable global values are bad (m'kay) but I'm not sure how to pass the values along in some meaningful way. Perhaps it's all of the years of object oriented programming shining through but I'm thinking of two dice in a roll-object where those get passed along until the tiles are flipped and the next roll is thrown.

    Thoughts on how to make this more functional are welcome.

    #lang racket
    
    #| Init Block |#
    
    (define tiles '())
    (define die1 0)
    (define die2 0)
    
    (define (start-game)
    (set! tiles '(1 2 3 4 5 6 7 8 9)))
    
    
    (define (dice)
        (+ 1 (random 6)))
    
    (define (dice-roll)
    (set! die1 (dice))
    (set! die2 (dice)))
    
    (define (sum-of-dice die1 die2)
    (+ die1 die2))
    
    
    (define (shut-tiles tilelist)
        (for ([i tilelist])
            (if (index-of tiles i)
                (set! tiles (remove i tiles))
                (print "Tile already shut"))))
    
    (start-game)
    (dice-roll)
    
    (define (next-turn)
    (dice-roll)
    (show-turn))
    
    (define (show-turn)
    (println tiles)
    (printf "Dice roll ~v ~v = ~v" die1 die2 (sum-of-dice die1 die2) ))
    
  • Open Metalcast Episode #156: Screaming into the void

    2017-06-20T03:00:25Z via Spigot To: Public

    (http://feedproxy.google.com/~r/OpenMetalcast/~3/Cj0xeYV5LX4/)

    There’s a saying “if you stare at the void the void stares back at you”. But what if you scream at the void? What if you play loud music (such as this fine episode here) at the void?

    Hey, stop looking at me like that, you void you.

    We’ve got a great episode of Creative Commons licensed metal lined up for your (and your void’s) listening pleasure. This episode includes new music from Canvas Black, Sartoraaus, Stabbed, Sarin, Celacanto, Sechem, Tornado Kid, and Mavradoxa. It’s a show that will have the void rocking while it stares back at you.

    Please support the bands in this show! Buy a T-Shirt, buy an album, head to the shows, or buy up their merch table. Whatever you can do to help these bands keep making music, please do it!

    If you have any suggestions for Creative Commons licensed metal, send me a link at craig@openmetalcast.com.

    Open Metalcast #156 (MP3)

    Open Metalcast #156 (OGG)

  • [Blog] Day 19/100: Reading...

    2017-06-20T03:00:24Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/LqA_b_cauEQ/)

    Did some reading of "Secrets of the JavaScript Ninja" and played more with the Shut the Box code in Racket to try to sectionalize it off properly. Will post more code tomorrow when I have more to show.

  • [Blog] Day 18/100: Landing a UFO in Racket

    2017-06-19T03:00:22Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/6YoEj0bZjI4/)

    Played more with Racket and the "Realm of Racket" book. The first example has you land a UFO at the bottom of the screen, so I modified that just a hair to land something else:

    Kind of interesting that the DrRacket will allow you to enter images like this. Unfortunately the resulting code isn't something that I can share as it makes a bit of a mess of it. But it works.

  • [Blog] Day 17/100: Swing and a miss

    2017-06-18T03:00:21Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/dJtL7OUI9iQ/)

    Today the programming side didn't get nearly enough attention. So I'm marking this as a miss.

    Trying again tomorrow.

  • [Blog] Day 16/100: More Shut the Box

    2017-06-17T03:35:40Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/20JZxCxafx8/)

    Played a little more with the functional aspects of Scheme / Racket wit the Shut the Box program:

    #lang racket 
    (define tiles `(1 2 3 4 5 6 7 8 9))
    
    (define (dice)
        (+ 1 (random 6)))
    
    (define (roll) 
        (list (dice) (dice)))
    
    (define dice-roll (roll))
    
    (define sum-roll (apply + dice-roll))
    
    (define tilelist '(4 5))
    
    (define (shut-tiles tilelist)
        (for ([i tilelist])
            (if (index-of tiles i)
                (set! tiles (remove i tiles))
                ("Tile already shut"))))
    
    (shut-tiles tilelist)
    
  • [Blog] Day 15/100: Pressing onward and onward

    2017-06-17T02:00:18Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/AlYy4O8O5F4/)

    Spent a little more time with "Learning Web App Development" until I got to the point where I got frustrated with the book. Part of my frustration with the book is it doesn't make it clear what's changed in between sections. That and a lot of "I left this as an exercise for the reader". That's great and I'm sure it's a fantastic learning tool for some but if I'm learning these things then leaving it as an exercise means I have to figure things out. And if later sections build on those concepts then it means there's a gap between where you taught and where I may or may not have caught the concept. That really irritates me in books, especially ones where it's more about self study. Worse is when the sample code pretty much has everything in a "solved" state (which is cool if you got lost, but absolute rubbish if you got lost mid-chapter).

    I don't know of a good way to fix this sort of issue but it's one that makes me start searching to see if there are other more cogent and coherent books on the subject.

    Ever onward.

  • [Blog] Celebrating identi.ca

    2017-06-17T01:00:19Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/cASwFTWZ2CA/)

    I'm not sure when I first logged onto identi.ca. I'm pretty sure it was after my friend Greg Grossmeier signed on that I created my account "snapl@identi.ca". I started following people that I knew in the FLOSS (Free / Libre Open Source Software) community. But I also started following other folks on there as well. The public stream moved at a ticker-tape crawl (not like the Twitter public stream which moved faster than you could read). But it was exciting to be part of something new.

    Identi.ca is a federated social network created by Evan Prodromou. What that means is each node of the network operates independently. So I could start my own instance at decafbad.net and build my own community of users. You could join any of the other instances out there and interact with the folks on that community of users. The federated part is that each of the users on these systems can then follow each other. So if Bob is at the example.com instance I can follow bob@example.com.

    Also Statusnet, the software that powered Identi.ca and the other instances was released under the GPL license. That meant that anyone could hack on it and spin up their own version of the software.

    At the time this was unheard of. Twitter was just hitting critical mass and having some growing pains trying to figure out their next move. And, as Twitter is wont to do they made some controversial decisions.

    The first explosion of identi.ca accounts came like a wave. Many folks hopped onto identi.ca for a variety of reasons. Some were looking for the next big thing, some looking for what Twitter wasn't giving them. Some were just following Robert Scoble and Leo Laporte. Whatever the reason they were populating the instance and conversations blossomed.

    Over time folks faded back to Twitter. Identi.ca tended to get these waves of people who checked out the service, but then realized they had different conversations on identi.ca than they did on Twitter.

    I remember Steve Gilmor co-organized a conference about identi.ca and the future of social media. I remember watching the live-stream of the proceedings. Steve seemed more interested in ensuring that these services had "the firehose" like Twitter had. The firehose was the entire public stream of Twitter. Identi.ca had it, but each instance had its own public stream. So in order to get all of the traffic out there you'd have to poll each of the instances for their public feed.

    It was a strange conference to look at, with multiple people having their own ideas of how social media would work. Steve seemed interested as a journalist for having a stream to research and investigate. Others were looking for how to monetize this technology.

    I think we're still trying to wrestle with those questions.

    But over time the instances grew quiet for various reasons. Folks migrated back to Twitter, and admins realized that administrating communities of people is hard work.

    Identi.ca went through a re-write to use a new protocol. Previously it used a protocol that is now known as OStatus. The new protocol is ActivityPub. ActivityPub was a better protocol than OStatus, but sadly it hasn't caught on.

    Eventually Evan moved on to other endeavors and identi.ca / pump.io was no longer his focus. There have been several attempts to keep the service running but as of this writing identi.ca is down.

    But what's great about the GPL is others can take the software and use it to build their own platforms. There are currently two major forks of the identi.ca code / protocols. GNUSocial is closely related to the old StatusNet software. The other is Mastodon, which is a complete re-write of the code in Ruby.

    Right now I'm seeing a migration of users from Twitter over to Mastodon. They all have their own reasons. For some the bullying on Twitter is unbearable. For others the racism. Whatever the reasons they're searching for alternatives.

    It's like identi.ca all over again. Maybe they'll stay and set up roots. Maybe they'll just pass through like the others.

    Whatever the reasons I'm glad that identi.ca still lives on.

    (If you would like to take a peek at Mastodon check out joinmastodon.org for more information. And follow me @craigmaloney@octodon.social.)

    Charles Stanhope likes this.

    Sarah Elkins shared this.

    For the record, ActivityPub is a new, work-in-progress standardized protocol. Pump.io doesn't use that yet.

    JanKusanagi at 2017-06-17T11:25:40Z

    Ah, what protocol does it use then? (/me will change it).

    Craig Maloney at 2017-06-17T13:17:20Z

  • [Blog] Day 14/100: Pressing onward

    2017-06-17T00:00:19Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/iWgAKPQYBM0/)

    Today was mostly cleaning up other projects so I didn't get a whole lot of time to do actual coding. However I did get the opportunity to learn more about React / React Native / Redux at our local coding group so that was time well spent. Hoping to put some of this knowledge to good use soon.

  • [Blog] Day 13/100: The Water of Treading

    2017-06-16T23:00:18Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/KJZknRLSI3Y/)

    Today didn't get a whole lot of code. Worked through the Learn Web App Development book some more, but most of today was spent on other things (anticipation of a fixed washer for starters).

    Ever onward!

  • [Blog] Cat Negotiation 101

    2017-06-16T22:00:19Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/NTXyNzxBFTI/)

    JoDee: I'd like to get Pixel back on a regular eating schedule.
    Pixel: Fuck you, I'm a cat.

    Me: Pixel, not now I'm in the middle of something.
    Pixel: Fuck you, I'm a cat.

    Us: Pixel, we'd like to have some bed to sleep on.
    Pixel: Fuck you, I'm a cat.

    This has been Cat Negotiation 101. Stay tuned for Cat Negotiation 102:

    Us: Pixel, please don't...
    Pixel: Fuck you, I'm a cat.

  • [Blog] Day 12/100: More Shut the Box in Racket

    2017-06-16T21:00:18Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/duvsvyJLF40/)

    Spent a little more time today playing with racket and the "Shut the Box" implementation.

    It's not much, but it's progress.

    ::: scheme
    
    (define tiles `(1 2 3 4 5 6 7 8 9))
    (define die1 (+ 1 (random 6)))
    (define die2 (+ 1 (random 6)))
    (define roll (+ die1 die2))
    
    (define tilelist '(4 5))
    
    (define (shuttiles tilelist)
        (for ([i tilelist])
            (if (index-of tiles i)
                (set! tiles (remove i tiles))
                ("Tile already shut"))))
    
    (shuttiles tilelist)
    
  • 2017-06-16T20:29:40Z via Identi.ca Web To: Public CC: Followers

    Hey all! Welcome back!

    Christopher Allan Webber likes this.

  • [Blog] Day 11/100: Shut the Box in Racket

    2017-06-16T20:27:26Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/83kHFhJ1L-c/)

    Today I had the brilliant idea to do my standard "Hello World" program in Scheme / Racket. So, I present to you the first bits of "Shut the Box" in Racket:

    (define tiles `(1 2 3 4 5 6 7 8 9))
    (define die1 (+ 1 (random 6)))
    (define die2 (+ 1 (random 6)))
    (define roll (+ die1 die2))
    
    (define tilelist 4)
    
    (if (index-of tiles tilelist)
    (set! tiles (remove tilelist tiles))
    ("Tile already shut"))
    

    More later as I figure things out.

  • [Blog] Day 10/100: Yet more reading

    2017-06-16T20:00:18Z via Spigot To: Public

    (http://feedproxy.google.com/~r/CraigMaloney/~3/SlyIhD1nwAE/)

    I'm planning on doing a talk at our local user group (Michigan!/usr/group]) about Scheme / Guile / Racket and so I'm reading more to understand how deep I want to go with introducing the languages. So today was more about research than actual programming (though I did find some interesting examples in Racket that I was playing with).