PCG | Procedural Terrain Generation - Internship and Final Degree | Generator Utils library
kandi X-RAY | PCG Summary
kandi X-RAY | PCG Summary
Procedural Terrain Generation - Internship and Final Degree Project
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PCG
PCG Key Features
PCG Examples and Code Snippets
Community Discussions
Trending Discussions on PCG
QUESTION
I need to read this XML file - extract below...
...ANSWER
Answered 2021-May-20 at 09:04I wrote some code for you.
The code load the XML file you showed (By the way there are two backslashes where slashes should be) into a list of pins (Class TPins). Each pin is represented by a TPin class which contains the pin data, including two lists for pin number by package and pin alias (TPinNumbers list of TPinNumber and TPinAliases list of TPinAlias).
I made a method to load the XML file. Use is simple:
QUESTION
I'm working on an algorithm (procedural racetrack generator) whose outcome, in the general case, is solely based on the RNG outputs. But in some specific scenarios, I need to provide to user the ability to bypass some generation steps (e.g. terrain conformation) without affecting the rest of the generation process.
Let me make a simple practical example:
...ANSWER
Answered 2021-May-14 at 15:31This comes down to assigning a separate PRNG for each of your four (or more) stages of generation (in your example, track shape generation, terrain generation, surface generation, and asset picking), and assigning a seed to each one of them. (In your case, one way this can work is to form a hash of the racetrack ID, an ID for each generation stage, and a fixed bitstring, and use that hash as the seed for each PRNG.)
In general, however, your choice of seed may matter, in practice if not in theory.
For example, there are many PRNGs for which a given seeding strategy will produce correlated pseudorandom number sequences. For example, in most versions of PCG, two sequences generated from seeds that differ only in their high bits will be highly correlated ("Subsequences from the same generator").
To reduce the risk of correlated pseudorandom numbers, you can use PRNG algorithms, such as SFC and other so-called "counter-based" PRNGs (Salmon et al., "Parallel Random Numbers: As Easy as 1, 2, 3", 2011), that support independent "streams" of pseudorandom numbers by giving each seed its own independent sequence of pseudorandom numbers. (Note, however, that PCG has a flawed notion of "streams".) There are other strategies as well, and I explain more about this in "Seeding Multiple Processes".
See also:
QUESTION
I have a windows 7 laptop (Sony pcg 81113M) with 3 USB ports, When I connect 2 * Ft 4222HQ and I run the "Getting start code for the Ft4222" (C++ Qtcreator) I get a wrong USB location which is 0x00. The same when I connect only one in that specific 2 ports.
I am verifying the USB-location of connected FTDI using the software USBview.
I am using "connect by location" in my program and if I connect two at the same time It will conseder it as one device (cause the Location Id is the same)
The FTDI driver is the latest version and i see all the interfaces in my device manager
Note: the third USB port works normally and I get a correct Location Id:
The os is a win7 64bit, the FTDI code runs on the 32bit (I also get the same result with 64bit)
Do anyone has an Idea about that? is there some other test that I can do it to figure it out the problem?
Here is Getting started FTDI code:
[source] https://www.ftdichip.com/Support/SoftwareExamples/LibFT4222-v1.4.4.zip
...ANSWER
Answered 2021-Mar-21 at 18:39From https://ftdichip.com/wp-content/uploads/2020/08/TN_152_USB_3.0_Compatibility_Issues_Explained.pdf Section 2.1.2 Location ID Returned As 0
LocationIDs are not strictly part of the USB spec in the format provided by FTDI. The feature was added as an additional option to back up identifying and opening ports by index, serial number or product description strings.
When connected to a USB 2.0 port the location is provided on the basis of the USB port that the device is connected to. These values are derived from specific registry keys. As the registry tree for 3rd party USB 3.0 host drivers is different to the Microsoft generic driver the Location ID cannot be calculated.
There is no workaround to this current issue and as such devices should be listed and opened by index, serial number or product description strings.
So this is known behaviour. Btw Win 7 EOL date was january 2020. Changing the OS is strongly adviced.
QUESTION
I have been trying different sparse solvers available in Python 3 and comparing the performance between them and also against Octave and Matlab. I have chosen both direct and iterative approaches, I will explain this more in detail below.
To generate a proper sparse matrix, with a banded structure, a Poisson's problem is solved using finite elements with squared grids of N=250, N=500 and N=1000. This results in dimensions of a matrix A=N^2xN^2 and a vector b=N^2x1, i.e., the largest NxN is a million. If one is interested in replicating my results, I have uploaded the matrices A and the vectors b in the following link (it will expire en 30 days) Get systems used here. The matrices are stored in triplets I,J,V, i.e. the first two columns are the indices for the rows and columns, respectively, and the third column are the values corresponding to such indices. Observe that there are some values in V, which are nearly zero, are left on purpose. Still, the banded structure is preserved after a "spy" matrix command in both Matlab and Python.
For comparison, I have used the following solvers:
Matlab and Octave, direct solver: The canonical x=A\b
.
Matlab and Octave, pcg solver: The preconditioned conjugated gradient, pcg solver pcg(A,b,1e-5,size(b,1))
(not preconditioner is used).
Scipy (Python), direct solver: linalg.spsolve(A, b)
where A is previously formatted in csr_matrix
format.
Scipy (Python), pcg solver: sp.linalg.cg(A, b, x0=None, tol=1e-05)
Scipy (Python), UMFPACK solver: spsolve(A, b)
using from scikits.umfpack import spsolve
. This solver is apparently available (only?) under Linux, since it make use of the libsuitesparse [Timothy Davis, Texas A&M]. In ubuntu, this has to first be installed as sudo apt-get install libsuitesparse-dev
.
Furthermore, the aforementioned python solvers are tested in:
- Windows.
- Linux.
- Mac OS.
Conditions:
- Timing is done right before and after the solution of the systems. I.e., the overhead for reading the matrices is not considered.
- Timing is done ten times for each system and an average and a standard deviation is computed.
Hardware:
- Windows and Linux: Dell intel (R) Core(TM) i7-8850H CPU @2.6GHz 2.59GHz, 32 Gb RAM DDR4.
- Mac OS: Macbook Pro retina mid 2014 intel (R) quad-core(TM) i7 2.2GHz 16 Gb Ram DDR3.
Observations:
- Matlab A\b is the fastest despite being in an older computer.
- There are notable differences between Linux and Windows versions. See for instance the direct solver at NxN=1e6. This is despite Linux is running under windows (WSL).
- One can have a huge scatter in Scipy solvers. This is, if the same solution is run several times, one of the times can just increase more than twice.
- The fastest option in python can be nearly four times slower than the Matlab running in a more limited hardware. Really?
If you want to reproduce the tests, I leave here very simple scripts. For matlab/octave:
...ANSWER
Answered 2020-Oct-20 at 12:56I will try to answer to myself. To provide an answer, I tried an even more demanding example, with a matrix of size of (N,N) of about half a million by half a million and the corresponding vector (N,1). This, however, is much less sparse (more dense) than the one provided in the question. This matrix stored in ascii is of about 1.7 Gb, compared to the one of the example, which is of about 0.25 Gb (despite its "size" is larger). See its shape here,
Then, I tried to solve Ax=b using again Matlab, Octave and Python using the aforementioned the direct solvers from scipy, the intel MKL wrapper, the UMFPACK from Tim Davis.
My first surprise is that both Matlab and Octave could solve the systems using the A\b, which is not for certain that it is a direct solver, since it chooses the best solver based on the characteristics of the matrix, see Matlab's x=A\b. However, the python's linalg.spsolve
, the MKL wrapper and the UMFPACK were throwing out-of-memory errors in Windows and Linux. In mac, the linalg.spsolve
was somehow computing a solution, and alghouth it was with a very poor performance, it never through memory errors. I wonder if the memory is handled differently depending on the OS. To me, it seems that mac swapped memory to the hard drive rather than using it from the RAM. The performance of the CG solver in Python was rather poor, compared to the matlab. However, to improve the performance in the CG solver in python, one can get a huge improvement in performance if A=0.5(A+A') is computed first (if one obviously, have a symmetric system). Using a preconditioner in Python did not help. I tried using the sp.linalg.spilu
method together with sp.linalg.LinearOperator
to compute a preconditioner, but the performance was rather poor. In matlab, one can use the incomplete Cholesky decomposition.
For the out-of-memory problem the solution was to use an LU decomposition and solve two nested systems, such as Ax=b, A=LL', y=L\b and x=y\L'.
I put here the min. solution times,
QUESTION
This is my first R script ever. It's working to pull in stock quote data for some specific ticker symbols. Since data is only available for week days I don't have continuous dates in my output. How can I add Saturday and Sunday to my data and fill in the nulls with data from the prior friday?
...ANSWER
Answered 2020-Aug-19 at 03:49You can use complete
to create dates which are missing and fill
to fill the NA
values from previous non-NA value for each ticker
.
QUESTION
Heres my code
...ANSWER
Answered 2020-Jul-22 at 05:51What about something like this?
QUESTION
I have a linear system with a 60000x60000 matrix that I wish to solve, with about 6,000,000 nonzero entries in it.
My current approach is to reorder the matrix with reverse cuthill mckee, factorize the matrix, and then solve it with preconditioned conjugate gradient, but I'm not getting very good results and I don't understand why. The reordering looks reasonable.
Below I have attached a simple example where I only use a subsystem of the matrix I'm trying to solve.
...ANSWER
Answered 2020-May-04 at 11:49There is a high chance that you are doing nothing wrong within your current approach (at least, I was not able to spot an obvious bug).
A couple of notes:
- Residual of
29.10655954230801
and2.5236861383747353
after 500 iterations are effectively the same: your iterative solution has not converged. - You seem to request a very high iterative solver tolerance of
1E-12
. That would not matter here, as you have a problem that does not converge at all. - Factorization (of ILU) should take approximately this time. I am not surprised to see this number for such a system. Not so familiar with this implementation of Cuthill-McKee.
Without knowing where your system comes from, it would be very hard to say anything. However:
- Check the condition number for your small version of the matrix (if it is somewhat representative of your original problem). High condition number would indicate a problem with the conditioning of the matrix; thus, potential poor convergence or ill-convergence of the iterative solution (or any type of solution in the extreme case).
- Conjugate gradient is intended for systems that are symmetric and positive-definite. It can converge for other cases; however, it can fail for well-conditioned problems that are not positive-definite.
QUESTION
I am trying to digest the following post https://www.pcg-random.org/posts/bounded-rands.html on non biased, efficient random number generation.
Here is an excerpt describing the classical, modulo approach.
...ANSWER
Answered 2020-Apr-09 at 01:21Let's start small. Say we have a method rng()
that generates any random integer in [0, 128). If we map all of its 128 outcomes as follows (where X is one of these outcomes):
QUESTION
I believe I found a bug in GCC while implementing O'Neill's PCG PRNG. (Initial code on Godbolt's Compiler Explorer)
After multiplying oldstate
by MULTIPLIER
, (result stored in rdi), GCC doesn't add that result to INCREMENT
, movabs'ing INCREMENT
to rdx instead, which then gets used as the return value of rand32_ret.state
A minimum reproducible example (Compiler Explorer):
...ANSWER
Answered 2020-Jan-23 at 05:09Does this code contain any undefined behaviour that would allow GCC to emit the "incorrect" assembly?
The behavior of the code presented in the question is well defined with respect to the C99 and later C language standards. In particular, C permits functions to return structure values without restriction.
QUESTION
I would like to parse an optional argument with multiple values with docopt
. Below is the example usage.
ANSWER
Answered 2019-Oct-10 at 19:16One approach would be to use the elipsis (...) operator, so that an option can be repeated zero or more times with square brackets, or one or more times with parenthesis . For example
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PCG
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page