Showcase
Showcase your work that you have created in the Skyline Game Engine.

experiments with AI

experiments with AI

Postby ant0N » 16 Mar 2015, 18:13

it came to artificial intelligence! :) Two days of trying to create a simple and extensible AI and I think I did it!
I will post in this thread my progress.

:D this is only the beginning.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: experiments with AI

Postby SolarPortal » 16 Mar 2015, 18:27

nice one antON :) It seems you have got the navmesh under control.
I am looking forward to seeing where this leads.

the dofile looks like it is going to have a problem if you pass it to another user as it is hard coded.
i will have a look into this now and get back to you as i am sure there is a way of making it relative.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: experiments with AI

Postby ant0N » 16 Mar 2015, 18:32

Thank you!
Yes, dofile() I could not get it to work otherwise..
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: experiments with AI

Postby StarFire » 16 Mar 2015, 20:32

Cool mini matrix!, looking forward to seeing this develop. Keep up the great work :D
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: experiments with AI

Postby SolarPortal » 16 Mar 2015, 20:51

ok, i have a bit of information for you regarding the dofile() method.

The script is relative to the exe applications directory.
For the "Skyline Editor.exe", this means the base directory is "Win32_Release" folder. If the script is in there,
then you can use this:
Code: Select all
dofile("Base.lua");


But this is not a good place to put scripts lol. So to get to the asset library, you need to use:
Code: Select all
dofile("../../Asset Library/Scripts/Base.lua");


But this is not a good method either because of the end game which could be packaged meaning no hard drive file paths and the lua file would have to be streamed into memory for use creating an unknown bug to solve atm.

The other option is no archiving in the end game, but even that has a different folder path:
Code: Select all
dofile("Assets/Scripts/Base.lua");


This is a challenge to get around lol :P

Edit: What i might do, is create my own c++ version that does the same thing as dofile() command and if loading from a stream, then use dostring instead. Could be interesting and will keep you informed. :)

Edit 2: I have now made a new skyline command, instead of calling dofile. We now use:
Code: Select all
sky.include("myscript.lua")

That's all that's needed and it will work in the end game and in the editor/player.
It finds the file based on the editor resources. So make sure to add the file to the list before calling.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: experiments with AI

Postby Shando » 17 Mar 2015, 01:44

Hi ant0N,

Looks like we are working on the same thing :D

I've just (almost) finished some AI Behaviours ( Seek, Flee, Evade, Pursue, Arrive & Follow ), which I'm testing and tweaking. My version does NOT use any of the NavMesh, but solely relies on Vectors etc. (based on the famous work by Craig Reynolds http://www.red3d.com/cwr/ and the AI in another engine). Though I'm sure adding in the NavMesh wouldn't be too tricky :?:

I'll pm you my script as it is now so you can take a look ( it's not commented, so might be a bit tricky to understand in places :oops: ).

One question....... Does the "doFile" work in the same way as "requires"? From what I've read, doFile runs the entire called file in one go, and requires includes the called file (similar to C++), which allows you to call individual functions from it.

Keep up the great work!!!

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: experiments with AI

Postby TattieBoJangle » 17 Mar 2015, 01:57

Seek, Flee, Evade, Pursue, Arrive & Follow


:D Now they would be great to have in skyline.
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Re: experiments with AI

Postby SolarPortal » 17 Mar 2015, 10:50

its good to see everyone working together and looking forward to that AI shando.

require is like loadFile where it loads the script, but none of it is executed and running in the state. This means you have to pcall to the loaded lua and execute it manually. This doesn't work in skyline as they files need to be running in the actual "Lua_State". This method is used when you need to change or add extra arguments to a lua script which does not need done inside skyline.
Basically, these methods are not used at all unless you execute the scripts manually which is not possible as skyline is running the lua states immediately when play the game is pressed.

This is where doFile() comes in, since you are playing the game and the script you are wanting to load has the functions you need. It needs to be running inside the "Lua_State" the same as the script it is called into in order to access variables or functions.

Another way of thinking of this is; that it just adds the contents of the lua script you are including into the script you need to reference, so the functions/variables are directly accessible.

The new "sky.include()" is a c++ implementation of the dofile() and dostring() approach, where you only need to pass a single filename and it will be located between editor, game and player.

In our function for the end game, we get the contents of the lua script from the loaded resources from an archive as a string from a stream and use the dostring() function instead of dofile() which is used in the editor and player. This has created compatibility right across skyline. So in the next version of skyline, this is the function you will want to use instead of dofile, loadfile, require etc...
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: experiments with AI

Postby SolarPortal » 17 Mar 2015, 15:42

not that this function works in end game, but i think to get loadfile to work, you need to use it like:

Code: Select all
f= loadfile("mylua.lua");
f();


i think the same with require aswell. They are cached resources that are not called immediately, but must be called manually.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: experiments with AI

Postby ant0N » 17 Mar 2015, 16:09

it is planned in the next release? :)
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: experiments with AI

Postby SolarPortal » 17 Mar 2015, 16:29

the "sky.include()" function which replaces dofile() has been added, tested and will be in the next release, yes :D
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: experiments with AI

Postby Shando » 18 Mar 2015, 00:24

Another way of thinking of this is; that it just adds the contents of the lua script you are including into the script you need to reference, so the functions/variables are directly accessible.


This will really make scripts much more flexible :mrgreen: No more copying the same 1000 lines of code into each microscript!!

I do have one question though..... If multiple microscripts call the same ".lua" file, does each one have it's own copy, or is there only one copy across all microscripts??

the "sky.include()" function which replaces dofile() has been added, tested and will be in the next release, yes :D


As always, fast, friendly, flexible Skyline comes up with the goods 8-)

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: experiments with AI

Postby SolarPortal » 18 Mar 2015, 10:37

yes, each one has its own copy as each entity has its own "Lua_State". The code brought in must exist within the state in order to be called.

Lua files that are brought in through the include cannot have any skyline functions: e.g.
onInit(), onUpdate() as they are not called in that script. But all skyline libraries, e.g. entity, physics, vehicle etc.. can be used.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Showcase

Who is online

Users browsing this forum: No registered users and 2 guests