Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: Pause/Resume execution in method on: 2012-08-25 17:03:16
Interesting. Are you talking about allowing users to write any Java code (including IO, reflection, and your game's classes) or just a subset of the platform?

At the moment, yes, but eventually I'll be putting in a security manager to minimize a players ability to cheat. I really want to give the player as much freedom as possible for the type of programs they can run, which is why I'm going to need a way to deal with the decision loop running for too long. But things might get a little nuts if access to reflection methods and game classes was allowed. Of course if I do wind up using a scripting language instead I won't have to worry about that, but I kind of like when games let the players cheat and completely break the game if they are clever enough, so at the very least I'm going to put in a way to disable or reduce the security, maybe as an unlockable.
2  Game Development / Game Mechanics / Re: Pause/Resume execution in method on: 2012-08-24 13:24:41
Thanks Roquen and Riven, I'll look into both of those.

I wasn't planning on giving every entity its own thread, I just need a way to give each a restricted and roughly equal amount of computing per tick, and bytecode instrumentation seems a little too complicated if I can just use threads. I've used Akka some, so I imagine I can implement it in that but it seems like it'll have a lot of overhead and add a level of complexity I'm not sure I need. It would be pretty easy to give action points for what an entity does, but what I'm worried about is it spending a long time computing and holding up the game for everyone else. I'll give just doing a cost estimate with static analysis for each entity's decision loop a try though.
3  Game Development / Game Mechanics / Pause/Resume execution in method on: 2012-08-24 02:46:00
I'm making a programming game where the player can program their allies' behavior. The player writes the body of the decide() function for a given ally, which can be filled out with any java code but has to return an action. I would like to give each ally a set, restricted amount of computation per tick so 1) adding more entities doesn't slow down the game too much, and 2) The time an entity spends computing is reflected in game, so if an ally spends more time "thinking" it will act less often. My inspiration for how this should work is Battlecode, which gives units a set amount of bytecode per turn, then just pauses the computation and makes the programmer deal with noticing when things have changed after it's resumed in the next round of computing.

My question is how I can pause and resume an entity which is executing the decision function in a thread. I understand the 'proper' way to do this is to set a flag telling the thread to pause and have it check occasionally, but since I can't force the player to check for a flag within the decide() function, I'm not sure how to pause the thread. The entities are only looking at a fixed representation of the world and just have to return an enum value, so I don't think they should have locks on anything, but I'm hoping there's a better way to do this than using the deprecated thread pausing methods. I'm open to changing how the player has to write code, but I can't think of a way to do it while still hiding the pause flag checks from the user without making writing the decision loop confusing and onerous. There must be some way to do this, since Battlecode does it, but I'm at a loss searching online for details as to how.
Pages: [1]
nelsongames (12 views)
2018-04-24 18:15:36

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

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

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

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

Solater (63 views)
2018-03-17 05:04:08

nelsongames (110 views)
2018-03-05 17:56:34

Gornova (159 views)
2018-03-02 22:15:33

buddyBro (705 views)
2018-02-28 16:59:18

buddyBro (93 views)
2018-02-28 16:45:17
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!