예제 #1
0
def receive():
    (pub, priv) = loadKeys("GitBank")

    cs = Coins("GitBank")

    receipts = Receipts("GitBank")
    pending = receipts.findPending(pub)
    if len(pending) == 0:
        print("No pending coins")
    elif len(pending) == 1:
        print("1 pending coin")
    else:
        print(str(len(pending)) + " pending coins")
    for receipt in pending:
        print(receipt)

    if receipt.cmd != "send":
        print("Unknown command: " + str(receipt.cmd))
        return
    if receipt.args != pub:
        print("Not me: " + str(receipt.args) + " " + str(pub))
        return
    if not receipt.verify():
        print("Not verified")
        return
    cs.add(receipt.coin)

    receipt = Receive(None, pub, epoch(), receipt.coin, receipt.pub)
    receipt.setPrivate(priv)
    receipt.sign()
    receipts.add(receipt)
예제 #2
0
def getPrices():
    #requires coins.py file included with repo
    #currently uses CoinMarketCap
    #see coins.py
    coinDict = {
        'btcPrice': 0,
        'ethPrice': 0,
        'ltcPrice': 0,
        'gntPrice': 0,
        'ansPrice': 0,
        'stratPrice': 0,
        'xrpPrice': 0,
        'omgPrice': 0,
        'synxPrice': 0
    }
    coins = Coins()
    coinPrice = []
    for i in range(len(coinOpt)):
        price = str(coins.getPrice(Abbreviations[i]))
        coinPrice.append(float(price))
    i = 0
    for k, v in coinDict.copy().items():
        if v is 0:
            coinDict[k] = coinPrice[i]
            i += 1
    return coinPrice
예제 #3
0
def send(args):
    to = args[0]

    f = open("participants.json", "rb")
    participants = json.loads(f.read())
    f.close()

    if not to in participants:
        print("Unknown participant: " + str(to))
        return

    toPub = participants[to]
    to = loadPublic(toPub, format="PEM")

    (pub, priv) = loadKeys("GitBank")

    cs = Coins("GitBank")
    coin = cs.get()

    if not coin:
        print("No coins!")
        return

    receipt = Send(None, pub, epoch(), coin, to)
    receipt.setPrivate(priv)
    receipt.sign()

    receipts = Receipts("GitBank")
    receipts.add(receipt)
예제 #4
0
 def create_all_coins(self):
     for i in range(9):
         mod = random.randint(0, 9)
         start_x = mod + i * 85
         start_y = random.randint(5, 17)
         C = Coins(start_x, start_y)
         if C.create_obj(self._board) == True:
             self._coins_placed.append(C)
예제 #5
0
파일: mint.py 프로젝트: antiface/CreditCoin
  def create(self, proof=None):
    coins=Coins(self.dir)
    coin=coins.new(self.pub, self.priv)

    receipts=Receipts(self.dir)
    cr=Create(None, self.pub, epoch(), coin, proof)
    cr.setPrivate(self.priv)
    cr.sign()
    receipts.add(cr)
