revamped everything

This commit is contained in:
Cubitect 2018-03-05 21:20:54 +00:00
parent 79cf661f8b
commit 89674d0317
22 changed files with 113053 additions and 0 deletions

674
LICENSE.txt Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

BIN
LayerSummary.pdf Normal file

Binary file not shown.

58
README.md Normal file
View File

@ -0,0 +1,58 @@
# cubiomes
Cubiomes is a standalone library, written in C, that mimics the Minecraft biome and feature generation.
It is intended as a powerful tool to devise very fast, custom seed finding applications and large scale map viewers.
### Audience
You should be familiar with the C programming language, also a basic understanding of the Minecraft biome generation process would be helpful.
A POSIX environment is required to compile the finders library and examples, but the core generator library may also work on other platforms.
### Documentation
There is a reference document for the generator layers which contains a summary for most generator layers and their function within the generation process.
### Example
There are two example programs in this repository which can be compiled using the makefile provided.
#### Finding Quad-Witch-Huts at a Specific Location
This classic type of finder uses several optimisations reguarding positioning of temples in the world. One of which allows you to specify the exact region (512x512) position about which the quad-hut should generate, without affecting the performance. For example:
`./find_quadhut 0 0`
will start a search with a regional positioning around the origin. (Actually the huts will be positioned in regions (-1,-1) to (0,0) this way.)
To my knowlege, as of the time of writing, this is fastest single-thread quad-hut-finder out there. However, note that the current implementation of the biome finding optimisations causes the finder to miss some seeds (< 2%) in favour for speed.
#### Finding Compact Biome Seeds
This finder searches for seeds that contain all major biome types within 1024 blocks of the origin. These seeds are very rare and it might take a moment for the finder to yield any. The commandline arguments are:
`./find_compactbiomes [starting_seed] [end_seed] [threads]`
### Cool Seeds
If you are looking to get the "Adventuring Time" achievment you might consider one of the following seeds. All of these seeds have all 36 required biomes within less than 700 blocks from the origin (rarity: less than 1 in 100 billion):
| Seed | All biome radius |
|---------------|------------------|
| 1065757415811 | 612 |
| -880424771806 | 644 |
| -9896963610 | 664 |
| -78538250832 | 686 |
| 1251759844332 | 692 |

34
docs/LayerSummary.aux Normal file
View File

@ -0,0 +1,34 @@
\relax
\@writefile{toc}{\contentsline {section}{\numberline {1}Biome Generator Layers}{3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.0}Seed Finding}{3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Layer 1: Island}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Layer 2: Zoom}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}Layer 3: Add Island}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}Layer 4: Zoom}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Layer 5: Add Island}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Layer 6: Add Island}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Layer 7: Add Island}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Layer 8: Remove Too Much Ocean}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.9}Layer 9: Add Snow}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.10}Layer 10: Add Island}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.11}Layer 11: Edge, Cool/Warm}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.12}Layer 12: Edge, Heat/Ice}{7}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.13}Layer 13: Edge, Special}{7}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.14}Layer 14: Zoom}{7}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.15}Layer 15: Zoom}{8}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.16}Layer 16: Add Island}{8}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.17}Layer 17: Add Mushroom Island}{9}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.18}Layer 18: Deep Ocean}{10}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.19}Layer 19: Biome}{10}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.20}Layer 20: Zoom}{12}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.21}Layer 21: Zoom}{12}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.22}Layer 22: Biome Edge}{13}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.23}Layer 23: River Init}{13}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.24}Layer 24: Zoom}{14}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.25}Layer 25: Zoom}{14}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.26}Layer 26: Hills}{14}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.27}Layer 27: Rare Biome}{16}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.28}Layer 31: Shore}{17}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.29}Layer 41: River}{18}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.30}Layer 43: River Mix}{19}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.31}Layer 44: Voronoi Zoom}{21}}

410
docs/LayerSummary.log Normal file
View File

@ -0,0 +1,410 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2017.8.28) 5 MAR 2018 21:14
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**LayerSummary.tex
(./LayerSummary.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
\lst@mode=\count87
\lst@gtempboxa=\box26
\lst@token=\toks15
\lst@length=\count88
\lst@currlwidth=\dimen103
\lst@column=\count89
\lst@pos=\count90
\lst@lostspace=\dimen104
\lst@width=\dimen105
\lst@newlines=\count91
\lst@lineno=\count92
\lst@maxwidth=\dimen106
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2015/06/04 1.6 (Carsten Heinz)
\c@lstnumber=\count93
\lst@skipnumbers=\count94
\lst@framebox=\box27
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.cfg
File: listings.cfg 2015/06/04 1.6 listings configuration
))
Package: listings 2015/06/04 1.6 (Carsten Heinz)
(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2007/01/21 v2.11 LaTeX color extensions (UK)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg
File: color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
)
Package xcolor Info: Driver file: pdftex.def on input line 225.
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
)
\Gread@gobject=\count95
)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1337.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1341.
Package xcolor Info: Model `RGB' extended on input line 1353.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1355.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1356.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1357.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1358.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1359.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1360.
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2016/01/03 v1.0q Standard LaTeX Graphics (DPC,SPQR)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg
File: graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
)
Package graphics Info: Driver file: pdftex.def on input line 95.
)
\Gin@req@height=\dimen107
\Gin@req@width=\dimen108
)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip10
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
)
(/usr/share/texlive/texmf-dist/tex/latex/pdfpages/pdfpages.sty
Package: pdfpages 2015/09/18 v0.5d Insert pages of external PDF documents (AM)
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/tools/calc.sty
Package: calc 2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
\calc@Acount=\count96
\calc@Bcount=\count97
\calc@Adimen=\dimen109
\calc@Bdimen=\dimen110
\calc@Askip=\skip43
\calc@Bskip=\skip44
LaTeX Info: Redefining \setlength on input line 80.
LaTeX Info: Redefining \addtolength on input line 81.
\calc@Ccount=\count98
\calc@Cskip=\skip45
)
(/usr/share/texlive/texmf-dist/tex/latex/eso-pic/eso-pic.sty
Package: eso-pic 2015/07/21 v2.0g eso-pic (RN)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/atbegshi.sty
Package: atbegshi 2011/10/05 v1.16 At begin shipout hook (HO)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO)
Package ifpdf Info: pdfTeX in PDF mode is detected.
)))
\AM@pagewidth=\dimen111
\AM@pageheight=\dimen112
(/usr/share/texlive/texmf-dist/tex/latex/pdfpages/pppdftex.def
File: pppdftex.def 2015/09/18 v0.5d Pdfpages driver for pdfTeX (AM)
)
\AM@pagebox=\box28
\AM@toc@title=\toks16
\c@AM@survey=\count99
\AM@templatesizebox=\box29
)
(/usr/share/texlive/texmf-dist/tex/latex/makecell/makecell.sty
Package: makecell 2009/08/03 V0.1e Managing of Tab Column Heads and Cells
(/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty
Package: array 2014/10/28 v2.4c Tabular extension package (FMi)
\col@sep=\dimen113
\extrarowheight=\dimen114
\NC@list=\toks17
\extratabsurround=\skip46
\backup@length=\skip47
)
\rotheadsize=\dimen115
\c@nlinenum=\count100
\TeXr@lab=\toks18
)
(/usr/share/texlive/texmf-dist/tex/latex/tools/tabularx.sty
Package: tabularx 2014/10/28 v2.10 `tabularx' package (DPC)
\TX@col@width=\dimen116
\TX@old@table=\dimen117
\TX@old@col=\dimen118
\TX@target=\dimen119
\TX@delta=\dimen120
\TX@cols=\count101
\TX@ftn=\toks19
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2016/03/03 v2.15a AMS math features
\@mathmargin=\skip48
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks20
\ex@=\dimen121
))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen122
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 1999/12/14 v2.01 operator names
)
\inf@bad=\count102
LaTeX Info: Redefining \frac on input line 199.
\uproot@=\count103
\leftroot@=\count104
LaTeX Info: Redefining \overline on input line 297.
\classnum@=\count105
\DOTSCASE@=\count106
LaTeX Info: Redefining \ldots on input line 394.
LaTeX Info: Redefining \dots on input line 397.
LaTeX Info: Redefining \cdots on input line 518.
\Mathstrutbox@=\box30
\strutbox@=\box31
\big@size=\dimen123
LaTeX Font Info: Redeclaring font encoding OML on input line 630.
LaTeX Font Info: Redeclaring font encoding OMS on input line 631.
\macc@depth=\count107
\c@MaxMatrixCols=\count108
\dotsspace@=\muskip11
\c@parentequation=\count109
\dspbrk@lvl=\count110
\tag@help=\toks21
\row@=\count111
\column@=\count112
\maxfields@=\count113
\andhelp@=\toks22
\eqnshift@=\dimen124
\alignsep@=\dimen125
\tagshift@=\dimen126
\tagwidth@=\dimen127
\totwidth@=\dimen128
\lineht@=\dimen129
\@envbody=\toks23
\multlinegap=\skip49
\multlinetaggap=\skip50
\mathdisplay@stack=\toks24
LaTeX Info: Redefining \[ on input line 2735.
LaTeX Info: Redefining \] on input line 2736.
)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold'
(Font) U/euf/m/n --> U/euf/b/n on input line 106.
))
(/usr/share/texlive/texmf-dist/tex/latex/multirow/multirow.sty
\bigstrutjot=\dimen130
)
(./LayerSummary.aux)
\openout1 = `LayerSummary.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 18.
LaTeX Font Info: ... okay on input line 18.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 18.
LaTeX Font Info: ... okay on input line 18.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 18.
LaTeX Font Info: ... okay on input line 18.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 18.
LaTeX Font Info: ... okay on input line 18.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 18.
LaTeX Font Info: ... okay on input line 18.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 18.
LaTeX Font Info: ... okay on input line 18.
\c@lstlisting=\count114
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count115
\scratchdimen=\dimen131
\scratchbox=\box32
\nofMPsegments=\count116
\nofMParguments=\count117
\everyMPshowfont=\toks25
\MPscratchCnt=\count118
\MPscratchDim=\dimen132
\MPnumerator=\count119
\makeMPintoPDFobject=\count120
\everyMPtoPDFconversion=\toks26
) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO
)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
Package: epstopdf-base 2010/02/09 v2.5 Base part for package epstopdf
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
Package: grfext 2010/08/19 v1.1 Manage graphics extensions (HO)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO)
))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty
Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
Package etexcmds Info: Could not find \expanded.
(etexcmds) That can mean that you are not using pdfTeX 1.50 or
(etexcmds) that some package has redefined \expanded.
(etexcmds) In the latter case, load this package earlier.
)))
Package grfext Info: Graphics extension search list:
(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext) \AppendGraphicsExtensions on input line 452.
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e
))
\AtBeginShipoutBox=\box33
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/pdflscape.sty
Package: pdflscape 2008/08/11 v0.10 Display of landscape pages in PDF (HO)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/lscape.sty
Package: lscape 2000/10/22 v3.01 Landscape Pages (DPC)
)
Package pdflscape Info: Auto-detected driver: pdftex on input line 80.
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
))
LaTeX Font Info: Try loading font information for U+msa on input line 20.
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info: Try loading font information for U+msb on input line 20.
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
) [1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./LayerSummary.toc)
\tf@toc=\write3
\openout3 = `LayerSummary.toc'.
[2]
<layers.pdf, id=16, 938.50626pt x 2133.9725pt>
File: layers.pdf Graphic file (type pdf)
<use layers.pdf>
Package pdftex.def Info: layers.pdf used on input line 56.
(pdftex.def) Requested size: 938.50397pt x 2133.96732pt.
File: layers.pdf Graphic file (type pdf)
<use layers.pdf>
Package pdftex.def Info: layers.pdf used on input line 56.
(pdftex.def) Requested size: 938.50397pt x 2133.96732pt.
<layers.pdf, id=19, page=1, 938.50626pt x 2133.9725pt>
File: layers.pdf Graphic file (type pdf)
<use layers.pdf, page 1>
Package pdftex.def Info: layers.pdf, page1 used on input line 56.
(pdftex.def) Requested size: 938.50397pt x 2133.96732pt.
File: layers.pdf Graphic file (type pdf)
<use layers.pdf, page 1>
Package pdftex.def Info: layers.pdf, page1 used on input line 56.
(pdftex.def) Requested size: 349.7766pt x 795.3209pt.
[3]
File: layers.pdf Graphic file (type pdf)
<use layers.pdf, page 1>
Package pdftex.def Info: layers.pdf, page1 used on input line 56.
(pdftex.def) Requested size: 349.7766pt x 795.3209pt.
File: layers.pdf Graphic file (type pdf)
<use layers.pdf, page 1>
Package pdftex.def Info: layers.pdf, page1 used on input line 56.
(pdftex.def) Requested size: 349.7766pt x 795.3209pt.
File: layers.pdf Graphic file (type pdf)
<use layers.pdf, page 1>
Package pdftex.def Info: layers.pdf, page1 used on input line 56.
(pdftex.def) Requested size: 349.7766pt x 795.3209pt.
[4 <./layers.pdf>] [5]
[6] [7] [8] [9] [10] [11] [12] [13] [14]
Overfull \hbox (1.60254pt too wide) in paragraph at lines 511--513
\OT1/cmr/m/n/10 birch-ForestHills, cold-TaigaHills, megaTaigaHills and sa-van-n
aPlateau. Also there
[]
[15] [16] [17] [18] [19] [20] [21] [22] (./LayerSummary.aux) )
Here is how much of TeX's memory you used:
5194 strings out of 494953
71369 string characters out of 6180977
148295 words of memory out of 5000000
8381 multiletter control sequences out of 15000+600000
12110 words of font info for 47 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
38i,18n,43p,731b,419s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texli
ve/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/texlive/tex
mf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dis
t/fonts/type1/public/amsfonts/cm/cmbx9.pfb></usr/share/texlive/texmf-dist/fonts
/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1
/public/amsfonts/cm/cmr10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public
/amsfonts/cm/cmr12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfon
ts/cm/cmr17.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/c
mr9.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pf
b>
Output written on LayerSummary.pdf (22 pages, 173371 bytes).
PDF statistics:
122 PDF objects out of 1000 (max. 8388607)
82 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
21 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

766
docs/LayerSummary.tex Normal file
View File

