• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python world.World类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中world.World的典型用法代码示例。如果您正苦于以下问题:Python World类的具体用法?Python World怎么用?Python World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了World类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: onDrawFunnelsButton

    def onDrawFunnelsButton(self, change=True):

        if change == True:
            self.funnel_number_x = self.funnel_number_x + 1

            if self.funnel_number_x == 5:
                self.funnel_number_x = 0
                self.funnel_number_y = self.funnel_number_y + 1
                if self.funnel_number_y == 5:
                    self.funnel_number_y = 0

        print "I pressed the draw funnels button"
        variance_x = 1.5 + abs(self.XVelocity_drawing*0.1)
        variance_y = 1.5 + abs(self.YVelocity_drawing*0.1)
        variance_z = 0.2

        self.ActionSet.computeAllPositions(self.XVelocity_drawing,self.YVelocity_drawing)
        print np.shape(self.ActionSet.p_x_trajectories), "is my shape"

        for i in xrange(np.size(self.ActionSet.p_x_trajectories,1)):
            print i
            x_center = self.ActionSet.p_x_trajectories[self.funnel_number_x,i]
            y_center = self.ActionSet.p_y_trajectories[self.funnel_number_y,i]
            print x_center, y_center
            World.buildEllipse(i, [x_center,y_center,0], variance_x*i/10.0*0.5, variance_y*i/10.0*0.5, variance_z, alpha=0.3)
开发者ID:peteflorence,项目名称:DirectSim,代码行数:25,代码来源:CarSimulator.py


示例2: test

def test():
    the_map = Map()
    tic = time.clock()
    the_map.discretize_map()
    print time.clock() - tic
    #obstacle = Polygon([(40,15), (45,15), (45,20), (40,20)], safety_region_length=4.0)
    #the_map.add_obstacles([obstacle])

    tend = 10
    dT = 1
    h  = 0.05
    N  = int(tend/h)  + 1
    N2 = int(tend/dT) + 1

    x0 = np.array([10, 10, 0.0, 3.0, 0, 0])
    xg = np.array([50, 50, 0])

    myDynWnd = DynamicWindow(dT, N2)

    v = Vessel(x0, xg, h, dT, N, [myDynWnd], is_main_vessel=True, vesseltype='viknes')
    v.current_goal = np.array([50, 50])

    world = World([v], the_map)

    myDynWnd.the_world = world
    
    world.update_world(0,0)

    fig = plt.figure()
    ax  = fig.add_subplot(111, aspect='equal', autoscale_on=False,
                          xlim=(-10, 160), ylim=(-10, 160))
    
    world.visualize(ax, 0, 0)
    
    plt.show()
开发者ID:thomsten,项目名称:project-thesis-simulator,代码行数:35,代码来源:ctrl_DWA.py


示例3: __init__

 def __init__(self, world_map, multiplayer):
     World.__init__(self, world_map, multiplayer)
     self._create_sprites()
     self.brick_energy()
     self.set_bounds_energy()
     self.set_dynamics_energy()
     self._set_walls()
开发者ID:filareta,项目名称:battle_city_game,代码行数:7,代码来源:world_wrapper.py


示例4: Game

class Game(object):

    def __init__(self):
        pygame.init()
        self.caption = "Zelda Love Candy"
        self.resolution = (640, 480)
        self.screen = pygame.display.set_mode(self.resolution)
        pygame.display.set_caption(self.caption)
        self.clock = pygame.time.Clock()
        self.isGameOver = False

        self.world = World()

    def update(self):
        """overide this to add neccessary update
        """
        self.world.update()
        self.world.render(self.screen)

    def start(self):
        """ start the game
        """
        while not self.isGameOver:
            self.clock.tick(30)
            for events in pygame.event.get():
                if events.type == pygame.QUIT:
                    self.isGameOver = True

            self.update()
            pygame.display.flip()

        pygame.quit()
开发者ID:Morfyo,项目名称:PYTHON,代码行数:32,代码来源:game.py


示例5: InfiniteQuestWindow

