Exemplo n.º 1
0
def main():
    drawList = []
    #Realtor Domain title
    titleText = vars.Text('Realtor Domain', None, 120)
    titleText.rect.centerx = vars.WINW * .4
    titleText.rect.top = 100
    drawList.append(titleText)
    #Menu Items
    menuText = []
    menuText.append(vars.Text('New Game', None, 80))
    menuText[0].rect.left = titleText.rect.left + 100
    menuText[0].rect.top = titleText.rect.top + 150
    menuText.append(vars.Text('Developer', None, 80))
    menuText[1].rect.topleft = (menuText[0].rect.left,
                                menuText[0].rect.top + 100)
    drawList.append(menuText[0])
    drawList.append(menuText[1])

    loop = True
    while loop:
        for event in pygame.event.get():
            if event.type == QUIT:
                Terminate()
            if event.type == MOUSEBUTTONDOWN:
                if menuText[1].rect.collidepoint(event.pos):
                    engine.main(True)
        vars.DISP.fill(vars.BLACK)
        for i in range(len(drawList)):
            drawList[i].Draw()
        pygame.display.update()
        vars.FPSCLOCK.tick(vars.FPS)
Exemplo n.º 2
0
def main():
    curr_dir = abspath(dirname(__file__))
    script_dir = join(curr_dir, 'update')
    if hasattr(sys, 'frozen') and sys.frozen:
        retcode = call([join(script_dir, 'startupdater' +
                             ('.exe' if sys.platform == 'win32' else ''))])
    else:
        retcode = call(['python', join(script_dir, 'startupdater.py')])

    sys.path.append(join(curr_dir, 'src/devclient'))
    # This import must stay after the updating of the client
    import engine
    engine.main(update=not retcode)
Exemplo n.º 3
0
    def run(self):
        pygame.init()
        screen = pygame.display.set_mode(game_data.WINDOW_SIZE,  pygame.FULLSCREEN)#, pygame.FULLSCREEN)
        pygame.display.set_caption(self.name + self.version)
        menu = cMenu(50, 50, 20, 5, 'vertical', 100, screen,
               [('Single Player', 1, None),
                ('Multiplayer', 2, None),
                ('Watch Replay',  3, None),
                ('Options',    4, None),
                ('Exit',       5, None)])
        menu.set_center(True, True)
        menu.set_alignment('center', 'center')
        state = 0
        prev_state = 1
        rect_list = []
        pygame.event.set_blocked(pygame.MOUSEMOTION)
        while (self.running):
            if prev_state != state:
                pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key = 0))
                prev_state = state

            pygame.display.update(rect_list)

            e = pygame.event.wait()
            if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
                if state == 0:
                    rect_list, state = menu.update(e, state)
                elif state == 1:
                    print 'Single Player!'
                    state = 0
                    self.running = False
                    engine.main()
                elif state == 2:
                    print 'Multiplayer!'
                    state = 0
                elif state == 3:
                    print 'Watch Replay!'
                    state = 0
                elif state == 4:
                    print 'Options!'
                    state = 0
                else:
                    print 'Exit!'
                    self.running = False
            
            if e.type == pygame.QUIT:
                self.running = False

        
        pygame.quit()
Exemplo n.º 4
0
    def test_main(self):
        self.runner_ok = 0
        test_self = self

        class FakeRunner(object):
            def __init__(self, mapp, playback_file, timeout, max_turns, bot_cmd, bot_class):
                test_self.assertEqual(1, mapp)
                test_self.assertEqual(2, playback_file)
                test_self.assertEqual(3, timeout)
                test_self.assertEqual(4, max_turns)
                test_self.assertEqual(5, bot_cmd)
                test_self.assertEqual(6, bot_class)
                test_self.runner_ok += 1
                sleep(2)

            def run(self):
                test_self.runner_ok += 1

        self.runner_ok = False
        import engine
        engine.sys.argv = [0, 1, 2, 3, 4, 5]
        engine.Runner = FakeRunner
        secs = engine.main(6)
        self.assertEqual(2, self.runner_ok)
        self.assertEqual(2, secs)
Exemplo n.º 5
0
def test_rule(rule):
    '''
        For every rule defined in rules.yaml, run engine against each known_job
        defined and ensure that the rule returned matches the rule defined.
        Note that such an implementation might cause high load on the lava
        server, and is rather slow.
    '''
    for known_job in rule['known_jobs']:
        _, engine_results = engine.main(known_job)
        assert rule in engine_results