@ -0,0 +1,766 @@
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{url}
\usepackage{pdfpages}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multirow}
\usepackage{array}
\title{Summary of the Biome Generation in \\ Minecraft 1.8 - 1.12}
\author{Cubitect}
\begin{document}
\maketitle
\begin{abstract}
This document is designed to provide an overview of how Minecraft biome generation works and how we may efficiently find seeds with desired properties.
\end{abstract}
\newpage
\tableofcontents
\newpage
\section{Biome Generator Layers}
Minecraft biome generation occurs in layers. Many of these layers are chained together inside the generator, such that the output from one becomes the input for the next. A flowchart of this can be found on the next page.
Each layer applies certain modifications to a map of integers, which change their use throughout the generation process. Initially the map only contains values 0 or 1, representing ocean or land masses. Later in the generator they represent temperature categories, until they are finally replaced by the actual biome IDs.
Some of the layers resize the output of the previous layer. These Zoom-layers therefore change how much area is represented by a map entry. I will refer to this as "scale". For instance, 1:256 should be read as: one map entry ends up as an area of 256x256 blocks in the world.
\setcounter{subsection}{-1}
\subsection{Seed Finding}
When constructing a seed finder, it may be useful to stop the generation at an earlier layer. For example if we require a swamp to be located near a given position, then we might want to generate up to layer 19: Biome first, and then check on a 1:256 scale if there is a swamp in the area. This is not enough to confirm that there will be a swamp at the given position, but we can rule out seeds that definitely don't have a swamp anywhere near the area. If the seed passes this cheap test, then we can go through the full expensive generation process and directly check the position for a swamp.
Usually it is not practical to continue the search from a terminated generation and we have to start over again. The reason for this is that most layers require an additional 1 wide boarder from the previous layer, so the map sizes don't match up.
Another more involved, but very powerful way of creating early knock-out criteria is to check if there is a some condition in the layer chain that is independent of the rest of the biomes. For instance in the case of finding a swamp, we can notice that there is a pseudo-random number check in layer 19: Biome, that converts Lush temperature climates to swamplands. However, the pseudo-random number generator is seeded by a combination of the position and the world seed, so we can make sure the random number output gives the required value without going through the rest of the layers. The more expensive generator can afterwards be used to make sure that a Lush climate is actually present at that position.
In the summary below in sections 1.1 -- 1.44 I have laid out some of the properties of each layer, such as the scale of the layer and the possible values for the map entries with their respective average probability of occurrence (Note: these are estimates and may vary). When constructing a seed finder these values can be used as a reference to determine reasonable cut-off points for the generator.
\includepdf[pages={1}]{layers.pdf}
\subsection{Layer 1: Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:4096} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 90.0\%\\\hline
1 & Land & 10.0\%\\\hline
\end{tabular}
\subsection{Layer 2: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:2048} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 90.0\%\\\hline
1 & Land & 10.0\%\\\hline
\end{tabular}
\subsection{Layer 3: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:2048} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 84.3\%\\\hline
1 & Land & 15.7\%\\\hline
\end{tabular}
\subsection{Layer 4: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 84.9\%\\\hline
1 & Land & 15.1\%\\\hline
\end{tabular}
\subsection{Layer 5: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 81.4\%\\\hline
1 & Land & 18.6\%\\\hline
\end{tabular}
\subsection{Layer 6: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 77.5\%\\\hline
1 & Land & 22.5\%\\\hline
\end{tabular}
\subsection{Layer 7: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 73.4\%\\\hline
1 & Land & 26.6\%\\\hline
\end{tabular}
\subsection{Layer 8: Remove Too Much Ocean}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 49.4\%\\\hline
1 & Land & 50.6\%\\\hline
\end{tabular}
\subsection{Layer 9: Add Snow}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 49.4\%\\\hline
1 & Warm & 33.7\%\\\hline
3 & Cold & 4.8\%\\\hline
4 & Freezing & 12.4\%\\\hline
\end{tabular}
\medskip\noindent
Changes some of the land starting points to Cold and Freezing.
\subsection{Layer 10: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 33.8\%\\\hline
1 & Warm & 37.6\%\\\hline
3 & Cold & 4.8\%\\\hline
4 & Freeing & 23.9\%\\\hline
\end{tabular}
\medskip\noindent
Spreads out the continental areas, decreasing the amount of ocean.
\subsection{Layer 11: Edge, Cool/Warm}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 33.8\%\\\hline
1 & Warm & 13.6\%\\\hline
2 & Lush & 23.9\%\\\hline
3 & Cold & 4.8\%\\\hline
4 & Freezing & 23.9\%\\\hline
\end{tabular}
\medskip\noindent
Changes Warm(1) lands which are adjacent to Cold(3) or Freezing(4) temperatures to Lush(2).
\subsection{Layer 12: Edge, Heat/Ice}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 33.8\%\\\hline
1 & Warm & 13.6\%\\\hline
2 & Lush & 23.9\%\\\hline
3 & Cold & 23.9\%\\\hline
4 & Freezing & 4.8\%\\\hline
\end{tabular}
\medskip\noindent
Changes Freezing(4) lands which are adjacent to Warm(1) or Lush(2) temperatures to Cold(3).
\subsection{Layer 13: Edge, Special}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1024} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 33.8\%\\\hline
1 & Warm & 12.5\%\\\hline
2 & Lush & 22.1\%\\\hline
3 & Cold & 22.1\%\\\hline
4 & Freezing & 4.4\%\\\hline
- & Special & 5.1\% / 60\\\hline
\end{tabular}
\medskip\noindent
Marks every 1 in 13 lands (non-ocean) as special, by adding a 4-bit number in 0x0F00 to the value.
\subsection{Layer 14: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:512} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 35.6\%\\\hline
1 & Warm & 12.2\%\\\hline
2 & Lush & 21.9\%\\\hline
3 & Cold & 21.9\%\\\hline
4 & Freezing & 4.2\%\\\hline
- & Special & 4.2\% / 60\\\hline
\end{tabular}
\subsection{Layer 15: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:256} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 35.6\%\\\hline
1 & Warm & 11.9\%\\\hline
2 & Lush & 21.9\%\\\hline
3 & Cold & 21.9\%\\\hline
4 & Freezing & 4.2\%\\\hline
- & Special & 4.5\% / 60\\\hline
\end{tabular}
\subsection{Layer 16: Add Island}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:256} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 31.4\%\\\hline
1 & Warm & 12.7\%\\\hline
2 & Lush & 22.4\%\\\hline
3 & Cold & 22.8\%\\\hline
4 & Freezing & 6.2\%\\\hline
- & Special & 4.5\% / 60\\\hline
\end{tabular}
\subsection{Layer 17: Add Mushroom Island}
\begin{tabular}{|l|l|l|l|}\hline
Scale: & \multicolumn{3}{|l|}{1:256} \\\hline\hline
Value & Type & \multicolumn{2}{l|}{Occurrence} \\\hline
0 & Ocean & \multicolumn{2}{l|}{31.4\%}\\\hline
1 & Warm & \multicolumn{2}{l|}{12.8\%}\\\hline
2 & Lush & \multicolumn{2}{l|}{22.5\%}\\\hline
3 & Cold & \multicolumn{2}{l|}{22.7\%}\\\hline
4 & Freezing & \multicolumn{2}{l|}{6.08\%}\\\hline
14 & Mushroom & \multicolumn{2}{l|}{0.0773\%}\\\hline\hline
\makecell[l]{ $(n<<8)+1$ \\ with $n = $ \\ $1, 4, 7, 10, 13$ } & - &
\makecell[l]{0.0690\% \\each} & \multirow{5}{*}{0.90\%}\\\cline{1-3}
\makecell[l]{ $(n<<8)+1$ \\ with $n = $ \\ $2, 3, 5, 6, 8, 9,$ \\ $11, 12, 14, 15$ } & - & \makecell[l]{0.0553\% \\ each} & \\\hline\hline
\makecell[l]{ $(n<<8)+2$ \\ with $n = $ \\ $1, 4, 7, 10, 13$ } & - &
\makecell[l]{0.1236\% \\ each} & \multirow{5}{*}{1.56\%}\\\cline{1-3}
\makecell[l]{ $(n<<8)+2$ \\ with $n = $ \\ $2, 3, 5, 6, 8, 9,$ \\ $11, 12, 14, 15$ } & - & \makecell[l]{0.0961\% \\ each} & \\\hline\hline
\makecell[l]{ $(n<<8)+3$ \\ with $n = $ \\ $1, 4, 7, 10, 13$ } & - &
\makecell[l]{0.1078\% \\ each} & \multirow{5}{*}{1.58\%}\\\cline{1-3}
\makecell[l]{ $(n<<8)+3$ \\ with $n = $ \\ $2, 3, 5, 6, 8, 9,$ \\ $11, 12, 14, 15$ } & - &
\makecell[l]{0.1037\% \\ each} & \\\hline\hline
\makecell[l]{ $(n<<8)+4$ \\ with $n = $ \\ $1, 4, 7, 10, 13$ } & - &
\makecell[l]{0.0212\% \\ each} & \multirow{5}{*}{0.32\%}\\\cline{1-3}
\makecell[l]{ $(n<<8)+4$ \\ with $n = $ \\ $2, 3, 5, 6, 8, 9,$ \\ $11, 12, 14, 15$ } & - &
\makecell[l]{0.0212\% \\ each} & \\\hline
\end{tabular}
\medskip\noindent
Changes every 100th Ocean (adjacent to more Ocean) to Mushroom Island. The special land types are written out in full in the table above. (Note "$<<$" represents a left bit shit.) Added together, the special types make up an average of about 4.37\% of the area.
\subsection{Layer 18: Deep Ocean}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:256} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & Ocean & 22.0\%\\\hline
1 & Warm & 12.8\%\\\hline
2 & Lush & 22.5\%\\\hline
3 & Cold & 22.7\%\\\hline
4 & Freezing & 6.1\%\\\hline
14 & Mushroom & 0.0773\%\\\hline
24 & Deep Ocean & 9.4\%\\\hline
- & Special & 4.4\% / 60\\\hline
\end{tabular}
\medskip\noindent
Changes any Ocean which is surrounded by more Ocean to Deep Ocean.\\
(Special lands still have the same statistics as shown for Layer 17.)
\subsection{Layer 19: Biome}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:256} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 22.0\%\\\hline
1 & plains & 11.6\%\\\hline
2 & desert & 6.41\%\\\hline
3 & extremeHills & 9.44\%\\\hline
4 & forest & 9.43\%\\\hline
5 & taiga & 5.68\%\\\hline
6 & swampland & 3.75\%\\\hline
12 & icePlains & 4.80\%\\\hline
14 & mushroomIsland & 0.0773\%\\\hline
21 & jungle & 1.58\%\\\hline
24 & deepOcean & 9.38\%\\\hline
27 & birchForest & 3.75\%\\\hline
29 & roofedForest & 3.75\%\\\hline
30 & coldTaiga & 1.60\%\\\hline
32 & megaTaiga & 1.58\%\\\hline
35 & savanna & 4.28\%\\\hline
38 & mesaPlateau\_F & 0.598\%\\\hline
39 & mesaPlateau & 0.299\%\\\hline
\end{tabular}
\medskip\noindent
Assigns the actual biome IDs to the lands, based on the temperature category of the land. To be more specific the selection criteria are:
\begin{tabular}{l c c l}
Temperature & & Weight & Biome \\\hline\hline
Warm & $\longrightarrow$ &
\makecell[c]{1/2 \\ 1/3 \\ 1/6} &
\makecell[l]{desert \\ savanna \\ plains} \\\hline
Warm, special & $\longrightarrow$ &
\makecell[c]{1/3 \\ 2/3} &
\makecell[l]{mesaPlateau \\ mesaPlateau\_F} \\\hline
Lush & $\longrightarrow$ &
\makecell[c]{1/6 \\ 1/6 \\ 1/6 \\ 1/6 \\ 1/6 \\ 1/6} &
\makecell[l]{forest \\ roofedForest \\ extremeHills \\ plains \\ birchForest \\ swampland} \\\hline
Lush, special & $\longrightarrow$ &
\makecell[c]{1/1} &
jungle \\\hline
Cold & $\longrightarrow$ &
\makecell[c]{1/4 \\ 1/4 \\ 1/4 \\ 1/4} &
\makecell[l]{forest \\ extremeHills \\ taiga \\ plains} \\\hline
Cold, special & $\longrightarrow$ &
\makecell[c]{1/1} &
megaTaiga \\\hline
Freezing& $\longrightarrow$ &
\makecell[c]{3/4 \\ 1/4} &
\makecell[l]{icePlains \\ coldTaiga}
\end{tabular}
\medskip\noindent
Ocean and Mushroom types are not affected by this layer. The special category is selected when one of the higher bits (0xF00) are set. E.g. 0x603 has high bits and is thus a special Cold(3) category.
\subsection{Layer 20: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:128} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 23.6\%\\\hline
1 & plains & 11.3\%\\\hline
2 & desert & 6.48\%\\\hline
3 & extremeHills & 9.28\%\\\hline
4 & forest & 9.28\%\\\hline
5 & taiga & 5.52\%\\\hline
6 & swampland & 3.61\%\\\hline
12 & icePlains & 4.94\%\\\hline
14 & mushroomIsland & 0.0586\%\\\hline
21 & jungle & 1.62\%\\\hline
24 & deepOcean & 9.09\%\\\hline
27 & birchForest & 3.61\%\\\hline
29 & roofedForest & 3.61\%\\\hline
30 & coldTaiga & 1.45\%\\\hline
32 & megaTaiga & 1.62\%\\\hline
35 & savanna & 4.12\%\\\hline
38 & mesaPlateau\_F & 0.602\%\\\hline
39 & mesaPlateau & 0.279\%\\\hline
\end{tabular}
\subsection{Layer 21: Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:64} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 23.9\%\\\hline
1 & plains & 11.2\%\\\hline
2 & desert & 6.50\%\\\hline
3 & extremeHills & 9.23\%\\\hline
4 & forest & 9.23\%\\\hline
5 & taiga & 5.49\%\\\hline
6 & swampland & 3.56\%\\\hline
12 & icePlains & 5.00\%\\\hline
14 & mushroomIsland & 0.0543\%\\\hline
21 & jungle & 1.62\%\\\hline
24 & deepOcean & 9.03\%\\\hline
27 & birchForest & 3.58\%\\\hline
29 & roofedForest & 3.57\%\\\hline
30 & coldTaiga & 1.43\%\\\hline
32 & megaTaiga & 1.62\%\\\hline
35 & savanna & 4.08\%\\\hline
38 & mesaPlateau\_F & 0.603\%\\\hline
39 & mesaPlateau & 0.275\%\\\hline
\end{tabular}
\subsection{Layer 22: Biome Edge}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:64} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 23.9\%\\\hline
1 & plains & 11.2\%\\\hline
2 & desert & 6.48\%\\\hline
3 & extremeHills & 9.23\%\\\hline
4 & forest & 9.23\%\\\hline
5 & taiga & 6.01\%\\\hline
6 & swampland & 3.47\%\\\hline
12 & icePlains & 5.00\%\\\hline
14 & mushroomIsland & 0.0543\%\\\hline
21 & jungle & 1.62\%\\\hline
23 & jungleEdge & 0.0144\%\\\hline
24 & deepOcean & 9.03\%\\\hline
27 & birchForest & 3.58\%\\\hline
29 & roofedForest & 3.57\%\\\hline
30 & coldTaiga & 1.43\%\\\hline
32 & megaTaiga & 1.11\%\\\hline
34 & extremeHillsPlus & 0.0111\%\\\hline
35 & savanna & 4.09\%\\\hline
37 & mesa & 0.321\%\\\hline
38 & mesaPlateau\_F & 0.385\%\\\hline
39 & mesaPlateau & 0.172\%\\\hline
\end{tabular}
\medskip\noindent
Introduces the biomes jungleEdge, extremeHillsPlus and mesa. The conditional biome changes that take place in this layer are:
\begin{tabular}{l c l}
mesaPlateau\_F & $\longrightarrow$ & mesa\\
mesaPlateau & $\longrightarrow$ & mesa\\
megaTaiga & $\longrightarrow$ & taiga\\
desert & $\longrightarrow$ & extremeHillsPlus\\
swampland & $\longrightarrow$ & jungleEdge \\
swampland & $\longrightarrow$ & plains
\end{tabular}
\subsection{Layer 23: River Init}
Starts a new branch of off Layer 18: Deep Ocean. This layer overwrites each map entry that is not Ocean(0) with a pseudo random number between 2 and 300000 (inclusive).
\subsection{Layer 24: Zoom}
\subsection{Layer 25: Zoom}
\subsection{Layer 26: Hills}
This is a multilayer which joins the biome generation with the river generator branch at the layers Biome Edge (22) and Zoom (25). However at this stage the river branch is mostly just used as a pseudo random number source.
\medskip\noindent
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:64} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 17.5\%\\\hline
1 & plains & 9.86\%\\\hline
2 & desert & 4.83\%\\\hline
3 & extremeHills & 6.95\%\\\hline
4 & forest & 8.87\%\\\hline
5 & taiga & 4.67\%\\\hline
6 & swampland & 3.36\%\\\hline
12 & icePlains & 3.54\%\\\hline
13 & iceMountains & 1.30\%\\\hline
14 & mushroomIsland & 0.0543\%\\\hline
17 & desertHills & 1.46\%\\\hline
18 & forestHills & 2.68\%\\\hline
19 & taigaHills & 1.15\%\\\hline
21 & jungle & 1.15\%\\\hline
22 & jungleHills & 0.420\%\\\hline
23 & jungleEdge & 0.0140\%\\\hline
24 & deepOcean & 14.4\%\\\hline
27 & birchForest & 2.58\%\\\hline
28 & birchForestHills & 0.800\%\\\hline
29 & roofedForest & 2.57\%\\\hline
30 & coldTaiga & 1.11\%\\\hline
31 & coldTaigaHills & 0.282\%\\\hline
32 & megaTaiga & 0.688\%\\\hline
33 & megaTaigaHills & 0.344\%\\\hline
34 & extremeHillsPlus & 1.80\%\\\hline
35 & savanna & 3.05\%\\\hline
36 & savannaPlateau & 0.830\%\\\hline
37 & mesa & 0.486\%\\\hline
38 & mesaPlateau\_F & 0.240\%\\\hline
39 & mesaPlateau & 0.107\%\\\hline
\end{tabular}
\newpage\noindent
\begin{tabular}{|l|l|l|}\hline
129 & Sunflower Plains & 0.4816\%\\\hline
130 & Desert M & 0.1971\%\\\hline
131 & Extreme Hills M & 0.2944\%\\\hline
132 & Flower Forest & 0.4904\%\\\hline
133 & Taiga M & 0.1897\%\\\hline
134 & Swampland M & 0.1109\%\\\hline
140 & Ice Plains Spikes & 0.1606\%\\\hline
149 & Jungle M & 0.0511\%\\\hline
151 & Jungle Edge M & 0.0005\%\\\hline
155 & Birch Forest M & 0.1154\%\\\hline
156 & Birch Forest Hills M & 0.0854\%\\\hline
157 & Roofed Forest M & 0.1144\%\\\hline
158 & Cold Taiga M & 0.0461\%\\\hline
160 & Mega Spruce Taiga & 0.0365\%\\\hline
161 & Redwood Taiga Hills & 0.0366\%\\\hline
162 & Extreme Hills+ M & 0.1913\%\\\hline
163 & Savanna M & 0.1240\%\\\hline
164 & Savanna Plateau M & 0.0853\%\\\hline
165 & Mesa (Bryce) & 0.0263\%\\\hline
166 & Mesa Plateau F M & 0.0123\%\\\hline
167 & Mesa Plateau M & 0.0056\%\\\hline
\end{tabular}
\medskip\noindent
Nine new biomes: iceMountains, desertHills, forestHills, taigaHills, jungleHills, birchForestHills, coldTaigaHills, megaTaigaHills and savannaPlateau. Also there are 21 new mutated variants which I have listed by their ingame display name.
This layer converts some map entries to related biomes, forming small biome patches. A list of the conversions that take place in this manor is shown below. Additionally, this layer adds 128 to some map entries, provided that the resulting biome ID is valid, forming mutated biome variants.
\begin{tabular}{l c l}
desert & $\longrightarrow$ & desertHill\\
forest & $\longrightarrow$ & forestHills\\
birchForest & $\longrightarrow$ & birchForestHills\\
roofedForest & $\longrightarrow$ & plains\\
taiga & $\longrightarrow$ & taigaHills\\
megaTaiga & $\longrightarrow$ & megaTaigaHills\\
coldTaiga & $\longrightarrow$ & coldTaigaHills\\
plains & $\longrightarrow$ & (1/3) forestHills, (2/3) forest\\
icePlains & $\longrightarrow$ & iceMountains\\
jungle & $\longrightarrow$ & jungleHills\\
ocean & $\longrightarrow$ & deepOcean\\
extremeHills & $\longrightarrow$ & extremeHillsPlus\\
savanna & $\longrightarrow$ & savannaPlateau\\
mesaPlateau\_F & $\longrightarrow$ & mesa\\
deepOcean & $\longrightarrow$ & (1/2) plains, (1/2) forest
\end{tabular}
\subsection{Layer 27: Rare Biome}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:64} \\\hline\hline
Value & Type & Occurrence \\\hline
1 & plains & 9.68\%\\\hline
129 & Sunflower Plains & 0.654\%\\\hline
... & ... & ...\\\hline
\end{tabular}
\medskip\noindent
This layer converts 1/57 th of Plains to Sunflower Plains. It has no affect on other biomes.
\subsection{Layer 31: Shore}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:16} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 15.7\%\\\hline
1 & plains & 8.93\%\\\hline
2 & desert & 4.59\%\\\hline
3 & extremeHills & 6.68\%\\\hline
4 & forest & 8.67\%\\\hline
5 & taiga & 4.39\%\\\hline
6 & swampland & 3.44\%\\\hline
12 & icePlains & 3.44\%\\\hline
13 & iceMountains & 1.15\%\\\hline
14 & mushroomIsland & 0.0370\%\\\hline
15 & mushroomIslandShore & 0.0208\%\\\hline
16 & beach & 3.81\%\\\hline
17 & desertHills & 1.27\%\\\hline
18 & forestHills & 2.27\%\\\hline
19 & taigaHills & 0.975\%\\\hline
21 & jungle & 1.03\%\\\hline
22 & jungleHills & 0.359\%\\\hline
23 & jungleEdge & 0.0853\%\\\hline
24 & deepOcean & 15.7\%\\\hline
25 & stoneBeach & 0.534\%\\\hline
26 & coldBeach & 0.311\%\\\hline
27 & birchForest & 2.45\%\\\hline
28 & birchForestHills & 0.800\%\\\hline
29 & roofedForest & 2.57\%\\\hline
30 & coldTaiga & 1.07\%\\\hline
31 & coldTaigaHills & 0.246\%\\\hline
32 & megaTaiga & 0.691\%\\\hline
33 & megaTaigaHills & 0.313\%\\\hline
34 & extremeHillsPlus & 2.84\%\\\hline
35 & savanna & 3.05\%\\\hline
36 & savannaPlateau & 0.715\%\\\hline
37 & mesa & 0.469\%\\\hline
38 & mesaPlateau\_F & 0.242\%\\\hline
39 & mesaPlateau & 0.103\%\\\hline
\end{tabular}
\newpage\noindent
\begin{tabular}{|l|l|l|}\hline
129 & Sunflower Plains & 0.571\%\\\hline
130 & Desert M & 0.188\%\\\hline
131 & Extreme Hills M & 0.284\%\\\hline
132 & Flower Forest & 0.430\%\\\hline
133 & Taiga M & 0.176\%\\\hline
134 & Swampland M & 0.111\%\\\hline
140 & Ice Plains Spikes & 0.157\%\\\hline
149 & Jungle M & 0.0492\%\\\hline
151 & Jungle Edge M & 0.000451\%\\\hline
155 & Birch Forest M & 0.109\%\\\hline
156 & Birch Forest Hills M & 0.0827\%\\\hline
157 & Roofed Forest M & 0.114\%\\\hline
158 & Cold Taiga M & 0.0477\%\\\hline
160 & Mega Spruce Taiga & 0.0358\%\\\hline
161 & Redwood Taiga Hills & 0.0354\%\\\hline
162 & Extreme Hills+ M & 0.184\%\\\hline
163 & Savanna M & 0.119\%\\\hline
164 & Savanna Plateau M & 0.0824\%\\\hline
165 & Mesa (Bryce) & 0.0236\%\\\hline
166 & Mesa Plateau F M & 0.0121\%\\\hline
167 & Mesa Plateau M & 0.00566\%\\\hline
\end{tabular}
\medskip\noindent
New biomes: mushroomIslandShore, beach, stoneBeach, coldBeach.
\subsection{Layer 41: River}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:4} \\\hline\hline
Value & Type & Occurrence \\\hline
-1 & none & 94.3\%\\\hline
7 & river & 5.70\%\\\hline
\end{tabular}
\medskip\noindent
Uses the zoomed pseudo random output of the river branch to determine the position of rivers in the world. All other values are set to -1.
\subsection{Layer 43: River Mix}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:4} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 13.9\%\\\hline
1 & plains & 9.69\%\\\hline
2 & desert & 4.80\%\\\hline
3 & extremeHills & 7.24\%\\\hline
4 & forest & 9.21\%\\\hline
5 & taiga & 4.47\%\\\hline
6 & swampland & 4.03\%\\\hline
7 & river & 4.19\%\\\hline
11 & frozenRiver & 0.0872\%\\\hline
12 & icePlains & 1.52\%\\\hline
13 & iceMountains & 0.495\%\\\hline
14 & mushroomIsland & 0.0257\%\\\hline
15 & mushroomIslandShore & 0.0172\%\\\hline
16 & beach & 2.96\%\\\hline
17 & desertHills & 1.33\%\\\hline
18 & forestHills & 2.50\%\\\hline
19 & taigaHills & 0.994\%\\\hline
21 & jungle & 1.21\%\\\hline
22 & jungleHills & 0.421\%\\\hline
23 & jungleEdge & 0.101\%\\\hline
24 & deepOcean & 12.7\%\\\hline
25 & stoneBeach & 0.426\%\\\hline
26 & coldBeach & 0.132\%\\\hline
27 & birchForest & 2.96\%\\\hline
28 & birchForestHills & 0.849\%\\\hline
29 & roofedForest & 2.93\%\\\hline
30 & coldTaiga & 0.466\%\\\hline
31 & coldTaigaHills & 0.107\%\\\hline
32 & megaTaiga & 0.704\%\\\hline
33 & megaTaigaHills & 0.316\%\\\hline
34 & extremeHillsPlus & 1.69\%\\\hline
35 & savanna & 2.97\%\\\hline
36 & savannaPlateau & 0.750\%\\\hline
37 & mesa & 0.456\%\\\hline
38 & mesaPlateau\_F & 0.251\%\\\hline
39 & mesaPlateau & 0.110\%\\\hline
\end{tabular}
\newpage\noindent
\begin{tabular}{|l|l|l|}\hline
129 & Sunflower Plains & 0.616\%\\\hline
130 & Desert M & 0.205\%\\\hline
131 & Extreme Hills M & 0.315\%\\\hline
132 & Flower Forest & 0.477\%\\\hline
133 & Taiga M & 0.184\%\\\hline
134 & Swampland M & 0.130\%\\\hline
140 & Ice Plains Spikes & 0.0681\%\\\hline
149 & Jungle M & 0.0582\%\\\hline
151 & Jungle Edge M & 0.000625\%\\\hline
155 & Birch Forest M & 0.136\%\\\hline
156 & Birch Forest Hills M & 0.101\%\\\hline
157 & Roofed Forest M & 0.136\%\\\hline
158 & Cold Taiga M & 0.0196\%\\\hline
160 & Mega Spruce Taiga & 0.0371\%\\\hline
161 & Redwood Taiga Hills & 0.0369\%\\\hline
162 & Extreme Hills+ M & 0.203\%\\\hline
163 & Savanna M & 0.128\%\\\hline
164 & Savanna Plateau M & 0.0882\%\\\hline
165 & Mesa (Bryce) & 0.0257\%\\\hline
166 & Mesa Plateau F M & 0.0134\%\\\hline
167 & Mesa Plateau M & 0.00585\%\\\hline
\end{tabular}
\medskip\noindent
This layer is actually used in parts of the Minecraft code where a faster alternative for the full biome generator is required. Note that this layer has a scale of 1:4 and the final map is just a zoomed version of this layer's output. The function of this layer is to apply the rivers to the main biome branch. A new biome is also added in this layer: frozenRiver.
\subsection{Layer 44: Voronoi Zoom}
\begin{tabular}{|l|l|l|}\hline
Scale: & \multicolumn{2}{|l|}{1:1} \\\hline\hline
Value & Type & Occurrence \\\hline
0 & ocean & 13.7\%\\\hline
1 & plains & 10.0\%\\\hline
2 & desert & 4.84\%\\\hline
3 & extremeHills & 7.50\%\\\hline
4 & forest & 9.54\%\\\hline
5 & taiga & 4.59\%\\\hline
6 & swampland & 4.22\%\\\hline
7 & river & 4.30\%\\\hline
11 & frozenRiver & 0.0806\%\\\hline
12 & icePlains & 1.40\%\\\hline
13 & iceMountains & 0.451\%\\\hline
14 & mushroomIsland & 0.0209\%\\\hline
15 & mushroomIslandShore & 0.0137\%\\\hline
16 & beach & 2.92\%\\\hline
17 & desertHills & 1.33\%\\\hline
18 & forestHills & 2.59\%\\\hline
19 & taigaHills & 1.00\%\\\hline
21 & jungle & 1.26\%\\\hline
22 & jungleHills & 0.429\%\\\hline
23 & jungleEdge & 0.118\%\\\hline
24 & deepOcean & 11.2\%\\\hline
25 & stoneBeach & 0.433\%\\\hline
26 & coldBeach & 0.118\%\\\hline
27 & birchForest & 3.12\%\\\hline
28 & birchForestHills & 0.890\%\\\hline
29 & roofedForest & 3.09\%\\\hline
30 & coldTaiga & 0.428\%\\\hline
31 & coldTaigaHills & 0.0984\%\\\hline
32 & megaTaiga & 0.675\%\\\hline
33 & megaTaigaHills & 0.303\%\\\hline
34 & extremeHillsPlus & 1.74\%\\\hline
35 & savanna & 3.00\%\\\hline
36 & savannaPlateau & 0.751\%\\\hline
37 & mesa & 0.464\%\\\hline
38 & mesaPlateau\_F & 0.238\%\\\hline
39 & mesaPlateau & 0.105\%\\\hline
\end{tabular}
\newpage\noindent
\begin{tabular}{|l|l|l|}\hline
129 & Sunflower Plains & 0.635\%\\\hline
130 & Desert M & 0.203\%\\\hline
131 & Extreme Hills M & 0.325\%\\\hline
132 & Flower Forest & 0.491\%\\\hline
133 & Taiga M & 0.190\%\\\hline
134 & Swampland M & 0.134\%\\\hline
140 & Ice Plains Spikes & 0.0625\%\\\hline
149 & Jungle M & 0.0612\%\\\hline
151 & Jungle Edge M & 0.000781\%\\\hline
155 & Birch Forest M & 0.144\%\\\hline
156 & Birch Forest Hills M & 0.106\%\\\hline
157 & Roofed Forest M & 0.142\%\\\hline
158 & Cold Taiga M & 0.0181\%\\\hline
160 & Mega Spruce Taiga & 0.0356\%\\\hline
161 & Redwood Taiga Hills & 0.0354\%\\\hline
162 & Extreme Hills+ M & 0.210\%\\\hline
163 & Savanna M & 0.129\%\\\hline
164 & Savanna Plateau M & 0.0885\%\\\hline
165 & Mesa (Bryce) & 0.0258\%\\\hline
166 & Mesa Plateau F M & 0.0131\%\\\hline
167 & Mesa Plateau M & 0.00559\%\\\hline
\end{tabular}
\medskip\noindent
This is the final layer in the biome generator and contains all the Overworld biomes except for frozenOcean, which does not generate in Mincraft 1.8 - 1.12.
\end{document}

