Latest Posts

Topic: Random Production Site Events

gmyx

Topic Opener
Joined: 2009-06-09, 02:00
Posts: 4
Ranking
Just found this site
Posted at: 2009-06-09, 02:40

Let me explain what I'm trying to do: A production site program that executes certain commands in a randomized order.

Why: I've been trying to build another tribe (called ATM Hybrids). I tried to make a simple but vast economy by basing myself off of the Empire Tribe and incorporating the Barbarians and Atlanteans. I then came to the realization that I game some production sites with too many inputs.

I had two options, reduce inputs and diversify even more my economy or make programs that consume different goods in different stages. This worked fine with 3 inputs consuming 2 goods at once but would not be graceful with more inputs.

After debating with myself I thought why not add some randomness to this. I started looking into the possiblity of adding randomness to the order. Therefore, I've been trying to add a randomness factor to a copy of the SVN. Here is my design so far and then some notes on game issues.

A random block would be defined by random_start and random_end commands. Only 'call' commands are allowed inside the random block. This ensures that some order can be preserved in the randomness.

random_start has no parameters and only serves as a starting identifier of the block

random_end has one parameter: number of repeats of the block.

Now onto potential issues that I've encountered. The first and biggest that I have not fully resolved from a design point of view yet is Network Play via Parallel Simulation. The random seed needs to be the same on all machines. I'm assuming there is a game time token or other sync method that is already in the game that can be used for this purpose.

The other is that the lack of one good may stall the production site even thought other portions can go ahead. This seems fairly easily resolved from a design point of view but I'm not sure yet on the technical side of it. My current thought is to just skip the call that cannot be completed since this can already be done through a conditional return; except it would be an implicit conditional return instead of any explicit conditional return.

So that is my thoughts. Unfortunately, GCC is not my strong point yet (darn .NET) but I am working on that. I'm having fun trying to do this but having a lot of problems. I still need to determine some memory structures that would allow me to do such a block inside the program site code.

At this point, I've got the base structures and game recognizes the random_start and random_end commands but does nothing with them yet.

I would like some thoughts, especially from game devs on what you think about this concept. Is this something that I should continue to pursue or is it outside the 'spirit' of the game?

Sorry for the long first post and thanks for reading.

Guy M.


Top Quote
Dwarik

Joined: 2009-05-11, 17:50
Posts: 42
Ranking
Pry about Widelands
Posted at: 2009-06-09, 03:28

a few quick thoughts

1) - why play hybrids - why not play hybrids

for both of these questions you need to have very good answers. I certainly think there is room for another tribe. However, a tribe with fish breeders, game keepers, no need for a lot of stone, etc etc (all the advantages of each tribe) is not going to work because of game ballance.

2) if you want any cross platform randomness function you probally need to write it youself. you could mimic this fairly easily by taking the sum of the digits of the gametime modulus something, or even just the last digit of the gametime. i'd be happy to discuss some better pseudo random functions if we really needed it, but for now i think either one of those would satisfy most need for randomness

3) what exactly do you want to have randomnized. a farm that would take 1-5 cycles before the wheat was 'ripe' for harvest might be cool. random animations might even be awsome, carriers that at random decided to go on strike would only be annoying.

4) (or 3b) on demand production might trump random production. If site would produce good A or B or C at random, it would pritty much end up calling whichever one was needed.

5) did you look at the way other production programs work. it should give you a good starting point for anything y ou would need for any new kind of program.

6) an implicit conditional return is just an explicit conditional return where you can omit the condition in favor of a default value.

7) working on widelands certainly is in the spirit of the game, keep in mind the issues i raised above. and of course ask yourself would it be fun to play against this instead of with this feature. not saying in favor or against the concept, just trying to get a clearer picture what your ideas are.


Top Quote
Dwarik

Joined: 2009-05-11, 17:50
Posts: 42
Ranking
Pry about Widelands
Posted at: 2009-06-09, 03:30

also did you look at the wiki at some of the background stories of your tribe? having some thoughts about the background often provides a good idea about which areas are the strengths and weaknesses of your tribe, which in turn helps with balance. as well as providing a unique feel & identity to your tribe.


Top Quote
SirVer

Joined: 2009-02-19, 15:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2009-06-09, 09:56

Also keep in mind that randomness is killing competition. I only state as an example Stracraft (which had pretty much no randomess; all units always hit with defined damage) which was and is a big success and Warcraft III (the game following Starcraft) which contains "mild randomness" and is not as beloved as Starcraft because many people quote luck as an important factor. Luck is also one of the big back draw people mention when playing Wesnoth.

So: keep this in mind whenever you add randomness.

Cheers, !SirVer


Top Quote
sigra

Joined: 2009-03-05, 19:02
Posts: 130
Ranking
At home in WL-forums
Location: Orsa
Posted at: 2009-06-09, 10:13

gmyx wrote: A random block would be defined by random_start and random_end commands. Only 'call' commands are allowed inside the random block. This ensures that some order can be preserved in the randomness.

I do not really understand what you are trying to achieve, but If there is a reason to have commands to call a random program, it would probably be best to use the call command and just add more parameters to it:

call=a b c

would call one of a, b, c randomly. Then there is no need to check which commands come between random_start and random_end.

Now onto potential issues that I've encountered. The first and biggest that I have not fully resolved from a design point of view yet is Network Play via Parallel Simulation. The random seed needs to be the same on all machines. I'm assuming there is a game time token or other sync method that is already in the game that can be used for this purpose.

Random numbers are already used in the game logic and it works in network games (and replays). So just use Game::logic_rand and it will work.


Top Quote
gmyx

Topic Opener
Joined: 2009-06-09, 02:00
Posts: 4
Ranking
Just found this site
Posted at: 2009-06-10, 01:41

“1) - why play hybrids - why not play hybrids for both of these questions you need to have very good answers. I certainly think there is room for another tribe. However, a tribe with fish breeders, game keepers, no need for a lot of stone, etc etc (all the advantages of each tribe) is not going to work because of game ballance.”

My hybrids is not just a straight up merge. I've made an attempt at balancing the requirements of the different production sites versus their outputs. I have an OpenDocument Spreadsheet that I could share that outlines my hybrids attempt.

“2) if you want any cross platform randomness function you probally need to write it youself. you could mimic this fairly easily by taking the sum of the digits of the gametime modulus something, or even just the last digit of the gametime. i'd be happy to discuss some better pseudo random functions if we really needed it, but for now i think either one of those would satisfy most need for randomness”

That sounds like what I was thinking of. Something that changes over time but is predictable from a parallel point of view. It only takes a few digits.

“3) what exactly do you want to have randomnized. a farm that would take 1-5 cycles before the wheat was 'ripe' for harvest might be cool. random animations might even be awsome, carriers that at random decided to go on strike would only be annoying.”

Let me explain with a 'gold and stone mine'. It currently has several inputs: Ration, Meal, Fish, Meat, Grapes, Beer, Wine but really a worker would take one food and one drink per cycle. The order that those inputs are consumed could be randomized by creating multiple programs that are called in a random order. Of course this could be used for other purposes such as different cycles for wheat to be produced or different animations.

“4) (or 3b) on demand production might trump random production. If site would produce good A or B or C at random, it would pritty much end up calling whichever one was needed.”

That is one of the constraints to be considered. Why get hung up on a good that the economy does not need? If ATM only 1 of 3 outputs are needed only that one would need to be produced. However, if all 3 need to be produced it would get produced in a randomized way eg: A C B. Under no circumstance should it be something like A C A B or something like that. It would go through all the outputs before stating again. This is all decided by the actual programs that are called.

“5) did you look at the way other production programs work. it should give you a good starting point for anything y ou would need for any new kind of program.”

I did, and in some cases just adding extra step served my purpose. The structure is very flexible in allowing things to happen how you want them.

“6) an implicit conditional return is just an explicit conditional return where you can omit the condition in favor of a default value.”

I'm not clear on this.

“7) working on widelands certainly is in the spirit of the game, keep in mind the issues i raised above. and of course ask yourself would it be fun to play against this instead of with this feature. not saying in favor or against the concept, just trying to get a clearer picture what your ideas are.”

“Also keep in mind that randomness is killing competition. I only state as an example Stracraft (which had pretty much no randomess; all units always hit with defined damage) which was and is a big success and Warcraft III (the game following Starcraft) which contains "mild randomness" and is not as beloved as Starcraft because many people quote luck as an important factor. Luck is also one of the big back draw people mention when playing Wesnoth. So: keep this in mind whenever you add randomness. Cheers, SirVer”

I agree. I've played Wesnoth and it annoyed me sometimes the way it just seems like unit A should not be able to harm let alone kill unit B, but alas it did. I don't think that luck would factor in because it's a not chance that something would happen but rather the order of things will be different every run through the program. At the end of the program the results are the same.

