This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
MIT License | |
Copyright (c) 2017 Tommy Ettinger | |
Based on lz-string4java, which is: | |
Copyright (c) 2016 rufushuang | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RandomUtils | |
{ | |
/** | |
* Generates a state array for use with {@link #randomInt(int[])}; this state array will be random using {@code Math.random()}. | |
* @return a 129-element int array with contents randomized by {@code Math.random()} | |
*/ | |
public static int[] initialState() | |
{ | |
final int[] state = new int[129]; | |
for(int i = 0; i < 129; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package change.this; | |
import com.badlogic.gdx.utils.NumberUtils; | |
public class CurvedRandom | |
{ | |
private long state0, state1; | |
/** | |
* Gets a roughly 96-bit random seed using Math.random(). | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/* | |
A faster drop-in replacement for System.Random with added features for copying and storing state. | |
But why replace System.Random in the first place, you ask? | |
A few reasons. One is discussed here, with the apparent consensus that it won't change: | |
https://connect.microsoft.com/VisualStudio/feedback/details/634761/system-random-serious-bug | |
(The formatting on that page is pretty lousy, so the text is here as well for convenience.) | |
"""While investigating the period of various random number generators, I found a serious bug in | |
Microsoft .NET System.Random implementation. | |
Microsoft Documentation (http://msdn.microsoft.com/en-us/library/system.random.aspx) says that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[ Written by Tommy Ettinger in 2017, based on work by Melissa O'Neill in 2015: | |
PCG-Random, http://www.pcg-random.org/ | |
To the extent possible under law, the author has dedicated all copyright | |
and related and neighboring rights to this software to the public domain | |
worldwide. This software is distributed without any warranty. | |
See <http://creativecommons.org/publicdomain/zero/1.0/>. ]# | |
var x*: uint64 # The state can be seeded with any value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carterza.planet.map.generator.pathfind; | |
import com.badlogic.gdx.ai.pfa.Connection; | |
import com.badlogic.gdx.ai.pfa.Heuristic; | |
/** | |
* Created by zachcarter on 12/20/16. | |
*/ | |
public class TiledElevationDistance<N extends TiledTerrainNode> implements Heuristic<N> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Coord findLowerElevation(Coord currentLocation, GreasedRegion riverBlockages, | |
GreasedRegion heights, GreasedRegion reuse, GreasedRegion temp) { | |
heights.refill(heightData.data, Sand, heightData.data[currentLocation.x][currentLocation.y]) | |
.andNot(riverBlockages); | |
reuse.clear().insert(currentLocation); | |
temp.remake(reuse).fringe(); | |
int searchDistance = 40; | |
for(int d = 1; d < searchDistance; d++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void generateFactionMap(final int factionCount, double controlledFraction) { | |
MultiSpill spreader = new MultiSpill(new short[WIDTH][HEIGHT], Spill.Measurement.MANHATTAN, CommonRNG.getRng()); | |
OrderedMap<Coord, Double> entries = new OrderedMap<>(); | |
char[][] map = new char[WIDTH][HEIGHT]; | |
short[][] regionMap = new short[WIDTH][HEIGHT]; | |
for(int x = 0; x < WIDTH; x++) { | |
for(int y = 0; y < HEIGHT; y++) { | |
if(tiles[x][y].heightValue >= Sand) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mu_120x75 | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~jj~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~jjjTTTTT~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~jjjjjjTTTTTT~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~jjjjjTTTTTTT~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~%H~~~~~~~~~~~~~~jjjjjTTTTTTT~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%~~~~N%%~~~~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets a quasi-random Vector2 between (0f,0f) inclusive and (1f,1f) exclusive, assigning into {@code into} the | |
* {@code index}-th point in the (2, 3) Halton sequence. If index is unique, the Vector2 should be as well for all | |
* but the largest values of index. You might find an advantage in using values for index that start higher than | |
* 20 or so, but you can pass sequential values for index and generally get Vector2s that won't be near each other; | |
* this is not true for all parameters to Halton sequences, but it is true for this one. | |
* @param into the Vector2 to place the result into and return | |
* @param index an int that, if unique, positive, and not too large, will usually result in unique Vector2 values | |
* @return into, modified; usually will have a comfortable distance from Vector2s produced with close index values |