33
docs/LayerSummary.toc Normal file
View File

@ -0,0 +1,33 @@
\contentsline {section}{\numberline {1}Biome Generator Layers}{3}
\contentsline {subsection}{\numberline {1.0}Seed Finding}{3}
\contentsline {subsection}{\numberline {1.1}Layer 1: Island}{5}
\contentsline {subsection}{\numberline {1.2}Layer 2: Zoom}{5}
\contentsline {subsection}{\numberline {1.3}Layer 3: Add Island}{5}
\contentsline {subsection}{\numberline {1.4}Layer 4: Zoom}{5}
\contentsline {subsection}{\numberline {1.5}Layer 5: Add Island}{5}
\contentsline {subsection}{\numberline {1.6}Layer 6: Add Island}{5}
\contentsline {subsection}{\numberline {1.7}Layer 7: Add Island}{6}
\contentsline {subsection}{\numberline {1.8}Layer 8: Remove Too Much Ocean}{6}
\contentsline {subsection}{\numberline {1.9}Layer 9: Add Snow}{6}
\contentsline {subsection}{\numberline {1.10}Layer 10: Add Island}{6}
\contentsline {subsection}{\numberline {1.11}Layer 11: Edge, Cool/Warm}{6}
\contentsline {subsection}{\numberline {1.12}Layer 12: Edge, Heat/Ice}{7}
\contentsline {subsection}{\numberline {1.13}Layer 13: Edge, Special}{7}
\contentsline {subsection}{\numberline {1.14}Layer 14: Zoom}{7}
\contentsline {subsection}{\numberline {1.15}Layer 15: Zoom}{8}
\contentsline {subsection}{\numberline {1.16}Layer 16: Add Island}{8}
\contentsline {subsection}{\numberline {1.17}Layer 17: Add Mushroom Island}{9}
\contentsline {subsection}{\numberline {1.18}Layer 18: Deep Ocean}{10}
\contentsline {subsection}{\numberline {1.19}Layer 19: Biome}{10}
\contentsline {subsection}{\numberline {1.20}Layer 20: Zoom}{12}
\contentsline {subsection}{\numberline {1.21}Layer 21: Zoom}{12}
\contentsline {subsection}{\numberline {1.22}Layer 22: Biome Edge}{13}
\contentsline {subsection}{\numberline {1.23}Layer 23: River Init}{13}
\contentsline {subsection}{\numberline {1.24}Layer 24: Zoom}{14}
\contentsline {subsection}{\numberline {1.25}Layer 25: Zoom}{14}
\contentsline {subsection}{\numberline {1.26}Layer 26: Hills}{14}
\contentsline {subsection}{\numberline {1.27}Layer 27: Rare Biome}{16}
\contentsline {subsection}{\numberline {1.28}Layer 31: Shore}{17}
\contentsline {subsection}{\numberline {1.29}Layer 41: River}{18}
\contentsline {subsection}{\numberline {1.30}Layer 43: River Mix}{19}
\contentsline {subsection}{\numberline {1.31}Layer 44: Voronoi Zoom}{21}