def main():

    # AG(cantidad_individuos, alelos, tamano_gen, generaciones, p, problema)

    # pesos = [22, 14, 16, 23, 12, 15, 22, 6, 19, 20, 40, 8, 16, 6, 15, 21, 16]
    # valores = [55, 34, 28, 30, 80, 3, 28, 24, 21, 43, 54, 12, 21, 11, 6, 21, 28]
    # mochila = knapsack.Knapsack(pesos, valores, 100)
    # ag = AG.AG(18, 17, 1, 400, 0.01, mochila)
    # ag.run()

    # coinsVector = [5,1,2,10,6,2]
    # coinsVector = [3, 3, 3, 7, 3, 11, 8, 8, 10, 10, 4, 1, 10, 4, 5]
    # coinsVector = [5, 15, 2, 1, 7, 1, 12, 5, 17, 17, 7, 2, 17, 2, 12, 15, 12, 15, 2, 7]
    coinsVector = [
        1, 20, 5, 1, 2, 5, 5, 1, 5, 2, 2, 1, 10, 5, 10, 5, 20, 20, 20, 5, 1, 1,
        20, 20, 1, 10, 2, 10, 5, 2, 10, 1, 20, 1, 20, 10, 5, 5, 20, 2, 10, 1,
        2, 5, 10, 20, 10, 2, 5, 5, 20, 1, 1, 5, 10, 10, 10, 1, 5, 2, 1, 2, 10,
        20, 2, 10, 10, 20, 5, 10, 1, 2, 1, 5, 20, 2, 5, 1, 5, 10, 2, 5, 10, 2,
        1, 1, 1, 10, 20, 10, 20, 2, 2, 10, 20, 10, 1, 1, 5, 2
    ]
    pesos = Coins(coinsVector)
    # pesos = Coins()
    ag = AGB(32, len(pesos._coinsVector), 1, 10000, 0.01, pesos)
    # ag = AG(32,100,1,4000,0.01,pesos)
    tIni = time.time()
    ag.run()
    tFin = time.time()
    t = tFin - tIni
    imprimirHistoricos(ag._historicos)
    print('Fila de monedas {}'.format(pesos._coinsVector))
    print('Tiempo de ejecución: {}'.format(
        datetime.fromtimestamp(t).strftime('%M:%S:%f')))
def main():

    cards = Cards()
    coins = Coins()

    x = int(input("Indique la cantidad de jugadores (3-4): "))
    players = Players(x)
    players.add_players()

    cards.shuffle_deck()
    cards.distribute_cards(x)

    cont = 0
    rounds = 0

    while len(players.deadplayers) != (x - 1):

        if cont == (x):
            cont = 0
            rounds += 1
            print("\nRonda " + str(rounds) + " terminada")

        if players.jugadores[cont] in players.deadplayers:
            cont += 1
        else:
            print("\nEs el turno de " + players.jugadores[cont] + "\n")
            action = interface(cont, players, cards, coins)
            action_played(cont, action, players, cards, coins)

            cont += 1

    for i in players.jugadores:
        if i not in players.deadplayers:
            print("\n" + i + " ha ganado el juego")
예제 #8
0
 def spawn_coins(self):
     """
     Spawns coins
     """
     self.__objects["coins"] += Coins( \
         np.array([config.WIDTH, \
             util.randint(0, config.MAX_HEIGHT - 4)], dtype='float64'),
         np.array([3, util.randint(3, 10)])).get_items()
예제 #9
0
 def __init__(self):
     """making the boarders"""
     self.matrix = [[' '] * 408 for i in range(35)]
     self.store = [[' '] * 6 for i in range(3)]
     self.storetort = [[' '] * 3 for i in range(1)]
     self.storebossE = [[' '] * 4 for i in range(3)]
     self.coinslist = []
     self.coinslist.append(Coins(12, -10))
     self.coinslist.append(Coins(20, -10))
     self.coinslist.append(Coins(52, -11))
     self.coinslist.append(Coins(60, -11))
     self.coinslist.append(Coins(102, -10))
     self.coinslist.append(Coins(110, -10))
     self.coinslist.append(Coins(174, 0))
     self.coinslist.append(Coins(166, 0))
예제 #10
0
def getPrices():
	#requires coins.py
	#uses Kraken for BTC & ETH
	#uses CoinMarketCap for NEO/ANS and GNT
	#easily modified to have other exchanges, or other currencies
	coins = Coins()
	global btcPrice
	global ethPrice
	global gntPrice
	global ansPrice
	btcPrice = coins.btc()
	ethPrice = coins.eth()
	gntPrice = coins.gnt()
	ansPrice = coins.ans()