class InfiniteQuestWindow(QMainWindow):
    # ----------------------------------------------------------------------
    def __init__(self):
        """"""
        super(InfiniteQuestWindow, self).__init__()
        self.setWindowTitle("Infinite Quest")
        self.mapview = MapView()
        # self.mapview = QGraphicsView()
        # self.sc = MapScene()
        # self.mapview.setScene(self.sc)
        self.mapview.installEventFilter(self)

        self.setCentralWidget(self.mapview)

        self.minimap = MiniMapView(self.mapview)
        minimap_dw = QDockWidget()
        minimap_dw.setWidget(self.minimap)
        self.addDockWidget(Qt.LeftDockWidgetArea, minimap_dw)

        self.statushero = StatusHeroWidget()
        statushero_dw = QDockWidget()
        statushero_dw.setWidget(self.statushero)
        self.addDockWidget(Qt.LeftDockWidgetArea, statushero_dw)

        # self.mapview.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding))

        self.world = World()

        self.hero = Hero(self.world.map(), *self.world.map().find_passable_landscape_coords())

        self.connection = Connection(self.hero, self.world)

        self.game_state_update()

    # ----------------------------------------------------------------------
    def game_state_update(self):
        """"""
        st = self.connection.get_world_state()
        self.mapview.scene.mapstate_update(st["map_state"])

    # ----------------------------------------------------------------------
    def eventFilter(self, obj, ev):
        """"""
        if ev.type() == QEvent.KeyPress:
            try:
                self.connection.action(
                    {
                        Qt.Key_Up: "move_up",
                        Qt.Key_Down: "move_down",
                        Qt.Key_Right: "move_right",
                        Qt.Key_Left: "move_left",
                    }[ev.key()]
                )
                self.game_state_update()
                return True
            except KeyError:
                pass
        else:
            pass
        return super(InfiniteQuestWindow, self).eventFilter(obj, ev)
开发者ID:darvin,项目名称:infinitequest,代码行数:60,代码来源:qinfinitequest.py


示例6: onAddAccelSphereButton

 def onAddAccelSphereButton(self):
     self.AccelSphere_toggle = not self.AccelSphere_toggle
     if not self.AccelSphere_toggle:
         self.AccelSphere = World.buildAccelSphere([self.XVelocity_drawing*self.ActionSet.t_f,self.YVelocity_drawing*self.ActionSet.t_f,self.ZVelocity_drawing*self.ActionSet.t_f], a_max=0.0)
         self.AccelArrow = World.buildAccelArrow([0,0,0], 0.0+9.8, 0.0, 0.0)
     else:
         self.redrawAccelSphere()
开发者ID:peteflorence,项目名称:DirectSim,代码行数:7,代码来源:CarSimulator.py


示例7: main

def main():

    # Construct the objects that will run the game.
    courier = Courier()
    world = World(courier)
    gui = Gui(courier, world)

    systems = [courier, world, gui]

    # Connect to the server and wait until the game is ready to begin.
    courier.setup()
    courier.login(world.setup)

    # Open up a window and get ready to start playing.
    clock = pygame.time.Clock()
    frequency = 40

    gui.setup()
    
    # Play the game!
    while world.still_playing():
        time = clock.tick(frequency) / 1000
        for system in systems:
            system.update(time)

    # Exit gracefully.
    for system in systems:
        system.teardown()
开发者ID:kxgames,项目名称:ClayPygeons,代码行数:28,代码来源:client.py


示例8: MainGameState

class MainGameState(object):
    def __init__(self):
        self.background = backgrounds.Cave()
        self.world = World()
        self.player = Player(self.world, (-100, 52.4))
        self.camera = Camera((0, 100.0), tracking=self.player)

    def update(self, delta):
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit(0)
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    raise states.StateChange(states.PauseMenuState(self))

        self.world.center = self.player.pos

        self.background.update(delta)
        self.world.update(delta)
        self.player.update(delta)
        self.camera.update(delta)

    def render(self, screen):
        self.background.render(screen, self.camera)
        self.world.render(screen, self.camera)
        self.player.render(screen, self.camera)
