Changeset 1081 for framspy


Ignore:
Timestamp:
02/17/21 16:59:46 (4 years ago)
Author:
Maciej Komosinski
Message:

Cosmetic

Location:
framspy
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • framspy/FramsticksLib.py

    r1078 r1081  
    1111        You can perform basic operations like mutation, crossover, and evaluation of genotypes.
    1212        This way you can perform evolution controlled by python as well as access and manipulate genotypes.
    13         You can even design and use in evolution your own genetic representation implemented entirely in python.
     13        You can even design and use in evolution your own genetic representation implemented entirely in python,
     14        or access and control the simulation and simulated creatures step by step.
    1415
    1516        You need to provide one or two parameters when you run this class: the path to Framsticks CLI where .dll/.so resides
  • framspy/frams-test.py

    r1078 r1081  
     1import sys
    12import frams
    23
    3 framspath = "" # set to where Framsticks binaries and libraries exist
     4framspath = sys.argv[1] # set to the directory where Framsticks binaries and libraries exist
    45frams.init(framspath, "-Ddata")  # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is
    56
  • framspy/frams.py

    r1078 r1081  
    1212All non-Framsticks Python attributes start with '_' to avoid conflicts with Framsticks attributes.
    1313Framsticks names that are Python reserved words are prefixed with 'x' (currently just Simulator.ximport).
    14 
    1514"""
    1615
     
    2120
    2221class ExtValue(object):
     22        """All Framsticks objects and values are instances of this class."""
     23
    2324        _reInsideParens = re.compile('\((.*)\)')
    2425        _reservedWords = ['import']  # this list is scanned during every attribute access, only add what is really clashing with framsticks properties
     
    247248
    248249
    249 def init(dllpath, *args):
     250def init(lib_path, *args):
    250251        original_dir = os.getcwd()
    251         os.chdir(dllpath)  # because under Windows, frams.dll requires other dll's which reside in the same directory, so we must change current dir for them to be found
    252         global c_api
    253         c_api = ctypes.CDLL('frams_c_api.so' if os.name == 'posix' else 'frams.dll')
     252        os.chdir(lib_path)  # because under Windows, frams.dll requires other dll's which reside in the same directory, so we must change current dir for them to be found while loading the main dll
     253        global c_api  # access global variable
     254        c_api = ctypes.CDLL('frams-objects.so' if os.name == 'posix' else 'frams-objects.dll')
    254255        os.chdir(original_dir)
    255256
Note: See TracChangeset for help on using the changeset viewer.