예제 #11
0
    def __init__(self):

        # Coins
        coins = Coins()
        self.cbridge = coins.cbridge
        self.cryptopia = coins.cryptopia
        self.common = coins.common
        self.sleep_time = 2 # Interval between each coin check
        self.btc_per_order = 0.001
        self.buy_price_ratio = 0.85

        # Bitshares account/wellet info
        self.account_name = "###" # Add your name
        self.account = Account(self.account_name)
        self.balances = self.account.balances
        self.open_orders = self.account.openorders
        self.phrase = "###" # Add your phrase

        # Start loop
        self.loop_markets()
예제 #12
0
def runBot():
    loop = asyncio.get_event_loop()
    theClient = bot.BotClient()
    commands = Commands(theClient)
    #levels = UserLevels(theClient)
    scrape = Scrape(theClient)
    saved = SaveLinks(theClient)
    messages = Messages(theClient)
    coins = Coins(theClient)
    try:
        loop.run_until_complete(theClient.start(Token))
    except KeyboardInterrupt:
        loop.run_until_complete(theClient.close())
    finally:
        loop.close()

    if theClient.restart == True:
        if asyncio.get_event_loop().is_closed():
            asyncio.set_event_loop(asyncio.new_event_loop())
        reload(bot)
        runBot()
예제 #13
0
    def __init__(self):

        # All Coins
        self.coins = Coins()
        self.coinex_coins = {
            "bittrex": self.coins.coinex_to_bittrex,
            "binance": self.coins.coinex_to_binance,
            "hitbtc": self.coins.coinex_to_hitbtc,
            "cbridge": self.coins.coinex_to_cbridge,
        }
        self.cbridge_coins = {
            "bittrex": self.coins.cbridge_to_bittrex,
        }
        # Settings
        self.target_percentages = {
            "bittrex": 12,
            "binance": 12,
            "hitbtc": 30,
            "cbridge": 40
        }
        self.percentage_ranges = {
            "bittrex": 5,
            "binance": 5,
            "hitbtc": 10,
            "cbridge": 15
        }

        # Prices
        self.bittrex_prices = {}
        self.binance_prices = {}
        self.hitbtc_prices = {}
        self.cbridge_prices = {}

        # Connect to Database
        self.conn = sqlite3.connect('hunter.db')
        self.c = self.conn.cursor()
예제 #14
0
파일: list.py 프로젝트: antiface/CreditCoin
import time
import random
import struct

from keys import loadKeys
from coins import Coins
from receipts import Create, Receipts

pub, priv = loadKeys()

cs=Coins()
cs.load('coins.dat')
for coin in cs.coins:
  print(coin.sig)
예제 #15
0
파일: recv.py 프로젝트: antiface/CreditCoin
import monocle
from monocle import _o, Return
monocle.init('tornado')

from monocle.stack import eventloop
from monocle.stack.network import add_service, Service, ConnectionLost

from coins import Coin, Coins
from keys import loadKeys, loadPrivate, loadPublic
from util import encode, decode, epoch
from receipts import Receipts, Send, Receive

dir=sys.argv[1]

cs=Coins()
cs.load(dir+'/coins.dat')

(pub, priv) = loadKeys(dir)

@_o
def handle_recv(conn):
  print('connected')
  s=yield conn.read_until("\n")
  print('read')
  print(s)
  smsg=json.loads(s)

  receipts=Receipts()
  receipts.load(dir+'/receipts.dat')  
  
예제 #16
0
 def __init__(self,x_coord,y_coord):
     Coins.__init__(self,x_coord,y_coord)
     self._token = 'M'