开发者ID:Cynerva,项目名称:jttcotm,代码行数:26,代码来源:maingame.py


示例9: onBuildWorldFromRandomObstacles

 def onBuildWorldFromRandomObstacles(self):
     distances = self.Sensor.raycastAll(self.frame)
     firstRaycastLocations = self.Sensor.invertRaycastsToLocations(self.frame, distances)
     self.LineSegmentWorld = World.buildLineSegmentWorld(firstRaycastLocations)
     self.LineSegmentLocator = World.buildCellLocator(self.LineSegmentWorld.visObj.polyData)
     self.Sensor.setLocator(self.LineSegmentLocator)
     self.updateDrawIntersection(self.frame)
开发者ID:peteflorence,项目名称:DirectSim,代码行数:7,代码来源:CarSimulator.py


示例10: greedy

def greedy(world):
    initial_world = World(world)
    global solver
    cmds = ''
    while not world.terminated:
        if len(cmds) > 10000:
            break
        #print cmds
        t = utils.path_to_nearest_lambda_or_lift(world)
        if t is None:
            break
        _, c = t
        #print c
        world = world.apply_commands(c)
        cmds += c
        if world.score > solver.best_score:
            solver.best_score = world.score
            solver.best_solution = cmds
            
    print 'greedy', solver.best_score, len(solver.best_solution)
    
    if initial_world.apply_commands(cmds).score < 0:
        solver.best_score = 0
        solver.best_solution = ''
        print 'shit!'
开发者ID:Vlad-Shcherbina,项目名称:icfpc2012-tbd,代码行数:25,代码来源:entry_point.py


示例11: compile

    def compile(self, candidate):
        world = World(self.world)
        compiled = []
        for gene in candidate.genes:
            gene_type, gene_value = gene
            if gene_type == 'wait':
                world = world.apply_command('W')
                compiled.append('W')
                if world.terminated: break
            elif gene_type == 'move':
                destination = gene_value
                commands = pathfinder.commands_to_reach(world, destination)
                for c in commands:
                    direction = [-world.width, world.width, -1, 1, 0]['UDLRA'.index(c)]
                    if world.data[world.robot + direction] == 'W' and world.razors > 0:
                        world = world.apply_command('S')
                        compiled.append('S')
                        if world.terminated: break
                    world = world.apply_command(c)
                    compiled.append(c)
                    if world.terminated: break
            else:
                assert False, "Unrecognized gene: %s" % gene_type
            if world.terminated:
                break

        if not world.terminated:
            compiled.append('A')
        return ''.join(compiled)
开发者ID:Vlad-Shcherbina,项目名称:icfpc2012-tbd,代码行数:29,代码来源:genetic.py


示例12: cleanup

def cleanup():
    world = World(None)
    conn = sqlite3.connect(DB_PATH)
    query = 'select x, y, z from block order by rowid desc limit 1;'
    last = list(conn.execute(query))[0]
    query = 'select distinct p, q from block;'
    chunks = list(conn.execute(query))
    count = 0
    total = 0
    delete_query = 'delete from block where x = %d and y = %d and z = %d;'
    print 'begin;'
    for p, q in chunks:
        chunk = world.create_chunk(p, q)
        query = 'select x, y, z, w from block where p = :p and q = :q;'
        rows = conn.execute(query, {'p': p, 'q': q})
        for x, y, z, w in rows:
            if chunked(x) != p or chunked(z) != q:
                continue
            total += 1
            if (x, y, z) == last:
                continue
            original = chunk.get((x, y, z), 0)
            if w == original or original in INDESTRUCTIBLE_ITEMS:
                count += 1
                print delete_query % (x, y, z)
    conn.close()
    print 'commit;'
    print >> sys.stderr, '%d of %d blocks will be cleaned up' % (count, total)
开发者ID:andrew889,项目名称:Craft,代码行数:28,代码来源:server.py


示例13: setup_world

