Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle, sys
- import pygame
- from pygame.locals import *
- from time import sleep
- from math import sin, cos, pi, sqrt
- vial = open('dat/cash_timeline.dat','r')
- cash = pickle.load(vial)
- vial.close()
- vial = open('dat/flux_timeline.dat','r')
- flux = pickle.load(vial)
- vial.close()
- centerx, centery = 300,300#of the megacircle
- radius = 175#of the megacircle
- kay = 85**2/6855.#chips to radius conversion
- if True:#define colors
- red = pygame.Color('#FF486C')
- orange = pygame.Color('#FF7148')
- yellow = pygame.Color('#FFF748')
- green = pygame.Color('#95FF48')
- blue = pygame.Color('#48C9FF')
- violet = pygame.Color('#486CFF')
- grey = pygame.Color('#A3A3A3')
- graph = pygame.Color('#3A3A3A')
- black = pygame.Color(0,0,0)
- white = pygame.Color(255,255,255)#Color definition
- colors=[red, orange, yellow, green, blue, violet, grey]
- allPlayers = ['Brontosaur', 'Mongoose', 'Aardvark', 'FruitBat', 'MantaRay', 'Tapeworm', 'Ebola']#all together now!
- def arr(x):#given x chips, calculate the radius of the circle;
- return int(sqrt(kay*x))#holdings proportional to area
- def winner():#who wins the tournament?
- for player in allPlayers:
- if flux[player][hand] > 0:
- return player
- color_dict = {}
- place_dict = {}
- for i in range(0, len(allPlayers)):#give each player a color and a location.
- color_dict[allPlayers[i]] = colors[i]#colors for everyone!
- place_dict[allPlayers[i]] = (centerx+int(radius*cos(2*pi*i/len(allPlayers))), centery+int(radius*sin(2*pi*i/len(allPlayers))))
- pygame.init()
- windowSurfObj = pygame.display.set_mode([700,700])
- pygame.display.set_caption('Poker Face')
- fontObj = pygame.font.Font('freesansbold.ttf', 24)
- hand=0#slight abuse of notation; counter to iterate thru time series
- while hand < 675:
- windowSurfObj.fill(white)
- win = winner()
- for playa in allPlayers:#draw your lines in the sand...
- if flux[playa][hand] < 0.0:
- wid = arr(abs(flux[playa][hand]))#does this correctly represent flow? ie, is area ~ flux? oh wellz...
- pygame.draw.line(windowSurfObj, black, place_dict[playa], place_dict[win], wid)
- for playa in allPlayers:#circleround.
- rad = arr(cash[playa][hand])#radius of circle
- pygame.draw.circle(windowSurfObj, color_dict[playa], place_dict[playa], rad)#draw circles.
- for playa in allPlayers:#his name was robert paulson.
- msgSurfObj = fontObj.render(playa, False, graph)
- msgRectObj = msgSurfObj.get_rect()
- msgRectObj.topleft = place_dict[playa]
- windowSurfObj.blit(msgSurfObj, msgRectObj)
- for event in pygame.event.get():#event.get calls up all the events that have happened since the last time get was called.
- if event.type == QUIT:#GTFO
- pygame.quit()
- sys.exit()
- elif event.type == KEYDOWN:#interact with the keyboard
- if event.key == K_ESCAPE:
- pygame.event.post(pygame.event.Event(QUIT))#GTFO
- pygame.display.update()#update the display!
- pygame.image.save(windowSurfObj, 'frm/frame%d.jpeg'%(hand))
- hand += 1#animate
- #sleep(0.07)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement