Warcraft3 pseudo random distribution in wesnoth.

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

I've implement the same pseudo random system that is used in warcraft 3 in wesnoth.
If you want to know how it works you can read more about it here: http://www.playdota.com/forums/7993/art ... tribution/
Please note that I've implemented the "Theoretical Probability Constants" and not the ones that are actually in WC3.

What this does is that is tries to spread out the number of hits a unit does so that it's damage per round is more consistent. However it is still quite random so you can't know for sure how the battle will turn out.
Take for example if a unit has a 50% chance to hit something the first strike will have a 0.30210 (30%) chance to hit. If the unit misses that strike the next strike will have a 0.30210 * 2 (60%) chance to hit etc. If the unit hits then the chance will drop down to 30% again.

This system makes sure that a unit can't miss forever. So for the 50% example the unit would have to miss 3 times before it would have >= 100% chance to hit.
However I have found it extremely hard to "charge up" units so you know that they will hit.
I'm not sure if I've implemented this correctly but the units feels more reliable but there is still luck involved. Perhaps it just placebo so I would really like some input on this patch.
This is the first time I've worked with the wesnoth code base so the code is probably not where it should be. And I need to change some names to make this more obvious what it does.
I've created this patch from wesnoth 1.9.13 but I think it should work with other versions.
Attachments
rnd.patch
WC3 PSD in wesnoth
(3.83 KiB) Downloaded 609 times
BritNavFan
Posts: 10
Joined: December 17th, 2011, 8:47 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by BritNavFan »

I just wanted to thank you for posting this. It's a good idea, and would play more "naturally" than the other system for reducing luck. I'm probably not going to use it, because I'd need to install a C compiler on my computer just to play Wesnoth and that's probably more hassle than it's worth. But if I continue to play Wesnoth, it'll be because you posted this.
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

BritNavFan wrote:I just wanted to thank you for posting this. It's a good idea, and would play more "naturally" than the other system for reducing luck. I'm probably not going to use it, because I'd need to install a C compiler on my computer just to play Wesnoth and that's probably more hassle than it's worth. But if I continue to play Wesnoth, it'll be because you posted this.
Thank for your kind words, I'm glad you like the idea :)

I'm on linux so I don't think I can provide windows binaries. However it shouldn't be that hard to download the tools needed to compile it.
But I understand that it might be time consuming and that you don't have time. However if you are on linux it should be really easy to patch and compile it.

I would really like some feedback :(
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

I had a friend patch and compile a windows binary with the patch.
It's compiled in windows 7 with visual studio 10.
This is the first time we have done this so I don't know if there will be any problems with libs and what not.
But you should just be able to replace the wesnoth .exe file with this one.
This is the 1.9.14 version BTW.

Edit: removed .exe download the new one below
Last edited by ZedDB on March 3rd, 2012, 8:06 pm, edited 1 time in total.
User avatar
StevenAus
Posts: 84
Joined: December 18th, 2009, 12:15 am
Location: Perth, Australia
Contact:

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by StevenAus »

I tried it with 1.10.0, but after installing libint3.dll, libiconv2.dll, msvcp100.dll, and msvcr100.dll, it wouldn't run, so there must be some slight differences between the 1.9.14 exe and the 1.10.1 exe. I'll try it with 1.9.14, which should work. But can you make a version for 1.10.0 when you are able? That would be great! :)

EDIT: I tried it with 1.9.14 and I got the same error message:
WesnothPRNGError.jpg
Note, this was with Windows 7 64-bit Pro, with the attachment you provided renamed to "wesnoth.exe" and the above dll files in the wesnoth directory, although named as wesnoth(32-bit).exe I got the same error.

It would be great if you could figure out what is causing the error and provide a working version for wesnoth 1.10.0! :) Thank you for introducing this W3 pseudo random distribution to wesnoth!
My Life Purpose Is To Teach The World To Fish For Life. I AM Steven Russell Lynch Abundance That I AM. Empowerment Is My Name And Fostering Self-Responsibility Is My Game.
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

StevenAus wrote: Note, this was with Windows 7 64-bit Pro, with the attachment you provided renamed to "wesnoth.exe" and the above dll files in the wesnoth directory, although named as wesnoth(32-bit).exe I got the same error.
My friends computer is also running 64bit win 7. But visual studio compiled it to a 32bit binary. So it shouldn't be a problem that you are on 64bit.
StevenAus wrote: It would be great if you could figure out what is causing the error and provide a working version for wesnoth 1.10.0! :) Thank you for introducing this W3 pseudo random distribution to wesnoth!
Yes, we'll have to figure out what is going on here. The guide we found to compile wesnoth on windows didn't seem to be the way it's "meant to be compiled" on windows as it seems like you have to modify where windows looks for .dll files for it to work. I thought it were only for the compile phase. But because you had to get addition .dll files it seems to need it afterwards also.

I'll try to figure this out this week. It might take longer because I have to rely on my friend and his computer.
Thanks for testing and reporting!
Yogibear
Retired Developer
Posts: 1086
Joined: September 16th, 2005, 5:44 am
Location: Hamburg, Germany

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by Yogibear »

Hi ZedDB,

that's pretty cool, actually.