def setup_world():
    w = World()
    w.sim = PhysicsSimulator( timestep = None )
    block = QuadBlock(32)
    bs = BlockStructure(block)
    thing = Thing( w, bs.create_collision_shape(), 1.0, 1.0 )
    return block, thing
开发者ID:steinarvk,项目名称:blockspace,代码行数:7,代码来源:test_component.py


示例14: ExploreScreen

class ExploreScreen(GameScreen):

    def __init__(self, app):

        GameScreen.__init__(self, app)

        utilities.setApp(self.app)

        self.world = World(10)

        self.app.taskMgr.add(self.update, "update")

        self.app.accept("a", self.world.player.moveLeft, [True])
        self.app.accept("a-up", self.world.player.moveLeft, [False])

        self.app.accept("d", self.world.player.moveRight, [True])
        self.app.accept("d-up", self.world.player.moveRight, [False])

        self.app.accept("space", self.world.player.jump, [True])
        self.app.accept("space-up", self.world.player.jump, [False])

        self.app.accept("c", self.world.player.crouch, [True])
        self.app.accept("c-up", self.world.player.crouch, [False])

        self.app.accept("mouse1", self.world.player.activate, [])

        self.app.accept("escape", sys.exit, [])

        #self.app.accept("h", self.showDBG, [True])
        #self.app.accept("h-up", self.showDBG, [False])

        self.prevTime = 0

        self.app.mousePos = Point2()
        self.app.disableMouse()


        self.app.rl = base.camLens.makeCopy()

        #bullet testing
        #debugNode = BulletDebugNode('Debug')
        #debugNode.showWireframe(True)
        #debugNode.showConstraints(True)
        #debugNode.showBoundingBoxes(False)
        #debugNode.showNormals(False)
        #self.debugNP = render.attachNewNode(debugNode)
        #self.debugNP.show()

        #self.world.bw.setDebugNode(self.debugNP.node())

    def update(self, task):
        delta = task.time - self.prevTime
        self.prevTime = task.time

        if(self.app.mouseWatcherNode.hasMouse()):
            self.app.mousePos.x = self.app.mouseWatcherNode.getMouseX()
            self.app.mousePos.y = self.app.mouseWatcherNode.getMouseY()
            self.world.update(delta)  

        return Task.cont
开发者ID:fcostin,项目名称:gravbot,代码行数:60,代码来源:explorescreen.py


示例15: main

def main():
    parser = argparse.ArgumentParser(
        description="Compute the optimal path using A*"
    )
    group = parser.add_mutually_exclusive_group()
    group.add_argument(
        "-w", "--world", help="The filename of the world to load",
    )
    group.add_argument(
        "-s", "--size", type=int, help="Size of the random board to be generated"
    )
    parser.add_argument(
        "-f", "--file", help="The file to output the world to"
    )
    parser.add_argument(
        "heuristic", type=int,
        help="The heuristic number to run (in range(1, 7))"
    )
    args = parser.parse_args()
    if args.world:
        newWorld = World(filepath=args.world)
    elif args.size:
        newWorld = World(height=args.size, width=args.size)
    else:
        newWorld = World(height=10, width=10)
    if args.file:
        newWorld.write_world(args.file)
    astar = AStar(newWorld, args.heuristic)
    astar.start()
开发者ID:zoccihedron,项目名称:CS4341_Assignment_1,代码行数:29,代码来源:main.py


示例16: Simulation

class Simulation():
    """The simulation class executes the simulation.

    Upon initialization it creates the system - the world, sun, oceans etc.
    The step function proceeds forwards in time.
    """

    def __init__(self):
        """Create the simulation."""
        log("> Creating world")
        self.create_world()
        log("> Creating sun")
        self.create_sun()

    def create_world(self):
        """Create the world."""
        self.world = World()

    def create_sun(self):
        """Create the sun."""
        self.sun = Sun()

    def step(self):
        """Advance 1 time step."""
        self.world.slosh_oceans()
        self.world.transfer_energy_vertically()
        self.world.transfer_energy_horizontally()
        self.world.absorb_energy_from_core()
        self.world.absorb_energy_from_sun(self.sun)