Exemplo n.º 6
0
def start():
    """
    Main body
    """
    while True:
        print('')
        acct = input('Enter Twitter Account:')
        if len(acct) < 1:
            break
        url = twurl.augment(TWITTER_URL, {'screen_name': acct, 'count': '100'})
        connection = urllib.request.urlopen(url, context=ctx)
        data = connection.read().decode()

        jsn = json.loads(data)
        with open(FL_NAME, encoding="utf-8", mode="w") as f_l:
            json.dump(jsn, f_l, indent=4, ensure_ascii=False)
        main(FL_NAME)
        headers = dict(connection.getheaders())
        print('\nRemaining', headers['x-rate-limit-remaining'], '\n')
        if to_end(bonus=True):
            break
Exemplo n.º 7
0
def myengine(config):
    samples = config['parameters']['samples']
    steps = config['parameters']['steps']
    on_states = config['parameters']['on_states']
    off_states = config['parameters']['off_states']

    result = engine.main(samples=samples, steps=steps, debug=False, \
        progress=False, on_states=on_states, off_states=off_states)

    result['parameters'] = {'samples': samples, 'steps': steps}

    return result
Exemplo n.º 8
0
def run(samples=10,
        steps=10,
        debug=True,
        progress=False,
        on_states=[],
        off_states=[]):

    import engine

    result = engine.main(samples=samples, steps=steps, debug=debug, \
        progress=progress, on_states=on_states, off_states=off_states)

    result['parameters'] = {'samples': samples, 'steps': steps}

    return result
Exemplo n.º 9
0
def getmessage():
    crowd = request.form['Crowd']
    traffic = request.form['Traffic']
    greenery = request.form['Greenery']

    lat = request.form['lati']
    long = request.form['longi']
    distance = request.form['distance']
    print(lat, long)
    print(crowd, traffic, greenery)
    global rsh
    rsh, islaps = engine.main(lat, long, distance, crowd, traffic, greenery)
    if 'laps' in islaps:
        return {'map_name': rsh + '.html', 'warning': islaps['lap']}
    else:
        return {'map_name': rsh + '.html'}
Exemplo n.º 10
0
    def test_main(self):
        self.runner_ok = 0
        test_self = self
        class FakeRunner(object):
            def __init__(self, mapp, playback_file, timeout, max_turns, bot_cmd, bot_class):
                test_self.assertEqual(1, mapp)
                test_self.assertEqual(2, playback_file)
                test_self.assertEqual(3, timeout)
                test_self.assertEqual(4, max_turns)
                test_self.assertEqual(5, bot_cmd)
                test_self.assertEqual(6, bot_class)
                test_self.runner_ok += 1
                sleep(2)

            def run(self):
                test_self.runner_ok += 1

        self.runner_ok = False
        import engine
        engine.sys.argv = [0,1,2,3,4,5]
        engine.Runner = FakeRunner
        secs = engine.main(6)
        self.assertEqual(2, self.runner_ok)
        self.assertEqual(2, secs)
Exemplo n.º 11
0
    """Given a target name return the appropriate grip piplein."""
    def getSensor(self, target):
        gpf = GripPipelineFactory()
        pipeline = gpf.getGripPipeline(target)
        if target == "yellowbox":
            return DreadbotYellowboxSensor(target, pipeline)
        if target == "autoline":
            return DreadbotAutolineSensor(target, pipeline)
        return None


class GripPipelineFactory(object):
    """Given a target name return the appropriate grip piplein."""
    def getGripPipeline(self, target):
        if target == "yellowbox":
            from yellowboxgrip import GripPipeline

            return GripPipeline()
        if target == "autoline":
            from autolinegripm4 import GripPipeline

            return GripPipeline()

        return None


if __name__ == "__main__":
    sf = SensorFactory()
    import engine
    engine.main(sf)
Exemplo n.º 12
0
def stress_test(x):
    listing = range(x)
    main(listing,comp)
Exemplo n.º 13
0
def stress_test(x):
    listing = range(2,x)
    main(listing,fib2)
Exemplo n.º 14
0
def test_this_2():
    result = engine.main(samples=1000000, steps=50, debug=False, \
        progress=True, on_states=[], off_states=[])

    json.dump(result, open('test_attr_cy_long.json', 'w'), indent=4)
Exemplo n.º 15
0
n_input_files = len(input_fnames)
names_concat = '_'.join(input_fnames)

if __name__ == "__main__":
    # set the constants for the stories
    stories_kwargs = dict(
        mark_end_state=False,  # attach end_of_state, end_of_story marker
        attach_questions=
        False,  # attach question marker at the end of the state (e.g. Q_subject)
        gen_symbolic_states=True,  # GEN_SYMBOLIC_STATES = False
        attach_role_marker=False,  # ATTACH_ROLE_MARKER = False
        attach_role_maker_before=[
            'Pronoun', 'Name', 'Pronoun_possessive', 'Pronoun_object'
        ],
    )

    # if there is only one 1 schema file, repeat & iter are the same thing
    if n_input_files == 1:
        n_iterations = n_iterations * n_repeats
        n_repeats = 1

    main(0,
         input_fnames,
         n_input_files,
         names_concat,
         n_iterations,
         n_repeats,
         write_to_files=True,
         stories_kwargs=stories_kwargs)
Exemplo n.º 16
0
for uid in data[0].split():

    result, data = mail.uid('fetch', uid, '(RFC822)')
    raw_email = data[0][1]

    email_message = email.message_from_string(raw_email.decode("utf-8"))

    m = re.search('TestJob (\d+): ', email_message['Subject'])
    lava_job_id = m.group(1)

    if cache.has(lava_job_id):
        print("Lava job already processed: {}".format(lava_job_id))
        continue

    _, job_results = engine.main(lava_job_id)
    if not job_results:
        # We could cache failed jobs so they don't rerun
        # But, this way if the rules are updated, it will re-try and send
        # a notification.
        # cache.cache_job(lava_job_id)
        print("No results found for job id {}".format(lava_job_id), file=sys.stderr)
        continue

    response_content = ""
    for result in job_results:
        response_content += result['description']

    job_results_no_description = []
    for result in job_results:
        del result['description']
Exemplo n.º 17
0
 def _run():
     """ run your fun"""
     main(event_manager)
Exemplo n.º 18
0
		self.scale.val = np.log10(z)
		# z = 20px * m/px = r
		
	def switchFocus(self):
		idx = self.bodies.index(self.focus)
		if idx == len(self.bodies)-1:
			idx = 0
		else:
			idx += 1
		self.focus = self.bodies[idx]
		
	def deleteFocus(self):
		self.bodies.remove(self.focus)
		self.focus = self.genFocus()
		
		
def drawBody(screen, body, color=WHITE):
	'''
	Draws body to screen using a circle
	Draw Radius is determined by looking at scale
	'''
	calc_r = int(body.getRadius() / SCALE) # m / m/px
	r = max([MIN_SIZE, calc_r])
	pos_x = int((body.getCoordinates()[0] - FOCUS[0]) / SCALE + WIN_Y/2)
	pos_y = int((body.getCoordinates()[1] - FOCUS[1]) / SCALE + WIN_Y/2)
	if 0<pos_x<WIN_Y and 0<pos_y<WIN_Y:
		pygame.draw.circle(screen, color, (pos_x, pos_y), r)
		
		
main(WIN_X, WIN_Y, FPS, GameScene())
Exemplo n.º 19
0
 def test_main(self):
     self.assertEqual(engine.main(), 0)
Exemplo n.º 20
0
def main():
    engine.main()
Exemplo n.º 21
0
            gravity = PVector(0, .5 * entity.mass)
            entity.apply_force(gravity)

            friction = self.calculate_friction(entity.velocity)
            entity.apply_force(friction)

            entity.update(screen)

    def calculate_friction(self, velocity):
        friction_coefficient = .5
        normal_force = 1
        friction_magnitude = friction_coefficient * normal_force

        friction = copy.deepcopy(velocity)
        friction *= -1
        friction.normalize()
        friction *= friction_magnitude

        return friction

    def calculate_noise(self):
        x = float(self.t) * self.span / self.points - 0.5 * self.span
        noise = pnoise1(x + self.base, self.octaves)
        self.t += 1
        return noise


main_loop = Loop()
engine.main(main_loop.loop, 15, screen_size=(WINDOW_WIDTH, WINDOW_HEIGHT))
Exemplo n.º 22
0
def index():
    file = request.files["imageLoader"]
    return engine.main(file)
Exemplo n.º 23
0
 def _run():
     """ run your fun"""
     asyncio.run(main())
Exemplo n.º 24
0
# setting up game window parameters and initialising
panel_height = 10
screen_width = max(map.width, 80)
screen_height = map.height + panel_height