I will try and see if i manage to introduce that into WesnothXP in a pluggable way (that is as another choosable RNG algorithm). In any case, your effort is very much appreciated :) .
Smart persons learn out of their mistakes, wise persons learn out of others mistakes!
User avatar
StevenAus
Posts: 84
Joined: December 18th, 2009, 12:15 am
Location: Perth, Australia
Contact:

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by StevenAus »

Indeed, that is pretty cool.

ZedDB - I found that using the same files in my 32-bit version of Windows 7 Pro gave an error which suggested that the particular dll file versions I downloaded would only work for the 64-bit version of Windows 7.
My Life Purpose Is To Teach The World To Fish For Life. I AM Steven Russell Lynch Abundance That I AM. Empowerment Is My Name And Fostering Self-Responsibility Is My Game.
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

StevenAus wrote:Indeed, that is pretty cool.

ZedDB - I found that using the same files in my 32-bit version of Windows 7 Pro gave an error which suggested that the particular dll file versions I downloaded would only work for the 64-bit version of Windows 7.
Hmm perhaps you can try the .dll files that is in the compile guide: http://wiki.wesnoth.org/CompilingWesnot ... ws_.282.29
We used the MSVC 2010 external stuff.
Yogibear wrote:Hi ZedDB,

that's pretty cool, actually.

I will try and see if i manage to introduce that into WesnothXP in a pluggable way (that is as another choosable RNG algorithm). In any case, your effort is very much appreciated :) .
Thanks! :)
Let me know how it goes.
User avatar
StevenAus
Posts: 84
Joined: December 18th, 2009, 12:15 am
Location: Perth, Australia
Contact:

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by StevenAus »

I take it that the increased chance for each subsequent hit after misses only applies on an individual unit basis? This would fit with not being able to "charge up" units. So I guess each unit until it dies (or more likely until the end of a scenario) has a counter that adjusts the probability of hitting based on base probability and number of times in a row there are missed attacks. Is this right?

I managed to get your edited wesnoth binary running in 1.10 in Windows 7 64-bit Pro, however I had installed VS 2010 and its redistributables, and I still needed the first two library files indicated in my previous post above.
My Life Purpose Is To Teach The World To Fish For Life. I AM Steven Russell Lynch Abundance That I AM. Empowerment Is My Name And Fostering Self-Responsibility Is My Game.
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

StevenAus wrote:I managed to get your edited wesnoth binary running in 1.10 in Windows 7 64-bit Pro, however I had installed VS 2010 and its redistributables, and I still needed the first two library files indicated in my previous post above.
Good to hear that you got it running. :)
StevenAus wrote:I take it that the increased chance for each subsequent hit after misses only applies on an individual unit basis? This would fit with not being able to "charge up" units. So I guess each unit until it dies (or more likely until the end of a scenario) has a counter that adjusts the probability of hitting based on base probability and number of times in a row there are missed attacks. Is this right?
Yes, all units saves how many times they have missed and their chance to hit is calculated with that number.

You can still "charge up" units. If you count the number of misses they have you can know for certain when they will hit. But because of the different terrain and how the combat system works with counter attacks I have a hard time keeping my units charged up so I can "nuke" a single unit.

In the multiplayer games I've played with this patch I feel less frustrated because units feel more reliable. But you still get surprises because this only limits how many misses a unit can have not how many hits it can make.
So the dwarf berserker can get really nasty (but still is a glass cannon ;) ).

But I really want feedback from more people so I know it's not just me :P
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

Sorry for the delay. We switched from VS to codeblocks with gcc so there should not be any additional .dlls needed besides the ones already in the wesnoth folder.
Report here if this is not the case or if there is any other problem.

Here is the patched .exe of wesnoth 1.10.1
(Edit: removed old .exe file se below)
Last edited by ZedDB on March 3rd, 2012, 10:33 am, edited 2 times in total.
User avatar
StevenAus
Posts: 84
Joined: December 18th, 2009, 12:15 am
Location: Perth, Australia
Contact:

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by StevenAus »

I'm getting:
AppCrash1.jpg
AppCrash2.jpg
Win7 Pro 64-bit, version 1.10.1 of Wesnoth.
My Life Purpose Is To Teach The World To Fish For Life. I AM Steven Russell Lynch Abundance That I AM. Empowerment Is My Name And Fostering Self-Responsibility Is My Game.
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

This might be a problem with codeblock and it's optimization flags. It seems like it chooses the optimal instruction set from the host computer. In this case it was a sandy bridge CPU so every CPU that didn't have the same instruction set will not be able to run the .exe... We tried to make it compile for i386 but it didn't make any difference... :/
Damn it's a PITA to compile stuff and redistribute binaries on windows :P

Anyhow my friend have an intel atom netbook so we compiled it on that and it worked on that and the sandy bridge computer. So I guess anything with the same (or better) instruction set of the atom should be able to run it now.
Let me know if it works better.

Edit: deleted this one also so below
ZedDB
Posts: 18
Joined: December 28th, 2011, 6:19 pm

Re: Warcraft3 pseudo random distribution in wesnoth.

Post by ZedDB »

As I suspected there was a -march=native flag in the codeblocks project files.
Here you have a binary of wesnoth with the rnd patch. It should work on all CPUs that is equal or greater than a Pentium 3.

Edit: see next page for new binary.
Last edited by ZedDB on May 5th, 2012, 11:31 am, edited 1 time in total.
Post Reply