예제 #17
0
파일: game.py 프로젝트: Motwani/DonkeyKong
def main(turns, score):
    pygame.init()
    pygame.display.set_caption('Donkey Kong')
    swidth = 800
    sheight = 620
    clock = pygame.time.Clock()
    disp = pygame.display.set_mode([swidth, sheight], 0, 32)

    BLACK = (0, 0, 0)

    class Gameline(pygame.sprite.Sprite):
        def __init__(self, color, length):

            pygame.sprite.Sprite.__init__(self)
            self.image = pygame.Surface([length, 4])
            self.image.fill(color)
            self.rect = self.image.get_rect()

    class Vertline(pygame.sprite.Sprite):
        def __init__(self):

            pygame.sprite.Sprite.__init__(self)
            self.image = pygame.Surface([4, 45])
            self.image.fill(BLACK)
            self.rect = self.image.get_rect()
            self.rect.y = 10

    line1 = Vertline()
    line1.rect.x = 250
    line2 = Vertline()
    line2.rect.x = 450
    list_obj = pygame.sprite.Group()
    pl_list = pygame.sprite.Group()
    coin_list = pygame.sprite.Group()
    ladder_list = pygame.sprite.Group()
    fire_list = pygame.sprite.Group()
    gor_list = pygame.sprite.Group()
    heart = pygame.sprite.Group()
    ps_list = pygame.sprite.Group()
    list_obj.add(line1)
    list_obj.add(line2)

    for i in range(3):
        line = Gameline(BLACK, 600)
        line.rect.x = -10
        line.rect.y = 100 + i * 200
        list_obj.add(line)
    for i in range(2):
        line = Gameline(BLACK, 600)
        line.rect.x = 230
        line.rect.y = 200 + i * 200
        list_obj.add(line)

    line = Gameline(BLACK, 810)
    line.rect.x = -10
    line.rect.y = 600
    list_obj.add(line)

    line = Gameline(BLACK, 200)
    line.rect.x = 250
    line.rect.y = 50
    list_obj.add(line)

    mario = Player()
    pl_list.add(mario)

    gor = Gorilla()
    gor_list.add(gor)

    ps = Princess()
    ps_list.add(ps)

    ladxy = [520, 298, 550, 498, 300, 398, 300, 198, 540, 98]
    for i in range(0, 10, 2):
        lad = Ladders(ladxy[i], ladxy[i + 1])
        ladder_list.add(lad)

    for i in range(12):
        c = Coins()
        c.cd(1)
        coin_list.add(c)
    for i in range(12):
        c = Coins()
        c.cd(2)
        coin_list.add(c)
    c = 50

    while True:
        heart.empty()
        life(turns, heart)

        font = pygame.font.Font(None, 36)
        text = font.render("Score = " + str(score), 1, (10, 10, 10))
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
        s = pygame.sprite.groupcollide(pl_list, coin_list, False, True)
        score += (len(s) * 5)
        if score >= 50:
            list_obj.remove(line1)
            list_obj.remove(line2)
        flag = pygame.sprite.groupcollide(pl_list, ladder_list, False, False)
        if len(flag) > 0:
            for i in ladder_list:
                if flag.values()[0][0] == i:
                    i.move(mario)
        else:
            mario.move()
            mario.rect.y = mario.checkmove(list_obj)
        keys = pygame.key.get_pressed()
        if keys[K_q]:
            pygame.quit()
            sys.exit()
        if keys[K_SPACE]:
            flag = 1
            v = -50
        if flag == 1:
            mario.rect.y += v
            v += 10
            if v == 40:
                flag = 0
        if c % 100 == 0:
            f = Fireball(gor, fire_list)
            c = 850
        else:
            c += 1
        for qw in fire_list:
            ladcol = pygame.sprite.spritecollideany(qw,
                                                    ladder_list,
                                                    collided=None)
            plcol = pygame.sprite.spritecollideany(qw, pl_list, collided=None)
            gorcol = pygame.sprite.groupcollide(gor_list, pl_list, False,
                                                False)
            """if ladcol != None :
					r=random.randrange(0,2)
					print r
					if r == 1 :
						qw.state = 1
						qw.h += 20
						if qw.state == 1 :
							qw.rect.y += qw.h
							qw.h += 1
						if qw.h == 23 :
							qw.state = 0
							qw.h = 0
				else :	
				"""
            if plcol != None or len(gorcol) < 0:
                turns -= 1
                if turns == 0:
                    font = pygame.font.Font(None, 72)
                    text = font.render("GAME OVER ", 1, (10, 10, 10))
                    disp.blit(text, (150, 300))
                    pygame.display.update()
                    time.sleep(2)
                    pygame.quit()
                    sys.exit()
                main(turns, score)
            qw.move(pl_list, list_obj, fire_list)
        gor.move(500, 20)
        ps.move(410, 260)
        if mario.rect.x >= 260 and mario.rect.x <= 400 and mario.rect.y >= 00 and mario.rect.y <= 30:
            font = pygame.font.Font(None, 72)
            text = font.render("YOU WIN SCORE = " + str(score), 1,
                               (10, 10, 10))
            disp.blit(text, (150, 300))
            pygame.display.update()
            time.sleep(2)
            pygame.quit()
            sys.exit()
        bgimg = pygame.image.load('background.png')
        #bgimg.rect = pygame.get_rect()
        disp.blit(bgimg, (0, 0))
        disp.blit(text, (650, 70))
        pl_list.draw(disp)
        coin_list.draw(disp)
        ladder_list.draw(disp)
        heart.draw(disp)
        gor_list.draw(disp)
        list_obj.draw(disp)
        fire_list.draw(disp)
        ps_list.draw(disp)
        pygame.display.update()
        clock.tick(20)
