コード例 #1
0
ファイル: build_fov_map.py プロジェクト: plomlompom/plomrogue
def build_fov_map(t):
    """Build Thing's FOV map."""
    from server.config.world_data import world_db, symbols_hide
    from server.utils import libpr, c_pointer_to_bytearray, c_pointer_to_string
    t["fovmap"] = bytearray(b'v' * (world_db["MAP_LENGTH"] ** 2))
    fovmap = c_pointer_to_bytearray(t["fovmap"])
    m = c_pointer_to_bytearray(world_db["MAP"])
    hide_string = c_pointer_to_string(symbols_hide)
    if libpr.build_fov_map(t["T_POSY"], t["T_POSX"], fovmap, m, hide_string):
        raise RuntimeError("Malloc error in build_fov_Map().")
コード例 #2
0
def build_fov_map(t):
    """Build Thing's FOV map."""
    from server.config.world_data import world_db, symbols_hide
    from server.utils import libpr, c_pointer_to_bytearray, c_pointer_to_string
    t["fovmap"] = bytearray(b'v' * (world_db["MAP_LENGTH"]**2))
    fovmap = c_pointer_to_bytearray(t["fovmap"])
    m = c_pointer_to_bytearray(world_db["MAP"])
    hide_string = c_pointer_to_string(symbols_hide)
    if libpr.build_fov_map(t["T_POSY"], t["T_POSX"], fovmap, m, hide_string):
        raise RuntimeError("Malloc error in build_fov_Map().")
コード例 #3
0
 def update_mem_and_memdepthmap_via_fovmap():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
     #             if ord_v == t["fovmap"][pos]]:
     #     t["T_MEMDEPTHMAP"][pos] = ord_0
     #     t["T_MEMMAP"][pos] = world_db["MAP"][pos]
     memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     memmap = c_pointer_to_bytearray(t["T_MEMMAP"])
     fovmap = c_pointer_to_bytearray(t["fovmap"])
     map = c_pointer_to_bytearray(world_db["MAP"])
     libpr.update_mem_and_memdepthmap_via_fovmap(map, fovmap, memdepthmap,
                                                 memmap)
コード例 #4
0
 def update_mem_and_memdepthmap_via_fovmap():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
     #             if ord_v == t["fovmap"][pos]]:
     #     t["T_MEMDEPTHMAP"][pos] = ord_0
     #     t["T_MEMMAP"][pos] = world_db["MAP"][pos]
     memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     memmap = c_pointer_to_bytearray(t["T_MEMMAP"])
     fovmap = c_pointer_to_bytearray(t["fovmap"])
     map = c_pointer_to_bytearray(world_db["MAP"])
     libpr.update_mem_and_memdepthmap_via_fovmap(map, fovmap, memdepthmap,
                                                 memmap)
コード例 #5
0
 def age_some_memdepthmap_on_nonfov_cells():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # ord_v = ord("v")
     # ord_0 = ord("0")
     # ord_9 = ord("9")
     # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
     #             if not ord_v == t["fovmap"][pos]
     #             if ord_0 <= t["T_MEMDEPTHMAP"][pos]
     #             if ord_9 > t["T_MEMDEPTHMAP"][pos]
     #             if not rand.next() % (2 **
     #                                   (t["T_MEMDEPTHMAP"][pos] - 48))]:
     #     t["T_MEMDEPTHMAP"][pos] += 1
     memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     fovmap = c_pointer_to_bytearray(t["fovmap"])
     libpr.age_some_memdepthmap_on_nonfov_cells(memdepthmap, fovmap)
コード例 #6
0
 def age_some_memdepthmap_on_nonfov_cells():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # ord_v = ord("v")
     # ord_0 = ord("0")
     # ord_9 = ord("9")
     # for pos in [pos for pos in range(world_db["MAP_LENGTH"] ** 2)
     #             if not ord_v == t["fovmap"][pos]
     #             if ord_0 <= t["T_MEMDEPTHMAP"][pos]
     #             if ord_9 > t["T_MEMDEPTHMAP"][pos]
     #             if not rand.next() % (2 **
     #                                   (t["T_MEMDEPTHMAP"][pos] - 48))]:
     #     t["T_MEMDEPTHMAP"][pos] += 1
     memdepthmap = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     fovmap = c_pointer_to_bytearray(t["fovmap"])
     libpr.age_some_memdepthmap_on_nonfov_cells(memdepthmap, fovmap)
コード例 #7
0
ファイル: ai.py プロジェクト: plomlompom/plomrogue
 def zero_score_map_where_char_on_memdepthmap(c):
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
     #           if t["T_MEMDEPTHMAP"][i] == mem_depth_c[0]]:
     #     set_map_score(i, 0)
     map = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     if libpr.zero_score_map_where_char_on_memdepthmap(c, map):
         raise RuntimeError("No score map allocated for "
                            "zero_score_map_where_char_on_memdepthmap().")
コード例 #8
0
ファイル: ai.py プロジェクト: plomlompom/plomrogue
 def zero_score_map_where_char_on_memdepthmap(c):
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
     #           if t["T_MEMDEPTHMAP"][i] == mem_depth_c[0]]:
     #     set_map_score(i, 0)
     map = c_pointer_to_bytearray(t["T_MEMDEPTHMAP"])
     if libpr.zero_score_map_where_char_on_memdepthmap(c, map):
         raise RuntimeError("No score map allocated for "
                            "zero_score_map_where_char_on_memdepthmap().")
コード例 #9
0
ファイル: ai.py プロジェクト: plomlompom/plomrogue
 def set_cells_passable_on_memmap_to_65534_on_scoremap():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # memmap = t["T_MEMMAP"]
     # for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
     #            if memmap[i] in symbols_passable]:
     #     set_map_score(i, 65534) # i.e. 65535-1
     scoremap = c_pointer_to_bytearray(t["T_MEMMAP"])
     passable_string = c_pointer_to_string(symbols_passable)
     if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(
             scoremap, passable_string):
         raise RuntimeError("No score map allocated for set_cells_passable"
                            "_on_memmap_to_65534_on_scoremap().")
コード例 #10
0
ファイル: ai.py プロジェクト: plomlompom/plomrogue
 def set_cells_passable_on_memmap_to_65534_on_scoremap():
     # OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
     # memmap = t["T_MEMMAP"]
     # for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
     #            if memmap[i] in symbols_passable]:
     #     set_map_score(i, 65534) # i.e. 65535-1
     scoremap = c_pointer_to_bytearray(t["T_MEMMAP"])
     passable_string = c_pointer_to_string(symbols_passable)
     if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(scoremap,
                 passable_string):
         raise RuntimeError("No score map allocated for set_cells_passable"
                            "_on_memmap_to_65534_on_scoremap().")