Esempio n. 1
0
 def __init__(self, canvas, image_filename, x=0, y=0):
     super().__init__(canvas, image_filename, x, y)
     self._name = "Monkey"
     # every monkey has a banana, of course
     # The initial position of each banana is above the monkey's head
     banana_x = x
     banana_y = y - self.height - 10  # 10 pixels above monkey
     self._banana = Banana(canvas, 'images/banana.png', banana_x, banana_y)
     # images for animating throw
     image1 = Image.open(image_filename)
     image2 = Image.open(MONKEY_ARM_RAISED_IMAGE)
     self.images = [image1, image2, image2]
     self.image_index = 0
     self.is_throwing = False
Esempio n. 2
0
    def apply_rules(cls):

        if cls.winner == None and cls.player1.lives <= 0:
            cls.winner = cls.player2
        if cls.winner == None and cls.player2.lives <= 0:
            cls.winner = cls.player1

        if cls.firing:
            b = Banana(cls.curr_player.pos.x, cls.curr_player.pos.y, cls.curr_player)
            b.set_vel(cls.curr_player.power * math.cos(math.radians(cls.curr_player.angle)), cls.curr_player.power * math.sin(math.radians(cls.curr_player.angle)))
            cls.bananas.add(b)
            cls.firing = False
            cls.curr_player = cls.player2 if cls.curr_player == cls.player1 else cls.player1


        for banana in cls.bananas.sprites():
            hit = banana.collide(cls.players.sprites())
            hit = hit or banana.collide(cls.buildings.sprites())
            if hit:
                cls.bananas.remove(banana)
        for player in cls.players.sprites():
            player.collide(cls.buildings.sprites())
Esempio n. 3
0
    scale = 16.0

    # visualisation
    def visualise_array(ax, Xs, Ys, A, samples=None):
        #        im = ax.imshow(A, origin='lower')
        #        im.set_extent([Xs.min(), Xs.max(), Ys.min(), Ys.max()])
        #        im.set_interpolation('nearest')
        #        im.set_cmap('Greens')
        cs = ax.contour(Xs, Ys, A, 5, linewidth=2)
        #ax.clabel(cs, inline=1, fontsize=15, linewidth=2)
        if samples is not None:
            ax.plot(samples[:, 0], samples[:, 1], 'bx')
        ax.set_ylim([Ys.min(), Ys.max()])
        ax.set_xlim([Xs.min(), Xs.max()])

    target = Banana(bananicity=b, V=V)

    names = [r'$Score$', r'$Stein\ param$', r'$Stein\ nonparam$', r'$HMC$']
    fig, ax = plt.subplots(
        2,
        4,
        figsize=(10, 3.5),
    )
    color = ['g', 'm', 'b', 'r']
    Xs = np.linspace(-30, 30, 200)
    Ys = np.linspace(-10, 30, len(Xs))
    pdf = density(Xs, Ys, target)

    # first load data
    path = 'results/'
    plot_results = []
Esempio n. 4
0
def main():
    person = Person()
    for a in xrange(10):
        person.add_banana(Banana())
    person.eat_bananas()
Esempio n. 5
0
#!/usr/bin/env python

from pycallgraph import PyCallGraph
from pycallgraph import Config
from pycallgraph.output import GraphvizOutput

from banana import Banana

config = Config(max_depth=1)
graphviz = GraphvizOutput(output_file='filter_max_depth.png')

with PyCallGraph(output=graphviz, config=config):
    banana = Banana()
    banana.eat()
Esempio n. 6
0
server = '192.168.1.3'
port = 5555

server_ip = socket.gethostbyname(server)

try:
    s.bind((server, port))

except socket.error as e:
    print(str(e))

s.listen(2)
print("Waiting for a connection")

game = Banana()

recv_dicts = [{}, {}]

flip_delay = 0

pending_take = None


def other_player(player):
    if player == 0:
        return 1
    else:
        return 0

Esempio n. 7
0
server = ''
port = 5555

server_ip = socket.gethostbyname(server)

try:
    s.bind((server, port))

except socket.error as e:
    print(str(e))

s.listen(2)
print("Waiting for a connection")

game_state = GameState()
game = Banana(game_state)

recv_dicts = [{}, {}]

flip_delay = 1.5

pending_take = None


def other_player(player):
    if player == 0:
        return 1
    else:
        return 0

Esempio n. 8
0
# Load the sprite sheet (bitmap)
banana_sprites, palette = adafruit_imageload.load("/banana_all.bmp",
                                                  bitmap=displayio.Bitmap,
                                                  palette=displayio.Palette)

palette.make_transparent(0)
# Create a sprite (tilegrid)
banana_tilegrid = displayio.TileGrid(banana_sprites,
                                     pixel_shader=palette,
                                     width=1,
                                     height=1,
                                     tile_width=10,
                                     tile_height=10)

banana = Banana(banana_tilegrid)

break_stamp_bitmap, break_stamp_palette = adafruit_imageload.load(
    "/break_stamp.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)

gorilla_sprites, gorilla_palette = adafruit_imageload.load(
    "/gorilla_all.bmp", bitmap=displayio.Bitmap, palette=displayio.Palette)

gorilla_palette.make_transparent(0)

player_1 = Player(gorilla_sprites, gorilla_palette)
player_2 = Player(gorilla_sprites, gorilla_palette)

background_bitmap = bitmap = displayio.Bitmap(320, 240, 8)
bg_palette = displayio.Palette(8)
bg_palette[0] = 0x0402AC
Esempio n. 9
0
def banana():
    return Banana().run()
Esempio n. 10
0
clock = pygame.time.Clock()

net = Network()

print("Getting ID")

player = net.get_id()

print("Initializing graphics")

graphics = Graphics()

print("Sending send_dict")

game = Banana(net.send(send_dict))

print("Displaying initial elements")

# DISPLAYSURF.fill(BGCOLOR)
graphics.printstatus(game, player, ['flip', 'status', 'guess'], guess, status,
                     taker)
# pygame.display.update()

# Time check variables

while True:

    FPSCLOCK.tick(60)

    graphics_to_update = []