开发者ID:thomasmorgan,项目名称:Eden,代码行数:29,代码来源:simulation.py


示例17: main

def main(world_size, slowness):
    world = World(world_size)
    game = world.go()
    print('New world was born')
    for m in world.monsters:
        print(event_message(('spawn', m, m.coord, None)))
    try:
        for step in game:
            was_event = False
            for event in step:
                if event:
                    was_event = True
                    print(event_message(event))
                    time.sleep(slowness)
            if world.move_number == 0 or was_event:
                print(coord_line(world))
            print('{}) {}'.format(world.move_number, world))
            time.sleep(slowness)
    except KeyboardInterrupt:
        print(world.stat.get_stat())
        sys.exit(1)
    if world.monsters:
        winner = world.monsters.pop()
        print('Finished! Last hero is {}'.format(winner.name))
        print(text_winner(winner))
    else:
        print('Finished. No one survived')
    print('Enter or any command to see game statistics.')
    input()
    print(world.stat.get_stat())
开发者ID:MrYellowgreen,项目名称:MindlessLands,代码行数:30,代码来源:console_play.py


示例18: redrawFunnelsButton

    def redrawFunnelsButton(self, change=True):
        if self.funnels_toggle:
            variance_x = 1.5 + abs(self.XVelocity_drawing*0.1)
            variance_y = 1.5 + abs(self.YVelocity_drawing*0.1)
            variance_z = 1.5 + abs(self.ZVelocity_drawing*0.1)

            #self.ActionSet.computeAllPositions(self.XVelocity_drawing,self.YVelocity_drawing,self.ZVelocity_drawing)

            #find almost equally spaced indexes
            indices_to_draw = np.zeros(10)
            
            indices_to_draw[0] = 0
            next_time = 0 + self.ActionSet.t_f/10.0

            number = 0
            for index, value in enumerate(self.ActionSet.overall_t_vector):
                if value > next_time:
                    indices_to_draw[number] = index
                    number = number + 1
                    next_time = next_time + self.ActionSet.t_f/10.0

            for index, value in enumerate(indices_to_draw):
                time = self.ActionSet.overall_t_vector[value]
                x_center = self.ActionSet.pos_trajectories[self.funnel_number,0,value]
                y_center = self.ActionSet.pos_trajectories[self.funnel_number,1,value]
                z_center = self.ActionSet.pos_trajectories[self.funnel_number,2,value]
                World.buildEllipse(index, [x_center,y_center,z_center], variance_x*time, variance_y*time, variance_z*time, alpha=0.3)
开发者ID:peteflorence,项目名称:DirectSim,代码行数:27,代码来源:CarSimulator.py


示例19: simulate

def simulate(living,nticks=None, max_bush_count=None, max_red_bush_count=None):
	"""Used to run a simulation, placed outside of class to enable multiprocessing"""
	creatures = living[0]
	predators = living[1]

	w = World(gene_pool_creatures=creatures, gene_pool_predators=predators, nticks=nticks,max_bush_count=max_bush_count,max_red_bush_count=max_red_bush_count)
	w.run_ticks()
	return (w.get_creatures(), w.get_predators())
开发者ID:andy071001,项目名称:artificialbrains,代码行数:8,代码来源:darwin.py


示例20: init_placement

 def init_placement(self, creature_type):
     for x in range(World.get_max_x(self.inst_of_world)):
         for y in range(World.get_max_y(self.inst_of_world)):
             if World.get_xy(self.inst_of_world, x, y) is None:
                 World.set_xy(self.inst_of_world, x, y, creature_type)
                 self.current_position_x = x
                 self.current_position_y = y
                 return
开发者ID:exp0nge,项目名称:Ecosystem-AI,代码行数:8,代码来源:organisms.py



注:本文中的world.World类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python image_io.PNGWriter类代码示例发布时间:2022-05-26
下一篇:
Python world.tile_exists函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap