LiveBaster - самодостаточный искусственный интеллект |
to English Продукт Видео Возможные применения Купить Документация Программные интерфейсы Использование в Unity3D Примеры Контакты |
Файл LBCore.cs - пример загрузки и выгрузки ядра LiveBasterusing UnityEngine;using System; using System.Runtime.InteropServices; using System.Collections; public class LBCore : MonoBehaviour { public bool LiveBasterLoad = false; public bool LiveBasterFree = false; [DllImport("LiveBaster64.dll", EntryPoint="LbLoadCore", CallingConvention=CallingConvention.Winapi)] public static extern bool LbLoadCore(); [DllImport("LiveBaster64.dll", EntryPoint="LbFreeCore", CallingConvention=CallingConvention.Winapi)] public static extern bool LbFreeCore(); void Start () { LiveBasterLoad = LbLoadCore(); } ~LBCore() { LiveBasterFree = LbFreeCore(); } void Update () { } } Файл LbSimpleControl.cs - пример использования Базового Компонента (БК) LiveBasterusing UnityEngine;using System; using System.Runtime.InteropServices; using System.Collections; public class LbSimpleControl : MonoBehaviour { enum ControlTypes { SimpleControl, TextControl, EyeControl, EarControl, TouchControl, SpeakerControl }; public const int m_precision = 1000; public Int32 m_parentControlId = 0; public Int32 m_ctrlId = -1; public bool LbDeleteControlTest = false; public Int32 m_kontext = 0; public Int32 m_result = 0; public Int32 m_desiredResult = 0; public Int32 m_action = 0; public Int32 m_prevAction = 0; public LbSimpleControl[] m_sensors; // список подключенных сенсоров public float m_min = -150; public float m_max = 150; public float m_devMin = 3; public float m_devMax = 3; public bool m_reverse = false; [DllImport("LiveBaster64.dll", EntryPoint="LbAddControl", CallingConvention=CallingConvention.Winapi)] public static extern Int32 LbAddControl( Int32 controlType ); [DllImport("LiveBaster64.dll", EntryPoint="LbDeleteControl", CallingConvention=CallingConvention.Winapi)] public static extern bool LbDeleteControl( Int32 controlId ); [DllImport("LiveBaster64.dll", EntryPoint="LbMakeAction", CallingConvention=CallingConvention.Winapi)] public static extern Int32 LbMakeAction( Int32 parentControlId, Int32 controlId, Int32 inDesiredResult, Int32 inResult, Int32 inKontext ); [DllImport("LiveBaster64.dll", EntryPoint="LbSetActionMinMax", CallingConvention=CallingConvention.Winapi)] public static extern bool LbSetActionMinMax( Int32 controlId, Int32 actionMin, Int32 actionMax ); [DllImport("LiveBaster64.dll", EntryPoint="LbSetDeviationMinMax", CallingConvention=CallingConvention.Winapi)] public static extern bool LbSetDeviationMinMax( Int32 controlId, Int32 deviationMin, Int32 deviationMax ); [DllImport("LiveBaster64.dll", EntryPoint="LbAddIntegrator", CallingConvention=CallingConvention.Winapi)] public static extern bool LbAddIntegrator( Int32 controlId, Int32 sensorControlId, Int32 action ); [DllImport("LiveBaster64.dll", EntryPoint="LbIntegrator", CallingConvention=CallingConvention.Winapi)] public static extern Int32 LbIntegrator( Int32 controlId ); [DllImport("LiveBaster64.dll", EntryPoint="LbAddGroupTargets", CallingConvention=CallingConvention.Winapi)] public static extern Int32 LbAddGroupTargets(); [DllImport("LiveBaster64.dll", EntryPoint="LbAddTarget", CallingConvention=CallingConvention.Winapi)] public static extern bool LbAddTarget( Int32 controlId, Int32 groupId, Int32 inDesiredResult ); [DllImport("LiveBaster64.dll", EntryPoint="LbGetDesiredResult", CallingConvention=CallingConvention.Winapi)] public static extern Int32 LbGetDesiredResult( Int32 controlId, Int32 groupId ); [DllImport("LiveBaster64.dll", EntryPoint="LbDesiredResultIsAchieved", CallingConvention=CallingConvention.Winapi)] public static extern bool LbDesiredResultIsAchieved(); ~LbSimpleControl() { LbDeleteControlTest = LbDeleteControl( m_ctrlId ); } public virtual void Start() { m_ctrlId = LbAddControl( (Int32)ControlTypes.SimpleControl ); LbSetActionMinMax( m_ctrlId, (Int32)(m_min*m_precision), (Int32)(m_max*m_precision) ); LbSetDeviationMinMax( m_ctrlId, (Int32)(m_devMin*m_precision), (Int32)(m_devMax*m_precision) ); } public Int32 UpdateAction( Int32 inDesiredResult, Int32 inResult, Int32 inKontext ) { m_desiredResult = inDesiredResult; m_result = inResult; m_kontext = inKontext; m_prevAction = m_action; m_action = LbMakeAction( m_parentControlId, m_ctrlId, inDesiredResult, inResult, m_kontext ); return m_action; } } |