Ejemplo n.º 1
0
 def __init__(self, sig, child, buf):
     super(TranslateMPI, self).__init__()
     self.sig = sig
     self.child = child
     self.buf = buf
     self.indent = [INDENT]
     self.blocker = Blocker(self, buf)
     self.parent = None
Ejemplo n.º 2
0
 def _add_features(self):
     # TODO: factor this out into feature generator
     for room in self._layout.rooms:
         feature = random.choice([None, 'light', 'fountain', 'library'])
         if feature == 'light':
             coords = random.sample([
                 (room.x + 1, room.y + 1),
                 (room.x + room.grid.size_x - 2, room.y + 1),
                 (room.x + 1, room.y + room.grid.size_y - 2),
                 (room.x + room.grid.size_x - 2,
                  room.y + room.grid.size_y - 2),
             ], random.randint(1, 4))
             for x, y in coords:
                 self.add_entity(
                     Entity(Renderable(light_anim, memorable=True),
                            Blocker(blocks_movement=True),
                            Description('Light'),
                            Position(x, y, Position.ORDER_FEATURES)))
         elif feature == 'fountain':
             self.add_entity(
                 Entity(
                     Renderable(fountain_anim, memorable=True),
                     Blocker(blocks_movement=True), Description('Fountain'),
                     Position(room.x + room.grid.size_x / 2,
                              room.y + room.grid.size_y / 2,
                              Position.ORDER_FEATURES)))
         elif feature == 'library':
             y = room.y + room.grid.size_y - 1
             for x in xrange(room.x + 1, room.x + room.grid.size_x - 1):
                 if self._layout.grid[x, y] != LayoutGenerator.TILE_WALL:
                     continue
                 if x == room.x + 1 and self._layout.grid[
                         room.x, y - 1] != LayoutGenerator.TILE_WALL:
                     continue
                 if x == room.x + room.grid.size_x - 2 and self._layout.grid[
                         x + 1, y - 1] != LayoutGenerator.TILE_WALL:
                     continue
                 self.add_entity(
                     Entity(
                         Renderable(random.choice(library_texes),
                                    memorable=True),
                         Blocker(blocks_movement=True),
                         Description('Bookshelf'),
                         Position(x, y - 1, Position.ORDER_FEATURES)))
Ejemplo n.º 3
0
 def __init__(self, **params):
     pb = {'blocksize': params['block_size'],
           'hashtype': params['hash_algorithm'],
           'archipelago_cfile': params['archipelago_cfile'],
           }
     self.blocker = Blocker(**pb)
     pm = {'namelen': self.blocker.hashlen,
           'archipelago_cfile': params['archipelago_cfile'],
           }
     self.mapper = Mapper(**pm)
Ejemplo n.º 4
0
 def make_blockers(self, number):
     blockerGroup = pygame.sprite.Group()
     for row in range(4):
         for column in range(9):
             blocker = Blocker(10, sett.GREEN, row, column)
             blocker.rect.x = 50 + (200 * number) + (column * blocker.width)
             blocker.rect.y = sett.BLOCKERS_POSITION + (row *
                                                        blocker.height)
             blockerGroup.add(blocker)
     return blockerGroup
Ejemplo n.º 5
0
def create_barriers(ai_settings, screen, barriers):
    for number in range(4):
        for row in range(5):
            for column in range(12):
                blocker = Blocker(screen, 10, ai_settings.barrier_color, row,
                                  column)
                blocker.rect.x = 250 + (200 * number) + (column *
                                                         blocker.width)
                blocker.rect.y = ai_settings.barrier_height + (row *
                                                               blocker.height)
                barriers.add(blocker)
Ejemplo n.º 6
0
    def compile_script(script):
        first_tokenizer = FirstTokenizer(script)
        OpFinder(first_tokenizer.tokens)

        blocker = Blocker(first_tokenizer.tokens)
        line_blocker = LineBlocker(blocker.block)

        FncFinder(line_blocker.output_block.tokens)
        shunter = Shunter(line_blocker.output_block)

        GoToIfyer(shunter.output_block)

        return shunter.output_block
Ejemplo n.º 7
0
def create_player(x, y):
    return Entity(
        Player(),
        Position(x, y, Position.ORDER_PLAYER),
        Actor(100, player_act),
        FOV(10),
        Movement(),
        Renderable(player_tex),
        Blocker(blocks_movement=True),
        Health(100),
        Fighter(1, 0),
        Inventory(),
    )
Ejemplo n.º 8
0
def create_random_monster(x, y):
    name, tex = get_random_monster_params()
    monster = Entity(
        Actor(80, monster_act),
        Position(x, y, Position.ORDER_CREATURES),
        Movement(),
        Renderable(tex),
        Blocker(blocks_movement=True, bump_function=monster_bump),
        Health(2),
        Fighter(1, 0),
        CorpseGenerator(),
        InFOV(),
        Description(name),
    )
    return monster