BIN
docs/layers.odg Normal file

Binary file not shown.

BIN
docs/layers.pdf Normal file

Binary file not shown.

99
find_compactbiomes.c Normal file
View File

@ -0,0 +1,99 @@
/**
* This example program finds seeds that contain all major biomes within 1024
* blocks of the origin. These seeds are very rare, with only about 1 in every
* 100 million. For a speed reference: on my 4GHz CPU it takes about 9 minutes
* to check 1E9 seeds using a single thread.
*/
#include "finders.h"
#include "generator.h"
#define SEED_BUF_LEN 0x10000
struct compactinfo_t
{
long seedStart, seedEnd;
};
void *searchCompactBiomesThread(void *data)
{
struct compactinfo_t info = *(struct compactinfo_t *)data;
long *seeds = (long *) malloc(sizeof(*seeds)*SEED_BUF_LEN);
long i, s, scnt;
for(s = info.seedStart; s < info.seedEnd; s += SEED_BUF_LEN)
{
if(s + SEED_BUF_LEN > info.seedEnd)
scnt = info.seedEnd - s;
else
scnt = SEED_BUF_LEN;
for(i = 0; i < scnt; i++)
{
seeds[i] = s + i;
}
scnt = filterAllTempCats(seeds, seeds, scnt, 0, 0);
// The biomes really shouldn't be further out than 1024 blocks.
scnt = filterAllMajorBiomes(seeds, seeds, scnt, -4, -4, 8, 8);
for(i = 0; i < scnt; i++)
{
printf("%ld\n", seeds[i]);
}
fflush(stdout);
}
free(seeds);
return NULL;
}
int main(int argc, char *argv[])
{
initBiomes();
long seedStart, seedEnd;
uint threads, t;
if(argc > 3)
{
if(sscanf(argv[1], "%ld", &seedStart) != 1) seedStart = 0;
if(sscanf(argv[2], "%ld", &seedEnd) != 1) seedEnd = 1000000000L;
if(sscanf(argv[3], "%u", &threads) != 1) threads = 1;
}
pthread_t threadID[threads];
struct compactinfo_t info[threads];
for(t = 0; t < threads; t++)
{
long seedCnt = (seedEnd - seedStart) / threads;
info[t].seedStart = seedStart + seedCnt * t;
info[t].seedEnd = seedStart + seedCnt * (t+1) + 1;
}
info[threads-1].seedEnd = seedEnd;
for(t = 0; t < threads; t++)
{
pthread_create(&threadID[t], NULL, searchCompactBiomesThread, (void*)&info[t]);
}
for(t = 0; t < threads; t++)
{
pthread_join(threadID[t], NULL);
}
return 0;
}

165
find_quadhuts.c Normal file
View File

@ -0,0 +1,165 @@
/**
* This is an example program that demonstrates how to find seeds with a
* quad-witch-hut located around the specified region (512x512 area).
*
* It uses some optimisations that cause it miss a small number of seeds, in
* exchange for a major speed upgrade. (~99% accuracy, ~1200% speed)
*/
#include "finders.h"
#include "generator.h"
#include "layers.h"
#include <unistd.h>
int main(int argc, char *argv[])
{
// Always initialize the biome list before starting any seed finder or
// biome generator.
initBiomes();
const char *seedFileName = "quadbases_Q1.txt";
if(access(seedFileName, F_OK))
{
printf("Seed base file does not exist: Creating new one.\n"
"This may take a few minutes...\n");
int threads = 6;
int quality = 1;
baseQuadTempleSearch(seedFileName, threads, quality);
}
long i, j, qhcnt;
long base, seed;
long *qhcandidates = loadSavedSeeds(seedFileName, &qhcnt);
Generator g = setupGenerator();
Generator gFilterBiome = setupGenerator();
gFilterBiome.topLayerIndex = 19; // Biome Layer with scale 1:256
int *biomeCache = allocCache(&gFilterBiome, 3, 3);
// Load the positions of the four structures that make up the quad-structure
// so we can test the biome at these positions.
Pos qhpos[4];
// Translate the positions to the desired regions.
int regPosX;
int regPosZ;
if(argc > 2)
{
if(sscanf(argv[1], "%d", &regPosX) != 1) regPosX = 0;
if(sscanf(argv[2], "%d", &regPosZ) != 1) regPosZ = 0;
}
regPosX -= 1;
regPosZ -= 1;
// Setup a dummy layer for Layer 19: Biome.
Layer layerBiome;
setupLayer(&layerBiome, NULL, 200, NULL);
int areaX = (regPosX << 1) + 1;
int areaZ = (regPosZ << 1) + 1;
// Search for a swamp at the structure positions
for(i = 0; i < qhcnt; i++)
{
base = moveTemple(qhcandidates[i], regPosX, regPosZ);
qhpos[0] = getTemplePos(base, 0+regPosX, 0+regPosZ);
qhpos[1] = getTemplePos(base, 0+regPosX, 1+regPosZ);
qhpos[2] = getTemplePos(base, 1+regPosX, 0+regPosZ);
qhpos[3] = getTemplePos(base, 1+regPosX, 1+regPosZ);
/*
for(j = 0; j < 4; j++)
{
printf("(%d,%d) ", qhpos[j].x, qhpos[j].z);
}
printf("\n");
//*/
// This little magic code checks if there is a meaningful chance for
// this seed base to generate swamps in the area.
// The idea is that the conversion from Lush temperature to swampland is
// independent of surroundings, so we can test the conversion
// beforehand. Furthermore biomes tend to leak into the negative
// coordinates because of the Zoom layers, so the majority of hits will
// occur when SouthEast corner (at a 1:256 scale) of the quad-hut has a
// swampland. (This assumption misses about 1 in 500 quad-hut seeds.)
// Finally, here we also exploit that the minecraft random number
// generator is quite bad, such that for the "mcNextRand() mod 6" check
// it has a period pattern of ~3 on the high seed-bits.
for(j = 0; j < 5; j++)
{
seed = base + ((j+0x53) << 48);
setWorldSeed(&layerBiome, seed);
setChunkSeed(&layerBiome, areaX+1, areaZ+1);
if(mcNextInt(&layerBiome, 6) == 5)
break;
}
if(j >= 5) continue;
long hits = 0, swpc;
for(j = 0; j < 0x10000; j++)
{
seed = base + (j << 48);
/** Pre-Generation Checks **/
// We can check that at least one swamp could generate in this area
// before doing the biome generator checks.
setWorldSeed(&layerBiome, seed);
setChunkSeed(&layerBiome, areaX+1, areaZ+1);
if(mcNextInt(&layerBiome, 6) != 5)
continue;
// This seed base does not seem to contain many quad huts, so make
// a more detailed analysis of the surroundings and see if there is
// enough potential for more swamps to justify searching fruther.
if(hits == 0 && (j & 0xfff) == 0xfff)
{
swpc = 0;
setChunkSeed(&layerBiome, areaX, areaZ+1);
swpc += mcNextInt(&layerBiome, 6) == 5;
setChunkSeed(&layerBiome, areaX+1, areaZ);
swpc += mcNextInt(&layerBiome, 6) == 5;
setChunkSeed(&layerBiome, areaX, areaZ);
swpc += mcNextInt(&layerBiome, 6) == 5;
if(swpc < (j > 0x1000 ? 2 : 1)) break;
}
// Dismiss seeds that don't have a swamp near the quad temple.
applySeed(&gFilterBiome, seed);
genArea(&gFilterBiome, biomeCache, (regPosX<<1)+2, (regPosZ<<1)+2, 1, 1);
if(biomeCache[0] != swampland)
continue;
applySeed(&g, seed);
if(getBiomeAtPos(&g, qhpos[0]) != swampland) continue;
if(getBiomeAtPos(&g, qhpos[1]) != swampland) continue;
if(getBiomeAtPos(&g, qhpos[2]) != swampland) continue;
if(getBiomeAtPos(&g, qhpos[3]) != swampland) continue;
printf("%ld\n", seed);
hits++;
}
}
free(biomeCache);
freeGenerator(&g);
freeGenerator(&gFilterBiome);
return 0;
}

