Jump to content
  • Advertisement
Sign in to follow this  
CryoGenesis

Help With Assigning Actions With Script Parser (JAVA)

This topic is 2522 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

Hello, I'm working on a project this year and at the moment I have my ideas and just starting to think of ways to get this game to run.
I'm too lazy to rewrite what I'm working on but here's the post where I wrote the idea.
http://www.gamedev.net/topic/618691-little-project-idea-of-mine-wanting-some-feedback/

Anyway, so my main idea (programming wise) for this project is that every cell is assigned a script. In this script would be its attributes and how it would interact with other cells and the environment. for instance in one cells script it says how it only travels in groups of 3 and no more.

Now here is the problem. I've written a script runner in Java. The program opens a script using a path to the file. It reads the first line which states how many lines are in the script. Lets say there are 2 lines in this script. the script runner would start a for loop for how many lines are in the script. each line is cut into individual words erasing spaces. The words are then sent to the decoder which runs the script.
How would I Assign a script for a cell?
I was thinking it could be like this:
one 'running' script (that the cell does real-time like chopping wood)
and one 'init' script (would define how a cell reacts with other cells)

How would I run the Running script for multiple cells without the game becoming incredibly slow?
Surely there must be an easy way?
Does anyone know of any links that could help?

other info:
The reason I'm going to use scripts is so the player can write a separate script apart from the default script and run their own cell behaviour instead of the default cell behaviour.
Its not just cells that are assigned scripts it will be environment objects like trees or crops.
One of the main reasons I'm doing the project is just something Interesting and unique I can dump in my portfolio.

I'm at early stages of thinking right now so if you have any different ways that are efficient and helpful to both me and the game itself please say :)

Thanks very much.
Gen.

Share this post


Link to post
Share on other sites
Advertisement

Surely there must be an easy way?


I'm not sure why you'd think this. "I need to do X every so often" times "I want N objects" is one of the more obvious design smells for scalability issues.

The common solution is to cut down the 'every so often' so that your scripts aren't really running constantly, they're updating some state infrequently.

Other obvious benefits might lie in your script management depending on how you're doing that sort of decode work.

Share this post


Link to post
Share on other sites

How would I run the Running script for multiple cells without the game becoming incredibly slow?

What makes you think running scripts will be slow? I'd advise against any premature optimisation.
For example, I've had scripts running on ~10k objects in a matter of milliseconds, this is particularly achievable if you compile scripts to bytecode where they stand a chance of being further JIT'd into machine code.

Share this post


Link to post
Share on other sites
If you've using Java, why don't you use Jython? You can write the objects you need in Python and create them in Java. I'm not sure if that generates bytecode or if it processes the scripts everytime thought.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!