# HG changeset patch # User Rune Skovbo Johansen # Date 1420133718 -3600 # Thu Jan 01 18:35:18 2015 +0100 # Node ID 4a4e42b70b8511e1e570214b53ea0cd13f294641 # Parent 8e7ca3f67f3ab4b964c2615f9d7c177cd15e70b4 Added and updated licensing information and added read file. diff --git a/Assets/Ent/Ent.cs b/Assets/Ent/Ent.cs --- a/Assets/Ent/Ent.cs +++ b/Assets/Ent/Ent.cs @@ -1,3 +1,13 @@ +/* + * This source code file is in the public domain. + * Permission to use, copy, modify, and distribute this software and its documentation + * for any purpose and without fee is hereby granted, without any conditions or restrictions. + * This software is provided “as is” without express or implied warranty. + * + * Original version of this code can be obtained from + * http://www.fourmilab.ch/random/ + */ + using System; using System.IO; using Ent; diff --git a/Assets/Implementations/MurmurHash.cs b/Assets/Implementations/MurmurHash.cs --- a/Assets/Implementations/MurmurHash.cs +++ b/Assets/Implementations/MurmurHash.cs @@ -1,10 +1,9 @@ /***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * Version: MPL 2.0/GPL 2.0/LGPL 2.1 * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License @@ -25,6 +24,7 @@ * Rune Skovbo Johansen * Removing all SQL dependencies (take byte array instead of SqlBinary). * Adding overload that takes an int array (less code and executes faster). + * Adding methods for obtaining random integers or floats in given ranges. * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/Assets/Implementations/PcgHash.cs b/Assets/Implementations/PcgHash.cs --- a/Assets/Implementations/PcgHash.cs +++ b/Assets/Implementations/PcgHash.cs @@ -1,3 +1,12 @@ +/* + * This source code file is in the public domain. + * Permission to use, copy, modify, and distribute this software and its documentation + * for any purpose and without fee is hereby granted, without any conditions or restrictions. + * This software is provided “as is” without express or implied warranty. + * + * Original code by Rune Skovbo Johansen based on code snippet by Adam Smith. + */ + using System; public static class PcgHash { @@ -25,5 +34,3 @@ return (x << b) ^ (x >> (32-b)); // broken rotate because I'm in java and lazy } } - - diff --git a/Assets/Testing/Extensions.cs b/Assets/Testing/Extensions.cs --- a/Assets/Testing/Extensions.cs +++ b/Assets/Testing/Extensions.cs @@ -1,17 +1,26 @@ -using System; +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The Initial Developer of the Original Code is Rune Skovbo Johansen. + * Portions created by the Initial Developer are Copyright (C) 2015 + * the Initial Developer. All Rights Reserved. + */ + +using System; public static class Extensions { public static string Ordinal (this int num) { if (num < 0) return num.ToString(); - + switch (num % 100) { case 11: case 12: case 13: return num + "th"; } - + switch (num % 10) { case 1: return num + "st"; diff --git a/Assets/Testing/RandomHashTest.cs b/Assets/Testing/RandomHashTest.cs --- a/Assets/Testing/RandomHashTest.cs +++ b/Assets/Testing/RandomHashTest.cs @@ -1,3 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The Initial Developer of the Original Code is Rune Skovbo Johansen. + * Portions created by the Initial Developer are Copyright (C) 2015 + * the Initial Developer. All Rights Reserved. + */ + using System; using System.Diagnostics; using System.Collections.Generic; diff --git a/Assets/Testing/RandomHashTester.cs b/Assets/Testing/RandomHashTester.cs --- a/Assets/Testing/RandomHashTester.cs +++ b/Assets/Testing/RandomHashTester.cs @@ -1,3 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The Initial Developer of the Original Code is Rune Skovbo Johansen. + * Portions created by the Initial Developer are Copyright (C) 2015 + * the Initial Developer. All Rights Reserved. + */ + using System; using System.Collections.Generic; using System.Security.Cryptography; diff --git a/Assets/UnityFrontend/NoiseTestMB.cs b/Assets/UnityFrontend/NoiseTestMB.cs --- a/Assets/UnityFrontend/NoiseTestMB.cs +++ b/Assets/UnityFrontend/NoiseTestMB.cs @@ -1,3 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The Initial Developer of the Original Code is Rune Skovbo Johansen. + * Portions created by the Initial Developer are Copyright (C) 2015 + * the Initial Developer. All Rights Reserved. + */ + using UnityEngine; using System.Collections; using System.Collections.Generic; diff --git a/readme.md b/readme.md new file mode 100644 --- /dev/null +++ b/readme.md @@ -0,0 +1,24 @@ +# Random Numbers Testing + +This repository contains a C# implementation of MurmurHash3 modified to be more suitable for procedural generation, as well as C# code for a random numbers testing framework. + +The front-end part of the random numbers testing framework is based on Unity and requires Unity 4.6 or later, while the backend and the MurmurHash3 implementations have no dependencies on Unity. + +## MurmurHash3 implementation + +MurmurHash3 is a random hash function with very good randomness properties and good performance. The implementation in this repository has been modified to be more suitable for procedural generation: + +* Adding overload that takes an int array (less code and executes faster). +* Adding methods for obtaining random integers or floats in given ranges. + +## Random numbers testing framework + +The contained random numbers testing framework can be used to assess the quality of randomness for random number generators and random hash functions. + +The framework is divided into a frontend part which runs on top of the Unity engine (version 4.6 or later) and a backend part which does not rely on the Unity editor or API. + +## License + +Most files in the repository are licensed under the Mozilla Public License, v. 2.0. A few files are in the public domain and thus have no restrictions on their use. See the individual files for details. + +A copy of the MPL can be obtained at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/).