Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Python or other scripting language for simple AI?  (Read 2977 times)
0 Members and 1 Guest are viewing this topic.
Offline DayTripperID

Senior Devvie


Medals: 8
Projects: 1
Exp: 1-3 months


Living is good!


« Posted 2016-07-25 13:24:03 »

Hey folks,

Was wondering if there is a way to invoke python scripts from java for simple AI scripting? I'm not planning on doing any sophisticated AI, just simple stuff.I would like to do it in python to cut down on code.

I want to do something along these lines:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//java code ...
entity.tick(){

     //invoke python script...
     //python script updates entity variables...
}

for (Entity e : entities){
     
     e.tick();
}


I something like this possible, where I can update java class variables from a python script? Or maybe there is another scripting alternative that can accomplish this? Any tips or links to tutorial resources appreciated!
 

Living is good!
Offline nsigma
« Reply #1 - Posted 2016-07-25 16:18:37 »

Check out Jython. There are many scripting alternatives for the JVM, or JavaScript is built in.  You can even live-compile Java.  This is great if you want to let users edit stuff.  However, IMO this will not cut down on code, because you'll be adding loads of boilerplate and a great deal of complexity.  If it's just for you, I'd stick with Java - it isn't that much more verbose.   Wink

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline DayTripperID

Senior Devvie


Medals: 8
Projects: 1
Exp: 1-3 months


Living is good!


« Reply #2 - Posted 2016-07-25 17:37:06 »

I checked out Jython and the setup is not worth the time/complexity. Oh well, I'll stick to java. Thanks for the reply. Smiley

Living is good!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ecumene

JGO Kernel


Medals: 197
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #3 - Posted 2016-07-25 19:23:10 »

I checked out Jython and the setup is not worth the time/complexity. Oh well, I'll stick to java. Thanks for the reply. Smiley

If you're looking for a plugin framework, PF4J is basic and expandable, and most of the other ones (like JPF) are either old, or bloated.

https://github.com/decebals/pf4j

Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #4 - Posted 2016-07-26 18:20:40 »

Using python for this could work, but you should check out Lua. It's great.

I use Luaj 5.2 build. You can inject code into the environment, run entry functions, and call scripts whenever you want. These scripts run on the calling thread, not a new one. It perfectly fits your scenario.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline DayTripperID

Senior Devvie


Medals: 8
Projects: 1
Exp: 1-3 months


Living is good!


« Reply #5 - Posted 2016-08-02 12:18:42 »

Thanks, guys/gals, for the advice. I'll look into those options and see if they're a good fit for me!

Living is good!
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1303 views)
2018-06-10 19:43:48

EgonOlsen (1161 views)
2018-06-10 19:43:44

EgonOlsen (900 views)
2018-06-10 19:43:20

DesertCoockie (1301 views)
2018-05-13 18:23:11

nelsongames (1106 views)
2018-04-24 18:15:36

nelsongames (1337 views)
2018-04-24 18:14:32

ivj94 (2079 views)
2018-03-24 14:47:39

ivj94 (1231 views)
2018-03-24 14:46:31

ivj94 (2213 views)
2018-03-24 14:43:53

Solater (798 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!