684
finders.c Normal file
View File

@ -0,0 +1,684 @@
#include "finders.h"
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
/* Globals */
Biome biomes[256];
const int achievementBiomes[256] = {
// 0 1 2 3 4 5 6 7 8 9
1,1,1,1,1,1,1,1,0,0, // 0
0,1,1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/******************************** SEED FINDING *********************************
*
* If we want to find rare seeds that meet multiple custom criteria then we
* should test each condition, starting with the one that is the cheapest
* to test for, while ruling out the most seeds.
*
* Biome checks are quite expensive and should be applied late in the
* condition chain (to avoid as many unnecessary checks as possible).
* Fortunately we can often rule out vast amounts of seeds before hand.
*/
/*************************** Quad-Structure Checks *****************************
*
* Several tricks can be applied to determine candidate seeds for quad
* structures.
*
* Minecraft uses a 48-bit pseudo random number generator (PRNG) to determine
* the position of it's structures. The remaining top 16 bits do not influence
* the structure positioning. Additionally the position of all temples in a
* world can be translated by applying the following transformation to the
* seed:
*
* seed2 = seed1 - 14357617 - dregX * 341873128712 - dregZ * 132897987541;
*
* Here seed1 and seed2 have the same structure positioning, but moved by a
* region offset of (dregX,dregZ). [a region is 32x32 chunks]
*
* For a quad-structure, we mainly care about relative positioning, so we can
* get away with just checking the regions near the origin: (0,0),(0,1),(1,0)
* and (1,1) and then move the structures to the desired position.
*
* Lastly we can recognise a that the transformation of relative region-
* coordinates imposes some restrictions in the PRNG, such that
* perfect-position quad-structure-seeds can only have certain values for the
* lower 16-bits in their seeds.
*
*
** Set of all Quad-Witch-Huts
*
* These conditions only leave 32 free bits which can comfortably be brute-
* forced to get the entire set of quad-structure candidates. Each of the seeds
* found this way describes an entire set of possible quad-witch-huts
* (with degrees of freedom for region-transposition, and the top 16-bit bits).
*/
#define SEEDMAX (1L << 48)
typedef struct quad_threadinfo_t
{
long start, end;
int threadID;
int quality;
const char *fnam;
} quad_threadinfo_t;
const long lowerBaseBitsQ1[] = // for quad-structure with quality 1
{
0x2aa7,0x3d99,0x60a9,0x8599
};
const long lowerBaseBitsQ2[] = // for quad-structure with quality 2
{
0x0825,0x0bd7,0x0c77,0x0dd7,0x0dd9,0x0e57,0x111c,0x12bc,0x12c1,
0x12c8,0x12e7,0x12ec,0x1357,0x1358,0x1638,0x17c9,0x1849,0x1a47,
0x1c1b,0x1d95,0x22a9,0x241f,0x2899,0x2aa7,0x2bf7,0x2c59,0x2c77,
0x2d19,0x2dd7,0x2df9,0x2e79,0x32c1,0x32c7,0x32c8,0x32f4,0x32f7,
0x32f9,0x333f,0x3344,0x3363,0x3368,0x3377,0x37e7,0x39c7,0x3a47,
0x3a69,0x3ca7,0x3d99,0x41a7,0x44a7,0x44ac,0x4597,0x49a7,0x4aab,
0x4c59,0x52c8,0x52d7,0x52d8,0x52e7,0x5305,0x5343,0x5348,0x5358,
0x5367,0x536c,0x537b,0x57c9,0x57e7,0x5849,0x5929,0x59e9,0x5a67,
0x5a69,0x5c97,0x5d09,0x60a9,0x61a7,0x64ab,0x6bf7,0x6d15,0x6dd7,
0x6dd9,0x6e57,0x6e79,0x72bf,0x72c8,0x72d7,0x72f7,0x7348,0x7358,
0x735d,0x7368,0x751c,0x77c9,0x7869,0x79c7,0x7a47,0x80ad,0x82a7,
0x8599,0x8bd9,0x8bf7,0x8c59,0x8c77,0x8d19,0x8df9,0x8e77,0x8e79,
0x8fcc,0x9070,0x9118,0x92fc,0x933b,0x9340,0x937c,0x93ec,0x93fc,
0x95bc,0x9d87,0x9da6,0xa587,0xa598,0xa5a6,0xa69e,0xb0db,0xb288,
0xb4e3,0xb55d,0xc29a,0xc2a8,0xc7e4,0xca9a,0xcd53,0xd0e5,0xd118,
0xd5ec,0xf2ff,0xf304,0xf33c,0xf341,0xf7c9,0xf7e7,0xf849,0xf867,
0xf9c7,0xf9e9,0xfa67,0xfa69,0xfcab
};
int isQuadTempleBase(const long seed, const long lower, const long upper)
{
// seed offsets for the regions (0,0) to (1,1)
const long reg00base = 14357617;
const long reg01base = 341873128712 + 14357617;
const long reg10base = 132897987541 + 14357617;
const long reg11base = 341873128712 + 132897987541 + 14357617;
long s;
s = (reg00base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 < upper) return 0;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 < upper) return 0;
s = (reg01base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 > lower) return 0;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 < upper) return 0;
s = (reg10base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 < upper) return 0;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 > lower) return 0;
s = (reg11base + seed) ^ 0x5DEECE66DL; // & 0xffffffffffff;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 > lower) return 0;
s = (s * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
if((s >> 17) % 24 > lower) return 0;
return 1;
}
long moveTemple(const long baseSeed, const int regionX, const int regionZ)
{
return (baseSeed - regionX*341873128712 - regionZ*132897987541) & 0xffffffffffff;
}
long *loadSavedSeeds(const char *fnam, long *scnt)
{
FILE *fp = fopen(fnam, "r");
long seed;
long *baseSeeds;
if(fp == NULL)
{
perror("Could not open file: ");
return NULL;
}
*scnt = 0;
while(!feof(fp))
{
if(fscanf(fp, "%ld", &seed) == 1) (*scnt)++;
}
baseSeeds = (long*) calloc(*scnt, sizeof(*baseSeeds));
rewind(fp);
for(long i = 0; i < *scnt && !feof(fp);)
{
if(fscanf(fp, "%ld", &baseSeeds[i]) == 1) i++;
}
fclose(fp);
return baseSeeds;
}
void *baseQuadTempleSearchThread(void *data)
{
quad_threadinfo_t info = *(quad_threadinfo_t*)data;
const long lower = info.quality;
const long upper = 23-info.quality;
const long start = info.start;
const long end = info.end;
long seed;
const long *lowerBits;
int lowerBitsCnt;
int lowerBitsIdx = 0;
if(info.quality == 1)
{
lowerBits = &lowerBaseBitsQ1[0];
lowerBitsCnt = sizeof(lowerBaseBitsQ1) / sizeof(lowerBaseBitsQ1[0]);
}
else if(info.quality == 2)
{
lowerBits = &lowerBaseBitsQ2[0];
lowerBitsCnt = sizeof(lowerBaseBitsQ2) / sizeof(lowerBaseBitsQ2[0]);
}
else
{
printf("Warning: Lower bits for quality %d have not been defined: will try all combinations.\n", info.quality);
static long lowerBaseBitsAll[65536];
lowerBits = &lowerBaseBitsAll[0];
lowerBitsCnt = sizeof(lowerBaseBitsAll) / sizeof(lowerBaseBitsAll[0]);
int i;
for(i = 0; i < 65536; i++) lowerBaseBitsAll[i] = i;
}
char fnam[256];
sprintf(fnam, "%s.part%d", info.fnam, info.threadID);
FILE *fp = fopen(fnam, "a+");
seed = start;
// Check the last entry in the file and use it as a starting point if it
// exists. (I.e. loading the saved progress.)
if(!fseek(fp, -31, SEEK_END))
{
char buf[32];
if(fread(buf, 30, 1, fp) > 0)
{
char *last_newline = strrchr(buf, '\n');
if(sscanf(last_newline, "%ld", &seed) == 1)
{
while(lowerBits[lowerBitsIdx] <= (seed & 0xffff))
lowerBitsIdx++;
seed = (seed & 0x0000ffffffff0000) + lowerBits[lowerBitsIdx];
printf("Thread %d starting from: %ld\n", info.threadID, seed);
}
else
{
seed = start;
}
}
}
fseek(fp, 0, SEEK_END);
while(seed < end)
{
if(isQuadTempleBase(seed, lower, upper))
{
fprintf(fp, "%ld\n", seed);
fflush(fp);
//printf("Thread %d: %ld\n", info.threadID, seed);
}
lowerBitsIdx++;
if(lowerBitsIdx >= lowerBitsCnt)
{
lowerBitsIdx = 0;
seed += 0x10000;
}
seed = (seed & 0x0000ffffffff0000) + lowerBits[lowerBitsIdx];
}
fclose(fp);
return NULL;
}
void baseQuadTempleSearch(const char *fnam, int threads, int quality)
{
pthread_t threadID[threads];
quad_threadinfo_t info[threads];
long t;
for(t = 0; t < threads; t++)
{
info[t].threadID = t;
info[t].start = (t * SEEDMAX / threads) & 0x0000ffffffff0000;
info[t].end = ((info[t].start + (SEEDMAX-1) / threads) & 0x0000ffffffff0000) + 1;
info[t].fnam = fnam;
info[t].quality = quality;
}
for(t = 0; t < threads; t++)
{
pthread_create(&threadID[t], NULL, baseQuadTempleSearchThread, (void*)&info[t]);
}
for(t = 0; t < threads; t++)
{
pthread_join(threadID[t], NULL);
}
// merge thread parts
char fnamThread[256];
char buffer[4097];
FILE *fp = fopen(fnam, "w");
FILE *fpart;
int n;
for(t = 0; t < threads; t++)
{
sprintf(fnamThread, "%s.part%d", info[t].fnam, info[t].threadID);
fpart = fopen(fnamThread, "r");
if(fpart == NULL)
{
perror("Could't merge file: ");
break;
}
while((n = fread(buffer, sizeof(char), 4096, fpart)))
{
if(!fwrite(buffer, sizeof(char), n, fp))
{
perror("Could't merge file: ");
fclose(fp);
fclose(fpart);
return;
}
}
fclose(fpart);
remove(fnamThread);
}
fclose(fp);
}
/**************************** General Biome Checks *****************************
*
*
*/
/* getBiomeAtPos
* ----------------
* Returns the biome for the position specified.
*/
int getBiomeAtPos(Generator *g, Pos pos)
{
static int ints[0x1000];
genArea(g, &ints[0], pos.x, pos.z, 1, 1);
return ints[0];
}
/* getTemplePos
* ------------
* Faster implementation for finding the block position at which the temple
* generation attempt will occur in the specified region.
*/
Pos getTemplePos(long seed, const long regionX, const long regionZ)
{
Pos pos;
// set seed
seed = regionX*341873128712 + regionZ*132897987541 + seed + 14357617;
seed = (seed ^ 0x5DEECE66DL);// & ((1L << 48) - 1);
seed = (seed * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
pos.x = (seed >> 17) % 24;
seed = (seed * 0x5DEECE66DL + 0xBL) & 0xffffffffffff;
pos.z = (seed >> 17) % 24;
pos.x = regionX*512 + (pos.x << 4) + 8;
pos.z = regionZ*512 + (pos.z << 4) + 8;
return pos;
}
/* getTemplePosInRegion
* --------------------
* Finds the chunk position within the specified region (32x32 chunks) where
* the temple generation attempt will occur.
* [ Closer to vanilla implementation than getTemplePos() ]
*/
Pos getTempleChunkInRegion(long seed, int regionX, int regionZ)
{
seed = regionX*341873128712 + regionZ*132897987541 + seed + 14357617;
setSeed(&(seed));
Pos pos;
pos.x = nextInt(&seed, 24);
pos.z = nextInt(&seed, 24);
return pos;
}
/* filterAllTempCats
* -----------------
* Looks through the seeds in 'seedsIn' and copies those for which all
* temperature categories are present in the 3x3 area centred on the specified
* coordinates into 'seedsOut'. The map scale at this layer is 1:1024.
*
* seedsIn: list of seeds to check
* seedsOut: output buffer for the candidate seeds
* seedCnt: number of seeds in 'seedsIn'
* centX, centZ: search centre origin (in 1024 block units)
*
* Returns the number of found candidates.
*/
long filterAllTempCats(long *seedsIn, long *seedsOut, long seedCnt, int centX, int centZ)
{
/* We require all temperature categories, including the special variations
* in order to get all main biomes. This gives 8 required values:
* Oceanic, Warm, Lush, Cold, Freezing,
* Special Warm, Special Lush, Special Cold
* These categories generate at Layer 13: Edge, Special.
*
* Note: The scale at this layer is 1:1024 and each element can "leak" its
* biome values up to 1024 blocks outwards into the negative coordinates
* (due to the Zoom layers).
*
* The plan is to check if the 3x3 area contains all 8 temperature types.
* For this, we can check even earlier at Layer 10: Add Island, that each of
* the Warm, Cold and Freezing categories are present.
*/
/* Edit:
* All the biomes that are generated by a simple Cold climate can actually
* be generated later on. So I have commented out the Cold requirements.
*/
const int pX = centX-1, pZ = centZ-1;
const int sX = 3, sZ = 3;
Generator gFilterSnow = setupGenerator();
gFilterSnow.topLayerIndex = 10;
Generator gFilterSpecial = setupGenerator();
gFilterSpecial.topLayerIndex = 13;
int *cache = allocCache(&gFilterSpecial, sX, sZ);
// Construct a dummy Edge,Special layer.
Layer layerSpecial;
setupLayer(&layerSpecial, NULL, 3, NULL);
long sidx, hits, seed;
int types[9];
int specialCnt;
int i, j;
hits = 0;
for(sidx = 0; sidx < seedCnt; sidx++)
{
seed = seedsIn[sidx];
/*** Pre-Generation Checks ***/
// We require at least 3 special temperature categories which can be
// tested for without going through the previous layers. (We'll get
// false positives due to Oceans, but this works fine to rule out some
// seeds early on.)
setWorldSeed(&layerSpecial, seed);
specialCnt = 0;
for(i = 0; i < sX; i++)
{
for(j = 0; j < sZ; j++)
{
setChunkSeed(&layerSpecial, (long)(i+pX), (long)(j+pZ));
if(mcNextInt(&layerSpecial, 13) == 0)
specialCnt++;
}
}
if(specialCnt < 3)
{
continue;
}
/*** Cold/Warm Check ***/
// Continue by checking if enough cold and warm categories are present.
applySeed(&gFilterSnow, seed);
genArea(&gFilterSnow, cache, pX,pZ, sX,sZ);
memset(types, 0, sizeof(types));
for(i = 0; i < sX*sZ; i++)
types[cache[i]]++;
// 1xOcean needs to be present
// 4xWarm need to turn into Warm, Lush, Special Warm and Special Lush
// 1xFreezing that needs to stay Freezing
// 3x(Cold + Freezing) for Cold, Special Cold and Freezing
if( types[Ocean] < 1 || types[Warm] < 4 || types[Freezing] < 1 ||
types[Cold]+types[Freezing] < 2)
{
continue;
}
/*** Complete Temperature Category Check ***/
// Check that all temperature variants are present.
applySeed(&gFilterSpecial, seed);
genArea(&gFilterSpecial, cache, pX,pZ, sX,sZ);
memset(types, 0, sizeof(types));
for(i = 0; i < sX*sZ; i++)
types[ cache[i] > 4 ? (cache[i]&0xf) + 4 : cache[i] ]++;
if( types[Ocean] < 1 || types[Warm] < 1 || types[Lush] < 1 ||
/*types[Cold] < 1 ||*/ types[Freezing] < 1 ||
types[Warm+4] < 1 || types[Lush+4] < 1 || types[Cold+4] < 1)
{
continue;
}
/*
for(i = 0; i < sX*sZ; i++)
{
printf("%c%d ", " s"[cache[i] > 4], cache[i]&0xf);
if(i % sX == sX-1) printf("\n");
}
printf("\n");*/
// Save the candidate.
seedsOut[hits] = seed;
hits++;
}
freeGenerator(&gFilterSnow);
freeGenerator(&gFilterSpecial);
free(cache);
return hits;
}
const int majorBiomes[] = {
ocean, plains, desert, extremeHills, forest, taiga, swampland,
icePlains, mushroomIsland, jungle, deepOcean, birchForest, roofedForest,
coldTaiga, megaTaiga, savanna, mesaPlateau_F, mesaPlateau
};
/* filterAllMajorBiomes
* --------------------
* Looks through the list of seeds in 'seedsIn' and copies those that have all
* major overworld biomes in the specified area into 'seedsOut'. These checks
* are done at a scale of 1:256.
*
* Returns the number of seeds found.
*/
long filterAllMajorBiomes(long *seedsIn, long *seedsOut, long seedCnt,
int pX, int pZ, uint sX, uint sZ)
{
/* We want to determine if
*
*/
Generator gFilterMushroom = setupGenerator();
gFilterMushroom.topLayerIndex = 17;
Generator gFilterBiomes = setupGenerator();
gFilterBiomes.topLayerIndex = 19;
int *cache = allocCache(&gFilterBiomes, sZ, sZ);
long sidx, seed, hits;
uint i, id, hasAll;
int types[BIOME_NUM];
hits = 0;
for(sidx = 0; sidx < seedCnt; sidx++)
{
/* We can use the Mushroom layer both to check for mushroomIsland biomes
* and to make sure all temperature categories are present in the area.
*/
seed = seedsIn[sidx];
applySeed(&gFilterMushroom, seed);
genArea(&gFilterMushroom, cache, pX,pZ, sX,sZ);
memset(types, 0, sizeof(types));
for(i = 0; i < sX*sZ; i++)
{
id = cache[i];
if(id >= BIOME_NUM) id = (id & 0xf) + 4;
types[id]++;
}
if( types[Ocean] < 1 || types[Warm] < 1 || types[Lush] < 1 ||
/* types[Cold] < 1 || */ types[Freezing] < 1 ||
types[Warm+4] < 1 || types[Lush+4] < 1 || types[Cold+4] < 1 ||
types[mushroomIsland] < 1)
{
continue;
}
/*** Find all major biomes ***/
applySeed(&gFilterBiomes, seed);
genArea(&gFilterBiomes, cache, pX,pZ, sX,sZ);
memset(types, 0, sizeof(types));
for(i = 0; i < sX*sZ; i++)
{
types[cache[i]]++;
}
hasAll = 1;
for(i = 0; i < sizeof(majorBiomes) / sizeof(*majorBiomes); i++)
{
// plains, taiga and deepOcean can be generated in later layers.
// Also small islands of Forests can be generated in deepOcean
// biomes, but we are going to ignore those.
if(majorBiomes[i] == plains ||
majorBiomes[i] == taiga ||
majorBiomes[i] == deepOcean)
{
continue;
}
if(types[majorBiomes[i]] < 1)
{
hasAll = 0;
break;
}
}
if(!hasAll)
{
continue;
}
seedsOut[hits] = seed;
hits++;
}
freeGenerator(&gFilterMushroom);
freeGenerator(&gFilterBiomes);
free(cache);
return hits;
}

236
finders.h Normal file
View File

@ -0,0 +1,236 @@
#ifndef FINDERS_H_
#define FINDERS_H_
#include "generator.h"
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#define THREADS 6
#define SEEDMAX (1L << 48)
static const int oceanMonumentBiomeList[] = {ocean, deepOcean, river, frozenOcean, frozenRiver};
static const int biomesToSpawnIn[] = {forest, plains, taiga, taigaHills, forestHills, jungle, jungleHills};
STRUCT(Pos)
{
int x, z;
};
extern Biome biomes[256];
extern const int achievementBiomes[256];
/******************************** SEED FINDING *********************************
*
* If we want to find rare seeds that meet multiple custom criteria then we
* should test each condition, starting with the one that is the cheapest
* to test for, while ruling out the most seeds.
*
* Biome checks are quite expensive and should be applied late in the
* condition chain (to avoid as many unnecessary checks as possible).
* Fortunately we can often rule out vast amounts of seeds before hand.
*/
/***************************** Quad-Temple Checks ******************************
*
* Several tricks can be applied to determine candidate seeds for quad
* temples (inc. witch huts).
*
* Minecraft uses a 48-bit pseudo random number generator (PRNG) to determine
* the position of it's structures. The remaining top 16 bits do not influence
* the structure positioning. Additionally the position of all temples in a
* world can be translated by applying the following transformation to the
* seed:
*
* seed2 = seed1 - 14357617 - dregX * 341873128712 - dregZ * 132897987541;
*
* Here seed1 and seed2 have the same temple positioning, but moved by a
* region offset of (dregX,dregZ). [a region is 32x32 chunks]
*
* For a quad-temple, we mainly care about relative positioning, so we can get
* away with just checking the regions near the origin: (0,0),(0,1),(1,0),(1,1)
* and then move the temples to the desired position.
*
* Lastly we can recognise a that the transformation of relative region-
* coordinates imposes some restrictions in the PRNG, such that
* perfect-position quad-structure-seeds can only have certain values for the
* lower 16-bits in their seeds.
*
*
** The Set of all Quad-Witch-Huts
*
* These conditions only leave 32 free bits which can comfortably be brute-
* forced to get the entire set of quad-structure candidates. Each of the seeds
* found this way describes an entire set of possible quad-witch-huts
* (with degrees of freedom for region-transposition, and the top 16-bit bits).
*/
long moveTemple(const long baseSeed, const int regX, const int regZ);
long *loadSavedSeeds(const char *fnam, long *scnt);
void baseQuadTempleSearch(const char *fnam, int threads, int quality);
/**************************** General Biome Checks *****************************
*/
/* getBiomeAtPos
* ----------------
* Returns the biome for the position specified.
*/
int getBiomeAtPos(Generator *g, Pos pos);
/* getTemplePos
* ------------
* Faster implementation for finding the block position at which the temple
* generation attempt will occur in the specified region.
*/
Pos getTemplePos(long seed, const long regionX, const long regionZ);
/* filterAllTempCats
* -----------------
* Looks through the seeds in 'seedsIn' and copies those for which all
* temperature categories are present in the 3x3 area centred on the specified
* coordinates into 'seedsOut'. The map scale at this layer is 1:1024.
*
* seedsIn: list of seeds to check
* seedsOut: output buffer for the candidate seeds
* seedCnt: number of seeds in 'seedsIn'
* centX, centZ: search centre origin (in 1024 block units)
*
* Returns the number of found candidates.
*/
long filterAllTempCats(long *seedsIn, long *seedsOut, long seedCnt, int centX, int centZ);
/* filterAllMajorBiomes
* --------------------
* Looks through the list of seeds in 'seedsIn' and copies those that have all
* major overworld biomes in the specified area into 'seedsOut'. These checks
* are done at a scale of 1:256.
*
* Returns the number of seeds found.
*/
long filterAllMajorBiomes(long *seedsIn, long *seedsOut, long seedCnt,
int pX, int pZ, uint sX, uint sZ);
/********************** C copy of the Java Random methods **********************
*/
static inline void setSeed(long *seed)
{
*seed = (*seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
}
static inline int next(long *seed, const int bits)
{
*seed = (*seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
return (int) (*seed >> (48 - bits));
}
static inline int nextInt(long *seed, const int n)
{
int bits, val;
do {
bits = next(seed, 31);
val = bits % n;
}
while(bits - val + (n - 1) < 0);
return val;
}
static inline long nextLong(long *seed)
{
return ((long) next(seed, 32) << 32) + next(seed, 32);
}
static inline float nextFloat(long *seed)
{
return next(seed, 24) / (float) (1 << 24);
}
static inline double nextDouble(long *seed)
{
return (((long) next(seed, 26) << 27) + next(seed, 27)) / (double) (1L << 53);
}
// Custom, faster alternative for the first and second call to nextInt(24)
static inline int firstInt24(long seed)
{
seed ^= 0x5deece66d;
seed = (seed * 0x5deece66d) & 0xffffffffffff;
seed >>= 17;
return seed % 24;
}
static inline int secondInt24(long seed)
{
seed ^= 0x5deece66d;
seed = (seed * 0x5deece66d + 0xB) & 0xffffffffffff;
seed = (seed * 0x5deece66d) & 0xffffffffffff;
seed >>= 17;
return seed % 24;
}
/**
* invSeed48()
* -----------
* Returns the previous 48-bit seed which will generate 'nseed'.
* The upper 16 bits are ignored, both here and in the generator.
*/
static inline long invSeed48(long nseed)
{
const long x = 0x5deece66d;
const long xinv = 0xdfe05bcb1365L;
const long y = 0xbL;
const long m48 = 0xffffffffffffL;
long a = nseed >> 32;
long b = nseed & 0xffffffffL;
if(b & 0x80000000L) a++;
long q = ((b << 16) - y - (a << 16)*x) & m48;
for(long k = 0; k <= 5; k++)
{
long d = (x - (q + (k << 48))) % x;
d = (d + x) % x; // force the modulo and keep it positive
if(d < 65536)
{
long c = ((q + d) * xinv) & m48;
if(c < 65536)
{
return ((((a << 16) + c) - y) * xinv) & m48;
}
}
}
return -1;
}
static inline const char *int2binstr(int x, int bit)
{
static char str[33];
str[0] = '\0';
for(bit = (1 << bit); bit > 0; bit >>= 1)
strcat(str, ((x & bit) == bit) ? "1" : "0");
return str;
}
#endif /* FINDERS_H_ */

200
generator.c Normal file
View File

@ -0,0 +1,200 @@
#include "generator.h"
#include "layers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int magscale[] = {1, 4, 16, 64, 256, 256, 1024 };
int *allocCache(Generator *g, int sizeX, int sizeZ)
{
int size = calcRequiredBuf(g, sizeX, sizeZ);
if(size < 256) size = 256;
int *ret = (int*) malloc(sizeof(*ret)*size);
memset(ret, 0, sizeof(*ret)*size);
return ret;
}
void setupLayer(Layer *l, Layer *p, int s, void (*getMap)(Layer *layer, int *out, int x, int z, int w, int h))
{
setBaseSeed(l, s);
l->p = p;
l->p2 = NULL;
l->getMap = getMap;
}
void setupMultiLayer(Layer *l, Layer *p1, Layer *p2, int s, void (*getMap)(Layer *layer, int *out, int x, int z, int w, int h))
{
setBaseSeed(l, s);
l->p = p1;
l->p2 = p2;
l->getMap = getMap;
}
Generator setupGenerator()
{
if(biomes[plains].id == 0)
{
fprintf(stderr, "Warning: The biomes have to be initialised first using initBiomes() before any generator can be used.\n");
}
Generator g;
g.rawSeed = 0;
g.mag = 1;
g.topLayerIndex = 44;
g.layerMax = 44;
g.layers = (Layer*) malloc(sizeof(Layer)*g.topLayerIndex);
// LAYER PARENT SEED LAYER_FUNCTION
setupLayer(&g.layers[ 0], NULL, 1, mapIsland);
setupLayer(&g.layers[ 1], &g.layers[ 0], 2000, mapZoom);
setupLayer(&g.layers[ 2], &g.layers[ 1], 1, mapAddIsland);
setupLayer(&g.layers[ 3], &g.layers[ 2], 2001, mapZoom);
setupLayer(&g.layers[ 4], &g.layers[ 3], 2, mapAddIsland);
setupLayer(&g.layers[ 5], &g.layers[ 4], 50, mapAddIsland);
setupLayer(&g.layers[ 6], &g.layers[ 5], 70, mapAddIsland);
setupLayer(&g.layers[ 7], &g.layers[ 6], 2, mapRemoveTooMuchOcean);
setupLayer(&g.layers[ 8], &g.layers[ 7], 2, mapAddSnow);
setupLayer(&g.layers[ 9], &g.layers[ 8], 3, mapAddIsland);
setupLayer(&g.layers[10], &g.layers[ 9], 2, mapCoolWarm); // MAG1024
setupLayer(&g.layers[11], &g.layers[10], 2, mapHeatIce);
setupLayer(&g.layers[12], &g.layers[11], 3, mapSpecial);
setupLayer(&g.layers[13], &g.layers[12], 2002, mapZoom);
setupLayer(&g.layers[14], &g.layers[13], 2003, mapZoom);
setupLayer(&g.layers[15], &g.layers[14], 4, mapAddIsland);
setupLayer(&g.layers[16], &g.layers[15], 5, mapAddMushroomIsland); // MAGSHROOM
setupLayer(&g.layers[17], &g.layers[16], 4, mapDeepOcean);
// biome layer chain
setupLayer(&g.layers[18], &g.layers[17], 200, mapBiome); // MAG256
setupLayer(&g.layers[19], &g.layers[18], 1000, mapZoom);
setupLayer(&g.layers[20], &g.layers[19], 1001, mapZoom);
setupLayer(&g.layers[21], &g.layers[20], 1000, mapBiomeEdge);
// basic river layer chain, used to determine where hills generate
setupLayer(&g.layers[22], &g.layers[17], 100, mapRiverInit);
setupLayer(&g.layers[23], &g.layers[22], 1000, mapZoom);
setupLayer(&g.layers[24], &g.layers[23], 1001, mapZoom);
setupMultiLayer(&g.layers[25], &g.layers[21], &g.layers[24], 1000, mapHills); // MAG64
setupLayer(&g.layers[26], &g.layers[25], 1001, mapRareBiome);
setupLayer(&g.layers[27], &g.layers[26], 1000, mapZoom);
setupLayer(&g.layers[28], &g.layers[27], 3, mapAddIsland);
setupLayer(&g.layers[29], &g.layers[28], 1001, mapZoom);
setupLayer(&g.layers[30], &g.layers[29], 1000, mapShore);
setupLayer(&g.layers[31], &g.layers[30], 1002, mapZoom);
setupLayer(&g.layers[32], &g.layers[31], 1003, mapZoom);
setupLayer(&g.layers[33], &g.layers[32], 1000, mapSmooth);
// river layer chain
setupLayer(&g.layers[34], &g.layers[22], 1000, mapZoom);
setupLayer(&g.layers[35], &g.layers[34], 1001, mapZoom);
setupLayer(&g.layers[36], &g.layers[35], 1000, mapZoom);
setupLayer(&g.layers[37], &g.layers[36], 1001, mapZoom);
setupLayer(&g.layers[38], &g.layers[37], 1002, mapZoom); // MAG16
setupLayer(&g.layers[39], &g.layers[38], 1003, mapZoom);
setupLayer(&g.layers[40], &g.layers[39], 1, mapRiver);
setupLayer(&g.layers[41], &g.layers[40], 1000, mapSmooth);
setupMultiLayer(&g.layers[42], &g.layers[33], &g.layers[41], 100, mapRiverMix);
setupLayer(&g.layers[43], &g.layers[42], 10, mapVoronoiZoom);
return g;
}
void setGenScale(Generator *g, int magnification)
{
switch(magnification)
{
case MAG1:
g->mag = MAG1;
g->topLayerIndex = 44;
break;
case MAG4:
g->mag = MAG4;
g->topLayerIndex = 43;
break;
case MAG16:
g->mag = MAG16;
g->topLayerIndex = 39;
break;
case MAG64:
g->mag = MAG64;
g->topLayerIndex = 26;
break;
case MAG256:
g->mag = MAG256;
g->topLayerIndex = 19;
break;
case MAGSHROOM:
g->mag = MAGSHROOM;
g->topLayerIndex = 17;
break;
case MAG1024:
g->mag = MAG1024;
g->topLayerIndex = 11;
break;
}
}
int calcRequiredBuf(Generator *g, int areaX, int areaZ)
{
areaX += 2;
areaZ += 2;
int i, maxX = areaX, maxZ = areaZ;
for(i = g->topLayerIndex-1; i >= 0; i--)
{
if(g->layers[i].getMap == mapZoom)
{
areaX = (areaX >> 1) + 2; areaZ = (areaZ >> 1) + 2;
}
else if(g->layers[i].getMap == mapVoronoiZoom)
{
areaX = (areaX >> 2) + 2; areaZ = (areaZ >> 2) + 2;
}
else
{
if(g->layers[i].getMap == mapIsland) continue;
if(g->layers[i].getMap == mapSpecial) continue;
if(g->layers[i].getMap == mapBiome) continue;
if(g->layers[i].getMap == mapRiverInit) continue;
if(g->layers[i].getMap == mapRiverMix) continue;
areaX += 2;
areaZ += 2;
}
if(areaX > maxX) maxX = areaX;
if(areaZ > maxZ) maxZ = areaZ;
}
return (2*maxX+2) * (2*maxZ+2);
}
void freeGenerator(Generator *g)
{
free(g->layers);
}
void applySeed(Generator *g, long seed)
{
g->rawSeed = seed;
// the seed has to be applied recursively, such that the branching layer chains (of parent 2) keep a world seed of zero
setWorldSeed(&g->layers[g->topLayerIndex-1], seed);
}
void genArea(Generator *g, int *out, int areaX, int areaZ, int areaWidth, int areaHeight)
{
Layer *l = &g->layers[g->topLayerIndex-1];
memset(out, 0, areaWidth*areaHeight*sizeof(*out));
l->getMap(l, out, areaX, areaZ, areaWidth, areaHeight);
}

63
generator.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef GENERATOR_H_
#define GENERATOR_H_
#include "layers.h"
/* If speed is more important than accuracy, here are some magnification modes for the generator.
* The map generation is done in stages (layers), some of which zoom into the map, magnifying it.
* These magnification modes control at which stage/magnification the map generation is aborted.
*
* Notes on magnification modes:
* MAG1 - 1 to 1 scale, exact map of the biomes
* MAG4 - 1 to 4 scale, used by some vanilla mc-generation as a faster alternative to the full scale map
* MAG16 - 1 to 16 scale, contains all biomes, except rivers
* MAG64 - 1 to 64 scale, misses oceanic features like beaches, small islands and rare biomes (Sunflower Plains).
* MAG256 - 1 to 256 scale, contains all the basic biomes, no variations (e.g. no hills and no mutations).
* MAGSHROOM, 1 to 256 scale, exploits that Mushroom Islands are determined before most other biomes.
* MAG1024 - 1 to 1024 scale, extreme scale that only contains basic information where biome types generate.
*/
enum Magnification { MAG1, MAG4, MAG16, MAG64, MAG256, MAGSHROOM, MAG1024 };
extern const int magscale[];
STRUCT(Generator) {
Layer *layers;
int topLayerIndex;
int layerMax;
int mag;
long rawSeed;
};
// Initialise an instance of a generator
Generator setupGenerator();
// Sets the magnification mode of the generator
void setGenScale(Generator *g, int magnification);
// Cleans up and frees the generator layers
void freeGenerator(Generator *g);
// Allocates an amount of memory required to generate an area of dimensions 'sizeX' by 'sizeZ'
int *allocCache(Generator *g, int sizeX, int sizeZ);
// Set up custom layers
void setupLayer(Layer *l, Layer *p, int s, void (*getMap)(Layer *layer, int *out, int x, int z, int w, int h));
void setupMultiLayer(Layer *l, Layer *p1, Layer *p2, int s, void (*getMap)(Layer *layer, int *out, int x, int z, int w, int h));
// Calculates the minimum size of the buffers required to generate an area of dimensions 'sizeX' by 'sizeZ'
int calcRequiredBuf(Generator *g, int sizeX, int sizeZ);
// Sets the world seed for the generator
void applySeed(Generator *g, long seed);
/*
* genArea
* -------
* Generates the specified area using the current generator settings and stores the biomeIDs in 'out'.
* The biomeIDs will be indexed in the form: out[x + z*areaWidth]
* It is recommended that 'out' is allocated using allocCache() for the correct buffer size.
*/
void genArea(Generator *g, int *out, int startX, int startZ, int areaWidth, int areaHeight);
#endif /* GENERATOR_H_ */

1107
layers.c Normal file

File diff suppressed because it is too large Load Diff

201
layers.h Normal file
View File

@ -0,0 +1,201 @@
#ifndef LAYER_H_
#define LAYER_H_
#include <stdlib.h>
#define STRUCT(S) typedef struct S S; struct S
#define OPT_O2 __attribute__((optimize("O2")))
enum BiomeID {
none = -1,
ocean = 0, plains, desert, extremeHills, forest, taiga, swampland, river, hell, sky, // 0-9
frozenOcean, frozenRiver, icePlains, iceMountains, mushroomIsland, mushroomIslandShore, beach, desertHills, forestHills, taigaHills, // 10-19
extremeHillsEdge, jungle, jungleHills, jungleEdge, deepOcean, stoneBeach, coldBeach, birchForest, birchForestHills, roofedForest, // 20-29
coldTaiga, coldTaigaHills, megaTaiga, megaTaigaHills, extremeHillsPlus, savanna, savannaPlateau, mesa, mesaPlateau_F, mesaPlateau, // 30-39
BIOME_NUM
};
enum BiomeType {
Ocean, Plains, Desert, Hills, Forest, Taiga, Swamp, River, Hell, Sky, Snow, MushroomIsland, Beach, Jungle, StoneBeach, Savanna, Mesa, BTYPE_NUM
};
enum BiomeTempCategory {
Oceanic, Warm, Lush, Cold, Freezing, Unknown
};
STRUCT(Biome) {
int id;
int type;
double height;
double temp;
int tempCat;
};
STRUCT(Layer) {
long baseSeed; // Generator seed (depends only on hierarchy of generator)
long worldSeed; // based on the seed of the world
long chunkSeed; // randomiser seed
void (*getMap)(Layer *layer, int *out, int x, int z, int w, int h);
Layer *p, *p2;
};
extern Biome biomes[256];
/* initBiomes() has to be called before any of the generators can be used */
void initBiomes();
void setWorldSeed(Layer *layer, long seed);
static inline int getBiomeType(int id)
{
return biomes[id & 0xff].type;
}
static inline int biomeExists(int id)
{
return !(biomes[id & 0xff].id & (~0xff));
}
static inline int getTempCategory(int id)
{
return biomes[id & 0xff].tempCat;
}
static inline int equalOrPlateau(int id1, int id2)
{
if(id1 == id2) return 1;
if(id1 == mesaPlateau_F || id1 == mesaPlateau) return id2 == mesaPlateau_F || id2 == mesaPlateau;
if(!biomeExists(id1) || !biomeExists(id2)) return 0;
// adjust for asymmetric equality (workaround to simulate a bug in the MC java code)
if(id1 >= 128 || id2 >= 128) {
// skip biomes that did not overload the isEqualTo() method
if(id2 == 130 || id2 == 133 || id2 == 134 || id2 == 149 || id2 == 151 || id2 == 155 ||
id2 == 156 || id2 == 157 || id2 == 158 || id2 == 163 || id2 == 164) return 0;
}
return getBiomeType(id1) == getBiomeType(id2);
}
static inline int canBeNeighbors(int id1, int id2)
{
if(equalOrPlateau(id1, id2)) return 1;
if(!biomeExists(id1) || !biomeExists(id2)) return 0;
int tempCat1 = getTempCategory(id1); if(tempCat1 == Lush) return 1;
int tempCat2 = getTempCategory(id2); if(tempCat2 == Lush) return 1;
return tempCat1 == tempCat2;
}
static inline int isOceanic(int id)
{
return id == ocean || id == deepOcean || id == frozenOcean;
}
static inline int isBiomeSnowy(int id)
{
return biomeExists(id) && biomes[id&0xff].temp < 0.1;
}
static inline int mcNextInt(Layer *layer, int mod)
{
int ret = (int)((layer->chunkSeed >> 24) % (long)mod);
if (ret < 0)
{
ret += mod;
}
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
layer->chunkSeed += layer->worldSeed;
return ret;
}
static inline void setChunkSeed(Layer *layer, long chunkX, long chunkZ)
{
layer->chunkSeed = layer->worldSeed;
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
layer->chunkSeed += chunkX;
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
layer->chunkSeed += chunkZ;
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
layer->chunkSeed += chunkX;
layer->chunkSeed *= layer->chunkSeed * 6364136223846793005L + 1442695040888963407L;
layer->chunkSeed += chunkZ;
}
static inline void setBaseSeed(Layer *layer, long seed)
{
layer->baseSeed = seed;
layer->baseSeed *= layer->baseSeed * 6364136223846793005L + 1442695040888963407L;
layer->baseSeed += seed;
layer->baseSeed *= layer->baseSeed * 6364136223846793005L + 1442695040888963407L;
layer->baseSeed += seed;
layer->baseSeed *= layer->baseSeed * 6364136223846793005L + 1442695040888963407L;
layer->baseSeed += seed;
layer->p = NULL;
layer->worldSeed = 0;
layer->chunkSeed = 0;
}
static inline int selectRandom2(Layer *l, int a1, int a2)
{
int i = mcNextInt(l, 2);
return i == 0 ? a1 : a2;
}
static inline int selectRandom4(Layer *l, int a1, int a2, int a3, int a4)
{
int i = mcNextInt(l, 4);
return i == 0 ? a1 : i == 1 ? a2 : i == 2 ? a3 : a4;
}
static inline int selectModeOrRandom(Layer *l, int a1, int a2, int a3, int a4)
{
int rndarg = selectRandom4(l, a1, a2, a3, a4);
if(a2 == a3 && a3 == a4) return a2;
if(a1 == a2 && a1 == a3) return a1;
if(a1 == a2 && a1 == a4) return a1;
if(a1 == a3 && a1 == a4) return a1;
if(a1 == a2 && a3 != a4) return a1;
if(a1 == a3 && a2 != a4) return a1;
if(a1 == a4 && a2 != a3) return a1;
if(a2 == a3 && a1 != a4) return a2;
if(a2 == a4 && a1 != a3) return a2;
if(a3 == a4 && a1 != a2) return a3;
return rndarg;
}
// A null layer does nothing, and can be used to apply a layer to existing data.
void mapNull(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapIsland(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapZoom(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapAddIsland(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRemoveTooMuchOcean(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapAddSnow(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapCoolWarm(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapHeatIce(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapSpecial(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapAddMushroomIsland(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapDeepOcean(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapBiome(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRiverInit(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapBiomeEdge(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapHills(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRiver(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapSmooth(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRareBiome(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapShore(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapRiverMix(Layer *l, int * __restrict out, int x, int z, int w, int h);
void mapVoronoiZoom(Layer *l, int * __restrict out, int x, int z, int w, int h);
#endif /* LAYER_H_ */

37
makefile Normal file
View File

@ -0,0 +1,37 @@
CC = gcc
CFLAGS = -O3 -Wall -fwrapv
LDFLAGS = -lm -lX11 -pthread
.PHONY : all clean
all: find_quadhuts find_compactbiomes clean
find_compactbiomes: find_compactbiomes.o layers.o generator.o finders.o
$(CC) -o $@ $^ $(LDFLAGS)
find_compactbiomes.o: find_compactbiomes.c
$(CC) -c $(CFLAGS) $<
find_quadhuts: find_quadhuts.o layers.o generator.o finders.o
$(CC) -o $@ $^ $(LDFLAGS)
find_quadhuts.o: find_quadhuts.c
$(CC) -c $(CFLAGS) $<
xmapview.o: xmapview.c xmapview.h
$(CC) -c $(CFLAGS) $<
finders.o: finders.c finders.h
$(CC) -c $(CFLAGS) $<
generator.o: generator.c generator.h
$(CC) -c $(CFLAGS) $<
layers.o: layers.c layers.h
$(CC) -c $(CFLAGS) $<
clean:
rm *.o

107959
quadbases_Q1.txt Normal file

File diff suppressed because it is too large Load Diff

291
xmapview.c Normal file
View File

@ -0,0 +1,291 @@
#include "xmapview.h"
#include <string.h>
#include <stdio.h>
/* Global biome colour table. */
void setBiomeColour(unsigned char biomeColour[256][3], int biome,
unsigned char r, unsigned char g, unsigned char b)
{
biomeColour[biome][0] = r;
biomeColour[biome][1] = g;
biomeColour[biome][2] = b;
}
void initBiomeColours(unsigned char biomeColours[256][3])
{
// This colouring scheme is taken from the AMIDST program:
// https://github.com/toolbox4minecraft/amidst
// https://sourceforge.net/projects/amidst.mirror/
memset(biomeColours, 0, 256*3);
setBiomeColour(biomeColours, ocean, 0, 0, 112);
setBiomeColour(biomeColours, plains,141, 179, 96);
setBiomeColour(biomeColours, desert, 250, 148, 24);
setBiomeColour(biomeColours, extremeHills, 96, 96, 96);
setBiomeColour(biomeColours, forest, 5, 102, 33);
setBiomeColour(biomeColours, taiga, 11, 102, 89);
setBiomeColour(biomeColours, swampland, 7, 249, 178);
setBiomeColour(biomeColours, river, 0, 0, 255);
setBiomeColour(biomeColours, hell, 255, 0, 0);
setBiomeColour(biomeColours, sky, 128, 128, 255);
setBiomeColour(biomeColours, frozenOcean, 144, 144, 160);
setBiomeColour(biomeColours, frozenRiver, 160, 160, 255);
setBiomeColour(biomeColours, icePlains, 255, 255, 255);
setBiomeColour(biomeColours, iceMountains, 160, 160, 160);
setBiomeColour(biomeColours, mushroomIsland, 255, 0, 255);
setBiomeColour(biomeColours, mushroomIslandShore, 160, 0, 255);
setBiomeColour(biomeColours, beach, 250, 222, 85);
setBiomeColour(biomeColours, desertHills, 210, 95, 18);
setBiomeColour(biomeColours, forestHills, 34, 85, 28);
setBiomeColour(biomeColours, taigaHills, 22, 57, 51);
setBiomeColour(biomeColours, extremeHillsEdge, 114, 120, 154);
setBiomeColour(biomeColours, jungle, 83, 123, 9);
setBiomeColour(biomeColours, jungleHills, 44, 66, 5);
setBiomeColour(biomeColours, jungleEdge, 98, 139, 23);
setBiomeColour(biomeColours, deepOcean, 0, 0, 48);
setBiomeColour(biomeColours, stoneBeach, 162, 162, 132);
setBiomeColour(biomeColours, coldBeach, 250, 240, 192);
setBiomeColour(biomeColours, birchForest, 48, 116, 68);
setBiomeColour(biomeColours, birchForestHills, 31, 95, 50);
setBiomeColour(biomeColours, roofedForest, 64, 81, 26);
setBiomeColour(biomeColours, coldTaiga, 49, 85, 74);
setBiomeColour(biomeColours, coldTaigaHills, 36, 63, 54);
setBiomeColour(biomeColours, megaTaiga, 89, 102, 81);
setBiomeColour(biomeColours, megaTaigaHills, 69, 79, 62);
setBiomeColour(biomeColours, extremeHillsPlus, 80, 112, 80);
setBiomeColour(biomeColours, savanna, 189, 178, 95);
setBiomeColour(biomeColours, savannaPlateau, 167, 157, 100);
setBiomeColour(biomeColours, mesa, 217, 69, 21);
setBiomeColour(biomeColours, mesaPlateau_F, 176, 151, 101);
setBiomeColour(biomeColours, mesaPlateau, 202, 140, 101);
setBiomeColour(biomeColours, ocean+128, 0, 0, 112);
setBiomeColour(biomeColours, plains+128, 141, 179, 96);
setBiomeColour(biomeColours, desert+128, 250, 148, 24);
setBiomeColour(biomeColours, extremeHills+128, 96, 96, 96);
setBiomeColour(biomeColours, forest+128, 5, 102, 33);
setBiomeColour(biomeColours, taiga+128, 11, 102, 89);
setBiomeColour(biomeColours, swampland+128, 7, 249, 178);
setBiomeColour(biomeColours, river+128, 0, 0, 255);
setBiomeColour(biomeColours, hell+128, 255, 0, 0);
setBiomeColour(biomeColours, sky+128, 128, 128, 255);
setBiomeColour(biomeColours, frozenOcean+128, 144, 144, 160);
setBiomeColour(biomeColours, frozenRiver+128, 160, 160, 255);
setBiomeColour(biomeColours, icePlains+128, 140, 180, 180);
setBiomeColour(biomeColours, iceMountains+128, 160, 160, 160);
setBiomeColour(biomeColours, mushroomIsland+128, 255, 0, 255);
setBiomeColour(biomeColours, mushroomIslandShore+128, 160, 0, 255);
setBiomeColour(biomeColours, beach+128, 250, 222, 85);
setBiomeColour(biomeColours, desertHills+128, 210, 95, 18);
setBiomeColour(biomeColours, forestHills+128, 34, 85, 28);
setBiomeColour(biomeColours, taigaHills+128, 22, 57, 51);
setBiomeColour(biomeColours, extremeHillsEdge+128, 114, 120, 154);
setBiomeColour(biomeColours, jungle+128, 83, 123, 9);
setBiomeColour(biomeColours, jungleHills+128, 44, 66, 5);
setBiomeColour(biomeColours, jungleEdge+128, 98, 139, 23);
setBiomeColour(biomeColours, deepOcean+128, 0, 0, 48);
setBiomeColour(biomeColours, stoneBeach+128, 162, 162, 132);
setBiomeColour(biomeColours, coldBeach+128, 250, 240, 192);
setBiomeColour(biomeColours, birchForest+128, 48, 116, 68);
setBiomeColour(biomeColours, birchForestHills+128, 31, 95, 50);
setBiomeColour(biomeColours, roofedForest+128, 64, 81, 26);
setBiomeColour(biomeColours, coldTaiga+128, 49, 85, 74);
setBiomeColour(biomeColours, coldTaigaHills+128, 36, 63, 54);
setBiomeColour(biomeColours, megaTaiga+128, 89, 102, 81);
setBiomeColour(biomeColours, megaTaigaHills+128, 69, 79, 62);
setBiomeColour(biomeColours, extremeHillsPlus+128, 80, 112, 80);
setBiomeColour(biomeColours, savanna+128, 189, 178, 95);
setBiomeColour(biomeColours, savannaPlateau+128, 167, 157, 100);
setBiomeColour(biomeColours, mesa+128, 217, 69, 21);
setBiomeColour(biomeColours, mesaPlateau_F+128, 176, 151, 101);
setBiomeColour(biomeColours, mesaPlateau+128, 202, 140, 101);
}
void initBiomeTypeColours(unsigned char biomeColours[256][3])
{
memset(biomeColours, 0, 256*3);
setBiomeColour(biomeColours, Oceanic, 0x00, 0x00, 0xa0);
setBiomeColour(biomeColours, Warm, 0xff, 0xc0, 0x00);
setBiomeColour(biomeColours, Lush, 0x00, 0xa0, 0x00);
setBiomeColour(biomeColours, Cold, 0x60, 0x60, 0x60);
setBiomeColour(biomeColours, Freezing, 0xff, 0xff, 0xff);
}
xwin_t init_x(uint sx, uint sy, const char *titel)
{
xwin_t w;
w.dis = XOpenDisplay(NULL);
w.screen = DefaultScreen(w.dis);
w.win = XCreateSimpleWindow(w.dis, DefaultRootWindow(w.dis), 0, 0, sx, sy,
5, 0x000000, 0xffffff);
w.gc = XCreateGC(w.dis, w.win, 0,0);
w.sx = sx;
w.sy = sy;
XSetStandardProperties(w.dis, w.win, titel, "Cubiomes", None, NULL, 0, NULL);
Atom WM_DELETE_WINDOW = XInternAtom(w.dis, "WM_DELETE_WINDOW", False);
XSetWMProtocols(w.dis, w.win, &WM_DELETE_WINDOW, 1);
XSelectInput(w.dis, w.win, ExposureMask|ButtonPressMask|KeyPressMask);
XSetBackground(w.dis, w.gc, 0x000000);
XSetForeground(w.dis, w.gc, 0xffffff);
XClearWindow(w.dis, w.win);
XMapRaised(w.dis, w.win);
return w;
}
void close_x(xwin_t w)
{
XFreeGC(w.dis, w.gc);
XDestroyWindow(w.dis, w.win);
XCloseDisplay(w.dis);
}
void getBiomeColourMap(uint *colbuf, const unsigned char biomeColour[256][3],
const int *ints, const uint sx, const uint sy, const uint pixscale)
{
uint i, j;
int containsInvalidBiomes = 0;
for(j = 0; j < sy; j++)
{
for(i = 0; i < sx; i++)
{
int id = ints[i*sx+j]; //if(id != swampland) id = 100;
uint r, g, b;
if(id < 0 || id >= 256)
{
// This may happen for some intermediate layers
containsInvalidBiomes = 1;
r = 0; g = 0; b = 0;
}
else
{
if(id < 128) {
r = biomeColour[id][0];
g = biomeColour[id][1];
b = biomeColour[id][2];
} else {
r = biomeColour[id][0]+40; r = (r>0xff) ? 0xff : r&0xff;
g = biomeColour[id][1]+40; g = (g>0xff) ? 0xff : g&0xff;
b = biomeColour[id][2]+40; b = (b>0xff) ? 0xff : b&0xff;
}
}
uint m, n;
for(m = 0; m < pixscale; m++){
for(n = 0; n < pixscale; n++){
colbuf[(j*pixscale+n) + sy*pixscale*(i*pixscale+m)] =
((r&0xff) << 16) + ((g&0xff) << 8) + (b&0xff);
}
}
}
}
if(containsInvalidBiomes)
{
printf("Warning: Ints contain invalid Biome IDs (Is this an intermediate layer?)\n");
}
}
void viewmap(Generator *g, unsigned char biomeColour[256][3], int areaX, int areaZ, uint areaWidth, uint areaHeight, uint pixscale)
{
int *ints = allocCache(g, areaWidth+10, areaHeight+1);
// generate the biome ints
genArea(g, ints, areaX, areaZ, areaWidth, areaHeight);
// Calculate a hash for the area (useful to verify the accuracy of the map)
uint i, hash = 0;
for(i = 0; i < areaWidth*areaHeight; i++) hash = hash ^ (i*(ints[i]+1));
printf("Hash:%3X\n", hash&0xfff);
// construct the X11 window
xwin_t w = init_x(areaWidth*pixscale, areaHeight*pixscale, "XMapViewer");
XEvent event;
KeySym key;
char text[255];
// convert the biome ints to a colour image
uint *colbuf = (uint *) malloc(sizeof(uint) *
areaWidth*areaHeight*pixscale*pixscale);
getBiomeColourMap(colbuf, biomeColour, ints, areaWidth, areaHeight, pixscale);
XImage *ximg = XCreateImage(w.dis, DefaultVisual(w.dis,0), 24, ZPixmap, 0,
(char*)colbuf, areaWidth*pixscale, areaHeight*pixscale, 32, 0);
XSetForeground(w.dis, w.gc, 0xf00020);
// enter the event loop
while(1)
{
XNextEvent(w.dis, &event);
if(event.type == ClientMessage)
{
break;
}
if (event.type==Expose && event.xexpose.count==0)
{
XMapWindow(w.dis, w.win);
XPutImage(w.dis, w.win, w.gc, ximg, 0, 0, 0, 0,
areaWidth*pixscale, areaHeight*pixscale);
XSetForeground(w.dis, w.gc, 0xf00020);
}
if (event.type==KeyPress)
{
XLookupString(&event.xkey,text,255,&key,0);
if (key == XK_Escape)
{
break;
}
else
{
}
}
if (event.type==ButtonPress)
{
}
//XResizeWindow(dis, win, sx, sy);
}
close_x(w);
XFree(ximg);
free(ints);
free(colbuf);
}

36
xmapview.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef XMAPVIEW_H_
#define XMAPVIEW_H_
#include "generator.h"
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
typedef struct xwin_t
{
Display *dis;
int screen;
Window win;
GC gc;
uint *colbuf;
uint sx, sy;
} xwin_t;
void initBiomeColours(unsigned char biomeColours[256][3]);
void initBiomeTypeColours(unsigned char biomeColours[256][3]);
xwin_t init_x(uint sx, uint sy, const char *titel);
void close_x(xwin_t w);
void viewmap(Generator *g, unsigned char biomeColour[256][3],
int areaX, int areaZ, uint areaWidth, uint areaHeight, uint pixscale);
#endif