Ejemplo n.º 9
0
 def _process_layout(self):
     grid = self._layout.grid
     for x in xrange(grid.size_x):
         for y in xrange(grid.size_y):
             tile = grid[x, y]
             if tile in (LayoutGenerator.TILE_DOOR_CLOSED,
                         LayoutGenerator.TILE_DOOR_OPEN):
                 self.add_entity(
                     create_door(x, y,
                                 tile == LayoutGenerator.TILE_DOOR_OPEN))
                 self.add_entity(
                     Entity(Description('Floor'), LayoutRenderable(tile),
                            Position(x, y)))
             elif tile == LayoutGenerator.TILE_WALL:
                 self.add_entity(
                     Entity(Description('Wall'), Blocker(True, True),
                            LayoutRenderable(tile),
                            Position(x, y, Position.ORDER_WALLS)))
             elif tile == LayoutGenerator.TILE_FLOOR:
                 self.add_entity(
                     Entity(Description('Floor'), LayoutRenderable(tile),
                            Position(x, y)))
Ejemplo n.º 10
0
    def __init__(self, **params):
        umask = params['umask']
        if umask is not None:
            os.umask(umask)

        path = params['path']
        if path and not os.path.exists(path):
            os.makedirs(path)
        if not os.path.isdir(path):
            raise RuntimeError("Cannot open path '%s'" % (path, ))

        p = {
            'blocksize': params['block_size'],
            'blockpath': os.path.join(path + '/blocks'),
            'hashtype': params['hash_algorithm'],
            'blockpool': params['blockpool']
        }
        self.blocker = Blocker(**p)
        p = {
            'mappath': os.path.join(path + '/maps'),
            'namelen': self.blocker.hashlen,
            'mappool': params['mappool']
        }
        self.mapper = Mapper(**p)
Ejemplo n.º 11
0
#!/usr/bin/env python

import time

import schedule

from blocker import Blocker
from config import SitesAvailabilityConfig
from hosts import HostsFileFacade

SCHEDULER_TICK_INTERVAL_IN_SEC = 30

hosts_file_facade = HostsFileFacade()
config = SitesAvailabilityConfig()
blocker = Blocker(hosts_file_facade, config)


def main():
    configure_scheduler()
    do_infinite_schedule_loop()


def configure_scheduler():
    schedule.every(1).minutes.do(update_state)


def do_infinite_schedule_loop():
    while True:
        schedule.run_pending()
        time.sleep(SCHEDULER_TICK_INTERVAL_IN_SEC)
Ejemplo n.º 12
0
import os
from blocker import Blocker

if __name__ == '__main__':
    blockbot = Blocker()
    blockbot.run()
Ejemplo n.º 13
0
def runGame(display):

    code = getInputData()
    IC = IntcodeComputer(code)
    # game = PILScreen()
    if display:
        game = Blocker(841, 600)
    count = 0

    paddlePos = 0

    # Set memory position 0 to 2, to play for free
    # IC.writeMem(0,2)

    ##################
    step = 0
    inp = []  #input??
    IC._output = []  # Clear the output list
    terminate = False
    stoppedAtInput = False
    HiScore = 0
    while not terminate:
        length = 0
        while length < 3 and not terminate:
            terminate, stoppedAtInput = IC.perform_one_operation(
                input=inp, stopAtInput=True)
            length = len(IC._output)

        # print(f'OutPut: {IC._output}')
        # print(f'Terminate: {terminate}')
        # print(f'stoppedAtInput: {stoppedAtInput}')
        # print(f'count: {count}')
        # print(f'Next instr: {IC._intCodeProgramDict[IC._memoryPosition]}')
        # print(f'Next memPos:{IC._memoryPosition}')

        if terminate: break

        try:
            x = IC._output[0]
            y = IC._output[1]
            t = IC._output[2]
            IC._output = []
        except Exception:
            print('EXCEPTION')
            break
            #game.show()

        ########   TILES
        #
        #   0 is an empty tile. No game object appears in this tile.
        #   1 is a wall tile. Walls are indestructible barriers.
        #   2 is a block tile. Blocks can be broken by the ball.
        #   3 is a horizontal paddle tile. The paddle is indestructible.
        #   4 is a ball tile. The ball moves diagonally and bounces off objects.

        if t == 3:
            paddlePos = x

        if t == 4:
            if paddlePos < x: inp = [1]
            elif paddlePos > x: inp = [-1]
            else: inp = [0]

        if x == -1 and y == 0:  # -1, 0, t gives SCORE
            if t > HiScore: HiScore = t
            if display: game.draw_text(str(HiScore))
        else:
            if t == 2: count += 1
            #if t != 0:
            if display: game.drawBrick(x, y, t)
        if display: game.screen_update()

    return count, HiScore
Ejemplo n.º 14
0
                   metavar='URL')
group.add_argument('-u',
                   help='Unblocking Mode',
                   type=str,
                   dest='urlU',
                   metavar='URL')
group.add_argument('-i',
                   help='Check Mode',
                   type=str,
                   dest='urlI',
                   metavar='URL')
group.add_argument('-g', help='Get Blocked URL list', action='store_true')

args = parser.parse_args()

b = Blocker()

if args.urlB == None and args.urlU == None and args.urlI == None and args.g == False:
    parser.print_help()

elif args.g:
    url_list = b.get_blocked()

    print('\n==================={ Blox }===================\n')
    print('[!] Blocked URL list\n')

    for url in url_list:
        print(f'  [+] {url}')

    print('\n==================={ Blox }===================\n')