Comments (6)
This code is poorly documented, so I'm not really sure. I think the idea of % max-1 is that there are therefore max possible numbers so Next(5) will give five possible results zero through four.
from civ2-clone.
For Next(5):
max-1 gives 0,1,2,3
max gives 0,1,2,3,4
max+1 gives 0,1,2,3,4,5
Not sure which of the last two is the correct one. I think some other methods in the class have similar issues.
Anyway starting a new game it always chooses Romans from [Roman,Celtic,Russian] civs. For other civs it however seems to chose random, as it should. I'll look into it more.
from civ2-clone.
Have you changed the seed? I had the random number generator hard coded to a seed of 1 at one point
from civ2-clone.
For Next(5):
max-1 gives 0,1,2,3
max gives 0,1,2,3,4
max+1 gives 0,1,2,3,4,5Not sure which of the last two is the correct one. I think some other methods in the class have similar issues.
Anyway starting a new game it always chooses Romans from [Roman,Celtic,Russian] civs. For other civs it however seems to chose random, as it should. I'll look into it more.
Looks like the correct behaviour is just max max-1 is definitely wrong
from civ2-clone.
I tried with a couple of different seeds and there's not much improvement.
Two problems when e.g. generating 100 random numbers with Next(2):
- the first generated number always seems to be 0
- there are clusters of zeros and ones
Out of curiosity, why didn't you use the random class that comes with .net?
from civ2-clone.
Interesting. After correcting it to use straight max I get:
1073741823 of the possible 2147483647 seed values generate a 1 the others generate a 0 for Next(2)
That's exactly how you would expect Next(2) to behave, it's almost exactly half.
With Next(2) you will always get clusters of zeros and ones as they are supposed to appear independent (It's a pseudorandom number generator so they are not really independent)
I wrote this one, based on an algorithm I found online, because I wanted something that could be serialized easily into a readable format and could be run across languages. This is from a multiplayer implementation of Colonization I was working on a few years ago that had a interface in Typescript and a server in C#
from civ2-clone.
Related Issues (20)
- Draw city size box
- Saving game HOT 5
- Game crashes when dead civ is chosen for next turn
- Don't update the map every time unit moves HOT 2
- Missing references - Broken code HOT 1
- Some issues with BitmapStorage
- Drawing with different zoom levels
- Search paths don't have the local sav/scn folder HOT 1
- Raylib-cs and .net8 HOT 2
- Feature Request: use Bilinear/Bicubic interpolation scaling on zooming HOT 10
- Unit Actions HOT 4
- What civ can see vs what is there HOT 2
- Game type parameter for TOT
- Improvements in MPG vs TOT HOT 8
- RaylibUI.Mac does not exist HOT 2
- Adjust Menus for TOT HOT 1
- Menu styling HOT 2
- Update dialog tiles when loading game/scenario HOT 3
- Update status panel HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from civ2-clone.