libtcod.console_set_custom_font(
    'arial12x12.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
libtcod.console_init_root(screen_width, screen_height, name)

# the level generation loop
while True:
    libtcod.console_clear(0)
    # engine.main(..) returns True only if an exit command is encountered
    if engine.main(map,
                   entities,
                   player,
                   specs_dict.get('fov', 10),
                   True,
                   specs_dict.get('health_boost', 1),
                   spell_dict=spell_dict):
        break

    # modifying attributes for new level
    prev_health = player.hp
    max_health = player.max_hp + 5
    mana = player.mana + 2
    for m in monsters_dict:
        monsters_dict[m]['hp'] += 2
    map, entities, player = generate(specs_dict, player_dict, monsters_dict)
    player.hp, player.max_hp, player.mana = prev_health, max_health, mana
Exemplo n.º 25
0
from engine import main

if __name__ == '__main__':
    main()
Exemplo n.º 26
0
        print(
            "Please enter 0 for Rock, 1 for Paper, or 2 for Scissor. The game will now exit. \n"
        )
        exit()
except ValueError:
    print("Invalid input. The game will now exit. \n")
    exit()

if int(user_choice) == 0:
    print("You chose Rock!")
elif int(user_choice) == 1:
    print("You chose Paper!")
elif int(user_choice) == 2:
    print("You chose Scissors!")

result = engine.main(int(user_choice))

if result == True:
    print("You win!")
elif result == False:
    print("You lose!")
elif result == None:
    print("It's a draw!")

while True:
    game_restart = input("Another game? (Enter y or n): ")
    if (game_restart == "y"):
        os.execv(__file__, sys.argv)
    elif (game_restart == "n"):
        exit()
    else:
Exemplo n.º 27
0
import pygame

import engine
from vectors.PVector import PVector


class Loop:
    @staticmethod
    def loop(screen):
        screen.fill((0, 0, 0))

        center = PVector(screen.get_width() // 2, screen.get_height() // 2)
        mouse_position = PVector(pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1])

        pygame.draw.line(screen, (255, 255, 255), tuple(center), tuple(mouse_position), 1)

        line = center - mouse_position
        s = pygame.Surface((line.magnitude(), 10))
        s.fill((255, 255, 255))
        screen.blit(s, (0, 0))


loop = Loop()
engine.main(loop.loop)
Exemplo n.º 28
0
def stress_test(x):
    listing = range(x)
    main(listing, comp)
Exemplo n.º 29
0
from flask import Flask
import engine

app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'Hello World!'


if __name__ == '__main__':
    engine.main()
    app.run()
Exemplo n.º 30
0
#!/usr/bin/env python
#
# http://www.bionicbunny.org/
# Copyright (c) 2013 Sladeware LLC
#
# Author: Oleksandr Sviridenko
#
# __main__ alows user to run b3 package as a script:
# $ python -m bb.tools.b3

import sys

import engine

sys.exit(engine.main())
Exemplo n.º 31
0
        self.walkerGSprite = WalkerSprite(self.walkerG)
        self.walkerGSprite.color = (100, 100, 255)

        self.walkerCD = CustomDistributionRandomWalker((100, 200))
        self.walkerCDSprite = WalkerSprite(self.walkerCD)
        self.walkerCDSprite.color = (255, 0, 0)

        self.walkerN = NonUniformWalker((700, 500))
        self.walkerNSprite = WalkerSprite(self.walkerN)
        self.walkerNSprite.color = (0, 255, 0)

    def loop(self, screen):
        self.walkerRSprite.display(screen)
        self.walkerR.update()

        self.walkerNSprite.display(screen)
        self.walkerN.update()

        self.walkerGSprite.display(screen)
        self.walkerG.update()

        self.walkerCDSprite.display(screen)
        self.walkerCD.update()

        random.seed()


main_loop = Loop()

engine.main(main_loop.loop)
Exemplo n.º 32
0
#!/usr/bin/python3
# coding:utf8
import asyncio
import sys
import common
from engine import main
from common.Daemon import Daemon

if __name__ == '__main__':

    sys.excepthook = common.new_hook

    daemon = Daemon('watch_process.pid')
    if len(sys.argv) == 2:
        if 'start' == sys.argv[1]:
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            daemon.restart()
        else:
            print('unknown command')
            sys.exit(2)
        sys.exit(0)
    elif len(sys.argv) == 1:
        asyncio.run(main())
    else:
        print('usage: %s start|stop|restart' % sys.argv[0])
        sys.exit(2)
Exemplo n.º 33
0
#!/usr/bin/python3
#coding:utf8
import sys
import common
from engine.handler import event_manager
from engine import main
from common.Daemon import Daemon

if __name__ == '__main__':

    sys.excepthook = common.new_hook

    daemon = Daemon('watch_process.pid')
    if len(sys.argv) == 2:
        if 'start' == sys.argv[1]:
            daemon.start()
        elif 'stop' == sys.argv[1]:
            daemon.stop()
        elif 'restart' == sys.argv[1]:
            daemon.restart()
        else:
            print('unknown command')
            sys.exit(2)
        sys.exit(0)
    elif len(sys.argv) == 1:
        main(event_manager)
    else:
        print('usage: %s start|stop|restart' % sys.argv[0])
        sys.exit(2)
Exemplo n.º 34
0
import engine
from ecosystem.Loop import Loop

if __name__ == "__main__":
    main_loop = Loop()
    engine.main(main_loop.loop, 15)
Exemplo n.º 35
0
def open_engine():
    engine.main()
Exemplo n.º 36
0
def stress_test(x):
    listing = range(2, x)
    main(listing, fib2)