예제 #18
0
파일: game.py 프로젝트: Motwani/DonkeyKong
def main(turns, score):
    pygame.init()
    pygame.display.set_caption("Donkey Kong")
    swidth = 800
    sheight = 620
    clock = pygame.time.Clock()
    disp = pygame.display.set_mode([swidth, sheight], 0, 32)

    BLACK = (0, 0, 0)

    class Gameline(pygame.sprite.Sprite):
        def __init__(self, color, length):

            pygame.sprite.Sprite.__init__(self)
            self.image = pygame.Surface([length, 4])
            self.image.fill(color)
            self.rect = self.image.get_rect()

    class Vertline(pygame.sprite.Sprite):
        def __init__(self):

            pygame.sprite.Sprite.__init__(self)
            self.image = pygame.Surface([4, 45])
            self.image.fill(BLACK)
            self.rect = self.image.get_rect()
            self.rect.y = 10

    line1 = Vertline()
    line1.rect.x = 250
    line2 = Vertline()
    line2.rect.x = 450
    list_obj = pygame.sprite.Group()
    pl_list = pygame.sprite.Group()
    coin_list = pygame.sprite.Group()
    ladder_list = pygame.sprite.Group()
    fire_list = pygame.sprite.Group()
    gor_list = pygame.sprite.Group()
    heart = pygame.sprite.Group()
    ps_list = pygame.sprite.Group()
    list_obj.add(line1)
    list_obj.add(line2)

    for i in range(3):
        line = Gameline(BLACK, 600)
        line.rect.x = -10
        line.rect.y = 100 + i * 200
        list_obj.add(line)
    for i in range(2):
        line = Gameline(BLACK, 600)
        line.rect.x = 230
        line.rect.y = 200 + i * 200
        list_obj.add(line)

    line = Gameline(BLACK, 810)
    line.rect.x = -10
    line.rect.y = 600
    list_obj.add(line)

    line = Gameline(BLACK, 200)
    line.rect.x = 250
    line.rect.y = 50
    list_obj.add(line)

    mario = Player()
    pl_list.add(mario)

    gor = Gorilla()
    gor_list.add(gor)

    ps = Princess()
    ps_list.add(ps)

    ladxy = [520, 298, 550, 498, 300, 398, 300, 198, 540, 98]
    for i in range(0, 10, 2):
        lad = Ladders(ladxy[i], ladxy[i + 1])
        ladder_list.add(lad)

    for i in range(12):
        c = Coins()
        c.cd(1)
        coin_list.add(c)
    for i in range(12):
        c = Coins()
        c.cd(2)
        coin_list.add(c)
    c = 50

    while True:
        heart.empty()
        life(turns, heart)

        font = pygame.font.Font(None, 36)
        text = font.render("Score = " + str(score), 1, (10, 10, 10))
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
        s = pygame.sprite.groupcollide(pl_list, coin_list, False, True)
        score += len(s) * 5
        if score >= 50:
            list_obj.remove(line1)
            list_obj.remove(line2)
        flag = pygame.sprite.groupcollide(pl_list, ladder_list, False, False)
        if len(flag) > 0:
            for i in ladder_list:
                if flag.values()[0][0] == i:
                    i.move(mario)
        else:
            mario.move()
            mario.rect.y = mario.checkmove(list_obj)
        keys = pygame.key.get_pressed()
        if keys[K_q]:
            pygame.quit()
            sys.exit()
        if keys[K_SPACE]:
            flag = 1
            v = -50
        if flag == 1:
            mario.rect.y += v
            v += 10
            if v == 40:
                flag = 0
        if c % 100 == 0:
            f = Fireball(gor, fire_list)
            c = 850
        else:
            c += 1
        for qw in fire_list:
            ladcol = pygame.sprite.spritecollideany(qw, ladder_list, collided=None)
            plcol = pygame.sprite.spritecollideany(qw, pl_list, collided=None)
            gorcol = pygame.sprite.groupcollide(gor_list, pl_list, False, False)
            """if ladcol != None :
					r=random.randrange(0,2)
					print r
					if r == 1 :
						qw.state = 1
						qw.h += 20
						if qw.state == 1 :
							qw.rect.y += qw.h
							qw.h += 1
						if qw.h == 23 :
							qw.state = 0
							qw.h = 0
				else :	
				"""
            if plcol != None or len(gorcol) < 0:
                turns -= 1
                if turns == 0:
                    font = pygame.font.Font(None, 72)
                    text = font.render("GAME OVER ", 1, (10, 10, 10))
                    disp.blit(text, (150, 300))
                    pygame.display.update()
                    time.sleep(2)
                    pygame.quit()
                    sys.exit()
                main(turns, score)
            qw.move(pl_list, list_obj, fire_list)
        gor.move(500, 20)
        ps.move(410, 260)
        if mario.rect.x >= 260 and mario.rect.x <= 400 and mario.rect.y >= 00 and mario.rect.y <= 30:
            font = pygame.font.Font(None, 72)
            text = font.render("YOU WIN SCORE = " + str(score), 1, (10, 10, 10))
            disp.blit(text, (150, 300))
            pygame.display.update()
            time.sleep(2)
            pygame.quit()
            sys.exit()
        bgimg = pygame.image.load("background.png")
        # bgimg.rect = pygame.get_rect()
        disp.blit(bgimg, (0, 0))
        disp.blit(text, (650, 70))
        pl_list.draw(disp)
        coin_list.draw(disp)
        ladder_list.draw(disp)
        heart.draw(disp)
        gor_list.draw(disp)
        list_obj.draw(disp)
        fire_list.draw(disp)
        ps_list.draw(disp)
        pygame.display.update()
        clock.tick(20)
예제 #19
0
파일: send.py 프로젝트: antiface/CreditCoin
    print('Unknown command: '+str(receipt.cmd))
    return
  if receipt.args.save_pkcs1('DER')!=pub.save_pkcs1('DER'):
    print('Not me')
    return
  if not rsa.verify(str(receipt.sig), receipt.pub):
    print('Not verified')
    return

  cs.save(dir+'/coins.dat')
  receipts.add(receipt)
  print('saving '+str(len(receipts.receipts)))
  receipts.save(dir+'/receipts.dat')

  eventloop.halt()
 except Exception, e:
  print('Exception:')
  print(e)
  traceback.print_exc()

if __name__=='__main__':
  cs=Coins()
  cs.load(dir+'/coins.dat')
  coin=cs.get()

  if not coin:
    print('No coins!')
  else:
    send(dir, coin, to)
    eventloop.run()