Beispiel #1
0
    def init_connection(self):
        """Initialize variables that are local to a connection, (needed if the client automatically reconnect)"""
        self.ready_lock.acquire(
            False)  # reacquire the ready-lock in case of reconnection

        self.connected = PYMUMBLE_CONN_STATE_NOT_CONNECTED
        self.control_socket = None
        self.media_socket = None  # Not implemented - for UDP media

        self.bandwidth = PYMUMBLE_BANDWIDTH  # reset the outgoing bandwidth to it's default before connectiong
        self.server_max_bandwidth = None
        self.udp_active = False

        self.users = users.Users(
            self, self.callbacks
        )  # contain the server's connected users informations
        self.channels = channels.Channels(
            self, self.callbacks)  # contain the server's channels informations
        self.blobs = blobs.Blobs(self)  # manage the blob objects
        self.sound_output = soundoutput.SoundOutput(
            self, PYMUMBLE_AUDIO_PER_PACKET,
            self.bandwidth)  # manage the outgoing sounds
        self.commands = commands.Commands(
        )  # manage commands sent between the main and the mumble threads

        self.receive_buffer = ""  # initialize the control connection input buffer
Beispiel #2
0
def run_game():

    pygame.init()
    ai_settings = Settings()
    #创建屏幕
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Supreme Commander Kim VS Trump")
    #创建一艘飞船
    player = Player(screen)
    #创建n个blob
    my_blobs = blobs.Blobs()
    my_blobs.generate_blob(ai_settings, screen, player,
                           ai_settings.blob_num_init)
    while True:

        #对各个事件做出反应
        gf.check_events(player, my_blobs, ai_settings)
        #更新屏幕
        if player.life_value > 0:
            gf.update_screen(ai_settings, screen, player, my_blobs)
        else:
            screen.fill([0, 0, 0])
            pygame.display.flip()
Beispiel #3
0
# Format data and merge on shapefile IDs
ordered_blocks = pd.DataFrame(
    df.loc[:, ['geoid10', 'tract_bloc', 'Pop', 'order']])
ordered_blocks.sort(['order'])
crime_hour_tables = []
for i in range(24):
    hourlyTable = pd.merge(crime_hour[i],
                           ordered_blocks,
                           how='right',
                           left_on='geoid10',
                           right_on='geoid10',
                           sort=False).fillna(0).sort(['order'])
    hourlyTable = hourlyTable.drop(['order', 'hour'], 1)
    crime_hour_tables.append(hourlyTable)
i = 0
print i


class bd:
    data = crime_hour_tables[i]
    w = w
    shp_link = shp_link
    id = 'geoid10'
    level = 'block'


d = bd()
b = blobs.Blobs(d, 'Pop', 1000, plot=False, iterations=1)
b.generate_shapefile(filename='blob_hour_test_0_1000.shp')
Beispiel #4
0
### script to test blobs
### contributors: [email protected]
### 6/18/15

import blobs

# tract level
d = blobs.Blobs_Data('Chicago Census.csv', 'tract',
                     'tracts/CensusTractsTIGER2010.shp', 'tractce10', [
                         'crimes_2001_to_present',
                         '311_service_requests_vacant_and_abandoned_building',
                         '311_service_requests_rodent_baiting'
                     ])
b = blobs.Blobs(d, 'pop', 10000)

# block level
d = blobs.Blobs_Data('Chicago Census.csv', 'block',
                     'blocks/CensusBlockTIGER2010.shp', 'geoid10', [
                         'crimes_2001_to_present',
                         '311_service_requests_vacant_and_abandoned_building',
                         '311_service_requests_rodent_baiting'
                     ])
b = blobs.Blobs(d, 'pop', 10000)
cl = blobs.Cluster_blobs(b, blobs_per_cluster=10)

# the following will let you get started immediately on pre-downloaded data
import numpy as np
import pandas as pd
import pysal as ps
shp_link = 'tracts/CensusTractsTIGER2010.shp'
dbf = ps.open('tracts/CensusTractsTIGER2010.dbf')