“I do not really understand what you are trying to achieve, but If there is a reason to have commands to call a random program, it would probably be best to use the call command and just add more parameters to it: call=a b c would call one of a, b, c randomly. Then there is no need to check which commands come between random_start and random_end.” That is certainly WAY more elegant than my solution and makes it much simpler to implement!

I hope this clears things up and it certainly gave me some stuff to act on.

Thank you.


Top Quote
sigra

Joined: 2009-03-05, 19:02
Posts: 130
Ranking
At home in WL-forums
Location: Orsa
Posted at: 2009-06-10, 08:00

Dwarik wrote: a farm that would take 1-5 cycles before the wheat was 'ripe' for harvest might be cool.

This already works. The probability that a tree will grow to the next size depends on the terrain types. If it fails to grow, it tries again in the next cycle. It also has a certain probability to die each cycle, so the more cycles it needs to grow, the smaller is the probability that it will survive to full size. This should be used for wheat too. It makes good farmland valuable and the player has to plan where he builds farms.


Top Quote
Nasenbaer
Avatar
Joined: 2009-02-21, 18:17
Posts: 828
Ranking
One Elder of Players
Location: Germany
Posted at: 2009-06-10, 16:47

That is one of the constraints to be considered. Why get hung up on a good that the economy does not need? If ATM only 1 of 3 outputs are needed only that one would need to be produced.

As far as I understand, that's exactly what our on demand production does.

However, if all 3 need to be produced it would get produced in a randomized way eg: A C B. Under no circumstance should it be something like A C A B or something like that. It would go through all the outputs before stating again. This is all decided by the actual programs that are called.

Not my point of view! When the check for A fails it should just check if B should be produced, so the short check for A should not make a big difference. Making lsts like A A B on the other hand is very useful - easiest example is the atlantean smokery: The Atlanteans will have much more fish than meat and so (if both are requested) it should try to produce 66% smoked fish and just 33% smoked meat.

Let me explain with a 'gold and stone mine'. It currently has several inputs: Ration, Meal, Fish, Meat, Grapes, Beer, Wine but really a worker would take one food and one drink per cycle. The order that those inputs are consumed could be randomized by creating multiple programs that are called in a random order. Of course this could be used for other purposes such as different cycles for wheat to be produced or different animations.

Of course possible, but always keep in mind to balance against the other tribes - e.g. imperial players won't be able to choose whether their gold miners drink beer or wine - they'll always take wine - and that's a wanted feature not a bug face-wink.png

Another point for thinking: like you describe it, you could just create two wares "food" and "drink", as the different types are handled the same anyway...

Luck is also one of the big back draw people mention when playing Wesnoth. So: keep this in mind whenever you add randomness.

As far as I know, Widelands current battle engine works with some small randomness as well - and hey I like it face-grin.png


Top Quote
gmyx

Topic Opener
Joined: 2009-06-09, 02:00
Posts: 4
Ranking
Just found this site
Posted at: 2009-06-24, 03:20

“Not my point of view! When the check for A fails it should just check if B should be produced, so the short check for A should not make a big difference. Making lsts like A A B on the other hand is very useful - easiest example is the atlantean smokery: The Atlanteans will have much more fish than meat and so (if both are requested) it should try to produce 66% smoked fish and just 33% smoked meat.”

Yes it does, if smoked fish is required it builds it. Using my concept it's just the order that things are produced that are affected. So Loop 1 could be A A B, Loop 2 could be A B A, etc. Of course, this is an opt-in from a tribe designer's point of view. The number / ratio is determined by the call command. Say you want 5 to 1 ratio a a good, provided that the goods are required they are built.

On that note, I have completed my first attempt at this. I did noticed that call had some trailing parameters so I had to accommodate those as well. I'm not sure what program uses these parameters however.

What is the best way to submit my changes for review? Diff file?

Thank you.


Top Quote
gmyx

Topic Opener
Joined: 2009-06-09, 02:00
Posts: 4
Ranking
Just found this site
Posted at: 2009-10-12, 20:17

gmyx wrote: On that note, I have completed my first attempt at this. I did notice that call had some trailing parameters so I had to accommodate those as well. I'm not sure what program uses these parameters however. What is the best way to submit my changes for review? Diff file? Thank you.

Now that r14 is out and the feature freeze is off, I bump this thread. How do I submit changes for review?

Thank you.

Edited: 2009-10-12, 20:17

Top Quote