You might have noticed that most of the work I’ve put into the blog lately has been to the end of promoting Geek Girl Con. This post is no different, save for a bit of complaining.
Honestly, I haven’t had much time for blogospherics lately, as work has had a series of disasters that I’ve had to mitigate, so I’ve been working my ass off. I’ve been venting my frustrations about current real-world events on Twitter in short form, because that seems easier to handle in the midst of jumping from one crisis to another with work, but the blog has lain fallow for too long, so I decided to cross-purpose a bit of work I did today. Why use something you’ve done once, when you can use it twice?
At Geek Girl Con, I’m going to be working in the DIY Science Zone, teaching a thing or two about randomness, especially as pertains to dice. I’ll be performing a few demonstrations of how humans don’t really grok randomness, including one where I’ll get people to draw fifty random dots on a piece of paper. I’ll then compare them to a better (though still not perfect) pseudo-random generator, a computer.
Then I’ll go on to talk about how this universe is deterministic and randomness really isn’t all that random no matter what we do to generate it, and pretend to be all smart and stuff. We’ll see how that works out.
I’ve written a little Python script to help with the first demonstration I mentioned above. Here it is. It uses the fairly standard Pygame init > run > terminate main loop you might see in other examples.
#Random dots 1.0 #By Jason Thibeault, 2014 #For use in demonstrations of randomness at Geek Girl Con #Settable variables numdots = 50 #Imports import pygame from pygame.locals import * import random #Defines bg = None def Init(): global bg, screen pygame.init() infoObject = pygame.display.Info() WIDTH,HEIGHT=infoObject.current_w, infoObject.current_h bg = pygame.display.set_mode((WIDTH,HEIGHT), FULLSCREEN, 32) pygame.mouse.set_visible(False) def Run(): infoObject = pygame.display.Info() WIDTH,HEIGHT=infoObject.current_w, infoObject.current_h bgcolor1 = (255, 255, 255) # Create a bitmap for the dot bitmap = pygame.Surface((8, 8), pygame.SRCALPHA, 32) pygame.draw.circle(bitmap, (0, 0, 128), [4, 4], 4, 0) dots = ArrayDots(numdots) # Loop forever quitgame = 0 while not quitgame: pygame.event.pump() # Fill background bg.fill(bgcolor1, (0, 0, WIDTH, HEIGHT)) # Render dots for dot in dots: bg.blit(bitmap, dot) pygame.display.update() # Look for quit and mouseclick for e in pygame.event.get(): if e.type in [pygame.QUIT]: quitgame = 1 break elif e.type == pygame.KEYDOWN: if e.key == 27: quitgame = 1 break elif e.type == pygame.MOUSEBUTTONDOWN: dots=ArrayDots(numdots) def ArrayDots(num): arraydots = [None]*num infoObject = pygame.display.Info() WIDTH,HEIGHT=infoObject.current_w, infoObject.current_h for i in range(0,num): arraydots[i] = RandomDot(WIDTH,HEIGHT) return arraydots def RandomDot(rangex,rangey): x,y = random.randint(1,rangex),random.randint(1,rangey) return [x,y] def Terminate(): pygame.mouse.set_visible(True) pygame.quit() def main(): Init() Run() Terminate() main()