def enter(): game_framework.reset_time() global map, player, house, background, avalanche, coin, snows, map_on_coins, game_over, santa, game_clear, distance, stones map = Map() player = Player() house = House() background = Background() avalanche = Avalanche() coin = Coin() game_over = Game_over() santa = Santa() game_clear = Game_clear() distance = Distance() map_on_coins = [Map_on_Coin() for i in range(200)] snows = [Snow() for i in range(20)] stones = [Stone() for i in range(10)] Player.x = 300.0 Player.y = 300.0 Player.unreal_x = 300.0 Player.unreal_y = 0 Player.jump_before_y = 0 Map.map_move_y_minor = 0 Avalanche.game_over = 0 Game_clear.game_clear = 0 Santa.game_clear = 0
def addPeople(self, people): for pName in people: pers = Santa(pName) for n, p in self.people.items(): p.addToPotentialSantas(pers) p.addToPotentialGiftees(pers) pers.addToPotentialSantas(p) pers.addToPotentialGiftees(p) self.people[pName] = pers
def matrixToCompany(self, matrix): for n, p in matrix.items(): pers = Santa(n) self.people[n] = pers # loop again to add the actual people for n, p in self.people.items(): cs = matrix[n]['confirmedSanta'] if cs != '': p.hasSanta = True p.confirmedSanta = self.people[cs] else: for nn, pp, in self.people.items(): if (pp.name != p.name) & (pp.name != cs): p.addToPotentialSantas(pp) cg = matrix[n]['confirmedGiftee'] if cg != '': p.hasGiftee = True p.confirmedGiftee = self.people[cg] else: for nn, pp, in self.people.items(): if (pp.name != p.name) & (pp.name != cg): p.addToPotentialGiftees(pp)
################################################################################ # This the secret santa letter template that is used to send everyone the email. # Note that {santa} and {recipient} are automatically replaced by the secret # santa's name, and his/her recipient of their gift. ################################################################################ letter = Letter(from_name='Secret Santa', from_email=smtp_user, subject='Family Christmas', greeting="{santa}, you are {recipient}'s secret Santa!", body="") ################################################################################ # The complete list of all the secret santa's and their email addresses. ################################################################################ santas = [ Santa('Jan', '*****@*****.**'), Santa('Alisha', '*****@*****.**'), Santa('Pam', '*****@*****.**'), Santa('Mark', '*****@*****.**'), Santa('Nick', '*****@*****.**'), Santa('Erica', '*****@*****.**'), Santa('Luke', '*****@*****.**'), Santa('Sidney', '*****@*****.**'), Santa('Brittany', '*****@*****.**'), ] ################################################################################ # This contains a list of people that you do NOT want to be paired together... # for whatever reason (either because they're going to gossip to each other of # who they have as their recipient, or they just plainly can't stand the thought # of giving each other a gift).
def send_test_email(): test_santa = Santa('Test Santa', config.smtp_user) test_recipient = Santa('Test Recipient', '*****@*****.**') test_santa.recipient = test_recipient config.letter.send(test_santa)
import torch torch.manual_seed(1991) from torch.optim import RMSprop, SGD, Adam from santa import Santa import matplotlib.pyplot as plt device = torch.device('cpu') theta = torch.randn(1, 1, device=device, requires_grad=True) theta.data = torch.Tensor([[4.0]]) N = 5000 optimizer = Santa( [theta], lr=1e-1, alpha=0.99, eps=1e-8, weight_decay=0, momentum=0.0, centered=False, decay_grad=0.0, anne_rate=0.5, burnin=N / 2, N=N) # optimizer = Adam([theta], lr=1e-2, betas=[0.99, 0.9]) thetas = [] for t in range(N): loss = (theta + 4) * (theta + 1) * (theta - 1) * (theta - 3) / 14 + 0.5 thetas.append(theta.item()) print(t, theta.item()) optimizer.zero_grad() loss.backward() optimizer.step() plt.plot(thetas) # plt.ylim([-6, 4])
letter = Letter(from_name='Secret Santa', from_email=smtp_user, subject='Family Christmas', body=""" Ho Ho Ho! {santa}, you are {recipient}'s secret Santa! Merry Christmas! """) ################################################################################ # The complete list of all the secret santa's and their email addresses. ################################################################################ santas = [ Santa('Jan', '*****@*****.**'), Santa('Alisha', '*****@*****.**'), Santa('Pam', '*****@*****.**'), Santa('Mark', '*****@*****.**'), Santa('Nick', '*****@*****.**'), Santa('Erica', '*****@*****.**'), Santa('Luke', '*****@*****.**'), Santa('Sidney', '*****@*****.**'), Santa('Brittany', '*****@*****.**'), ] ################################################################################ # This contains a list of people that you do NOT want to be paired together... # for whatever reason (either because they're going to gossip to each other of # who they have as their recipient, or they just plainly can't stand the thought # of giving each other a gift).