Jump to content
  • Advertisement
Sign in to follow this  
Sander

looking for a scripting engine

This topic is 4439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm building a hearts game for GNOME after I discovered that there are very few hearts games out for Linux. I've come to the point where I'd like to add AI to the game for the computer opponents. My idea is as follows:
  • use a scripting language for the AI so I can change them without recompiling the game
  • let each (named) player be a different, single script which can be loaded dynamically. For example, the user could select to play against Brian (expert), Eric (moderate) and Lisa (easy). each of those three players is a separate script. Adding another AI is as easy as dropping a new file in the /scripts directory
What I (think I) am looking for: A scripting language that
  • is generally available on *nix
  • easily interfaces with C and C++
  • can run the players continually. E.g. I dont want to start a script and have it finish each time an AI needs to play a card. I'd like the AI to remain available in the background, so script writers can use global variables in their scripts that are available the entire game. This can be usefull for AI's that plan tactics across multiple cards being played, or AI's that are "card counters" (keep track of all cards that are played to figure out what cards help by the other players).
Any comments or suggestions would be greatly appreciated :-)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I would definitly suggest Python, I haven't seen a distro of *nix without it yet. Of course there are probably a few lightweight distros that don't have it.

Python interfaces very easily with C and for C++ there is Boost.Python that "enables seamless interoperability between C++ and the Python programming language". Never used it myself but I have faith in Boost ;)

See: http://www.boost.org/libs/python/doc/index.html
and: http://docs.python.org/ext/ext.html

- Lazy Anonymous Coward

Share this post


Link to post
Share on other sites

I don't think this is really speed critical, so you could just skip C++ and write the whole thing in Python.
If you still want to use C++, you could use Lua or Guile.
BTW, you almost certainly don't need to run players continually. For example, if you used Lua, you could just load each script into a separate lua_State and call one or more Lua-side function (e.g. getPlayerMove(gameState)) on each turn for each AI, and you could use as many variables to store information between turns as you want (a lua_State is the state of the Lua VM, and each one keeps track of its functions, variables, etc.).

Share this post


Link to post
Share on other sites
Python will definitely fit the bill. C++ integration is pretty easy, and you can definitely run scripts with arbitrary lifetimes (such as the length of a game) to get the effects you want.

Share this post


Link to post
Share on other sites
Thanks guys. Lua and Guile both seem good candidates. Python looks nice too, but it's probabely better to use that to develop entire applications instead of only the AI scripts. I'm not sure if I'll use Lua or Guile. I always wanted an excuse to learn Scheme, but Lua seems very easy to use. I'll probabely play a bit with both before deciding.

@Barius: You wouldn't think so, but speed is an issue. While the game is simply sitting idle for 99.9% of the time, it does need to react very snappy on user commands, and drawing your own GtkDrawingArea with the Gdk library ain't the fastest of things, especially with SVG cards. Cairo and libsvg-cairo will probabely alleviate this a *lot* but I'd like this to run on current GNOME's as well, not just the bleeding edge development version.

Share this post


Link to post
Share on other sites
AngelScript - fast with c/c++ syntax with easy api, it should compile on *nix.
I used it in two commercial projects (but on windows platform).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!