├── .gitignore ├── LICENSE.GPL-2.0 ├── LICENSE.MIT ├── Makefile ├── README.md ├── markov.py ├── uwurandom.c ├── uwurandom_core.h ├── uwurandom_markov_data.h ├── uwurandom_markov_special.h ├── uwurandom_ops.h ├── uwurandom_platform.h ├── uwurandom_types.h └── uwurandom_user.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.ko 3 | *.mod 4 | *.mod.c 5 | .vscode/* 6 | *.cmd 7 | uwurandom 8 | Module.symvers 9 | modules.order 10 | .cache 11 | compile_commands.json -------------------------------------------------------------------------------- /LICENSE.GPL-2.0: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /LICENSE.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 valadaptive 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | KERNELRELEASE ?= $(shell uname -r) 2 | KERNEL_DIR ?= /lib/modules/$(KERNELRELEASE)/build/ 3 | EXTRA_CFLAGS += -I`pwd` -Wno-declaration-after-statement 4 | 5 | obj-m += uwurandom.o 6 | 7 | all: 8 | make -C $(KERNEL_DIR) M=`pwd` modules 9 | 10 | clean: 11 | make -C $(KERNEL_DIR) M=`pwd` clean 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # /dev/uwurandom 2 | 3 | `/dev/urandom` is made out of cold hard math. Instead, consider using `/dev/uwurandom`, which generates data through a tiny catgirl furiously typing away utter nonsense inside your computer. 4 | 5 | **Disclaimer: I am very bad at C. While I've tested this myself and haven't managed to cause a kernel panic, this is not production-quality code. Use at your own risk.** 6 | 7 | ## Installation and usage 8 | 9 | ### Installation 10 | Compilation is easy :3 11 | 12 | First up, you'll need to install kernel headers for whichever kernel version you've installed. 13 | 14 | On Ubuntu or Debian (assuming your kernel is already up-to-date): 15 | ```bash 16 | sudo apt-get install linux-headers-generic 17 | ``` 18 | 19 | On Fedora: 20 | ```bash 21 | sudo dnf install kernel-devel 22 | ``` 23 | 24 | On Arch: 25 | ```bash 26 | sudo pacman -S linux-headers 27 | ``` 28 | 29 | (or `linux-lts-headers` if you're using the `linux-lts` kernel) 30 | 31 | Once you've installed the kernel headers, you should be able to simply run `make` to build the kernel module: 32 | ```bash 33 | make 34 | ``` 35 | 36 | ### Usage 37 | 38 | Usage is also easy! >w< To insert the kernel module, just run: 39 | 40 | ```bash 41 | sudo insmod uwurandom.ko 42 | ``` 43 | 44 | When the module is loaded, it automatically sets up the `/dev/uwurandom` device, so you can do: 45 | 46 | ```bash 47 | cat /dev/uwurandom 48 | ``` 49 | and witness its sheer glory with your own eyes. 50 | 51 | If things are a bit too silly and you want to un-load the kernel module, run: 52 | 53 | ``` 54 | sudo rmmod uwurandom 55 | ``` 56 | 57 | Or, if you're boring and don't want to load an entire kernel module for generating catgirl keyboard mashing, you can compile the userspace version: 58 | 59 | ``` 60 | clang -O3 uwurandom_user.c -o uwurandom 61 | ``` 62 | -------------------------------------------------------------------------------- /markov.py: -------------------------------------------------------------------------------- 1 | from typing import Tuple, TypeVar, Generic, OrderedDict, Optional 2 | from dataclasses import dataclass 3 | from enum import Enum 4 | import re 5 | 6 | T = TypeVar('T') 7 | 8 | @dataclass 9 | class NgramChoice: 10 | next_ngram: int 11 | cumulative_probability: int 12 | 13 | @dataclass 14 | class Ngram(Generic[T]): 15 | choices: list[NgramChoice] 16 | total_probability: int 17 | chars: Tuple[T, ...] 18 | 19 | class SpecialMarkov(Enum): 20 | SCRUNKLY_PUNCTUATION = -1 21 | 22 | class MarkovTable(Generic[T]): 23 | def __init__(self, order: int, *strs: list[T]): 24 | self.entries: OrderedDict[Tuple[T, ...], dict[T, int]] = OrderedDict() 25 | self.order = order 26 | 27 | for str in strs: 28 | self.add_string(str) 29 | 30 | def add_string(self, str: list[T]): 31 | for i in range(0, len(str) - self.order): 32 | ngram = tuple(str[i:i + self.order]) 33 | next_char = str[i + self.order] 34 | 35 | ngram_entry = self.entries.setdefault(ngram, {}) 36 | if next_char in ngram_entry: 37 | ngram_entry[next_char] += 1 38 | else: 39 | ngram_entry[next_char] = 1 40 | 41 | # TODO: emit terminal state on last tuple 42 | 43 | def to_table(self) -> Tuple[list[Ngram[T]], dict[Tuple[T, ...], int]]: 44 | # sorted_entries = OrderedDict(sorted(self.entries.items(), key = lambda item: ''.join(item[0]))) # type: ignore 45 | sorted_entries = self.entries 46 | 47 | table: list[Ngram[T]] = [] 48 | ngram_indices = {ngram: index for index, ngram in enumerate(sorted_entries.keys())} 49 | for index, (ngram, probabilities) in enumerate(sorted_entries.items()): 50 | 51 | total_probability = sum(probabilities.values()) 52 | # sort by probability in descending order to minimize linear search steps 53 | next_chars = sorted(probabilities.items(), key=lambda p: p[1], reverse=True) 54 | 55 | cumulative_probability = 0 56 | choices = [] 57 | for char, probability in next_chars: 58 | next_ngram = ngram[1:] + (char,) 59 | if next_ngram not in ngram_indices: 60 | raise ValueError(f'Found terminal ngram {next_ngram}') 61 | 62 | cumulative_probability += probability 63 | next_ngram_index = ngram_indices[next_ngram] 64 | choice = NgramChoice(next_ngram_index, cumulative_probability) 65 | choices.append(choice) 66 | 67 | table.append(Ngram(choices, total_probability, ngram)) 68 | 69 | return table, ngram_indices 70 | 71 | def to_c(self, prefix: str, initial_ngram: Optional[Tuple[T, ...]] = None, specials: Optional[str] = None) -> str: 72 | markov_table, ngram_indices = self.to_table() 73 | 74 | choice_defs = ["static const uwu_markov_choice {prefix}_choices[] = {{".format(prefix=prefix)] 75 | ngram_defs = ["static const uwu_markov_ngram {prefix}_ngrams[] = {{".format(prefix=prefix)] 76 | 77 | table_def = """static const uwu_markov_table {prefix}_table = {{ 78 | .specials = {specials}, 79 | .initial_ngram={initial_ngram}, 80 | .num_ngrams={num_ngrams}, 81 | .choices={prefix}_choices, 82 | .ngrams={prefix}_ngrams 83 | }};""".format( 84 | prefix=prefix, 85 | specials=specials if specials is not None else 'NULL', 86 | initial_ngram=ngram_indices[initial_ngram] if initial_ngram is not None else -1, 87 | num_ngrams=len(markov_table) 88 | ) 89 | 90 | choice_table_index = 0 91 | for ngram_index, ngram in enumerate(markov_table): 92 | choice_defs.append(' // ngram {index} {chars}'.format(index=ngram_index, chars=ngram.chars)) 93 | for choice_index, choice in enumerate(ngram.choices): 94 | choice_defs.append(' {{.next_ngram = {next_ngram}, .cumulative_probability = {cumulative_probability}}},'.format( 95 | next_ngram=choice.next_ngram, 96 | cumulative_probability=choice.cumulative_probability, 97 | comma='' if choice_index == len(ngram.choices) - 1 and ngram_index == len(markov_table) - 1 else ',' 98 | )) 99 | 100 | last_char = ngram.chars[-1] 101 | 102 | ngram_defs.append(' {{.choices = {index}, .total_probability = {total_probability}, .character = {character}}}, // "{chars}"'.format( 103 | prefix=prefix, 104 | index=choice_table_index, 105 | total_probability=ngram.total_probability, 106 | character=last_char.value if isinstance(last_char, SpecialMarkov) else f"'{last_char}'", 107 | chars=ngram.chars 108 | )) 109 | 110 | choice_table_index += len(ngram.choices) 111 | 112 | ngram_defs.append('};') 113 | choice_defs.append('};') 114 | 115 | return '{choices}\n\n{ngrams}\n\n{table_def}'.format(choices='\n'.join(choice_defs), ngrams='\n'.join(ngram_defs), table_def=table_def) 116 | 117 | 118 | catgirl_nonsense = [list(s) for s in """mraowmraowmewmraowmrrppurrrrmraownyanyamraowwwwwmrwmraowmreowmewmrowmraowmewmraownya 119 | mrrrowmeowmrowrmrowpurrrmrowmeowmraowmewmrowrmewnyaaaamrowrnyaamewmeowmrowrmeownya 120 | mrowrmeow 121 | meowmrowrmrowmeow 122 | mrowrnyaaaaa 123 | mrrowmeowmrowrmrrowmeowmrowrnyaaamrowmewmeowmewpurrrrrmeowmrowrmeownya""".split()] 124 | 125 | keysmash = list('alksdhfl;ag;kdhfgjkfhgadskfagdfkajfdhgbklkafghkahgsdfka;dfglkfjhgajdfghkgahjfgafgfkjdhg;lskgjhjkhajhdgfjhkafgl;ajdfglkajdflg;hdkjafhgkgaurgjrahdfgbahiurghrgh;arhnguahraufjalfgnhjhaujeghfgadjog;aldhhjlahuegjfdbhgajkfghafkjgahiurg') 126 | 127 | scrunkly_base = 'the little tienpsy! so adornale and cutest tootsit! awww like and double tap now so it can the to live the cute! happy kdb! awww the scrunkly! scrunkly the when! the boinky spunge! crinkly doo! shronkle scrimblo! aww when the.. the limtle tootsie,, tienpsy widdle scrimblo boinkus! boinky spunge! crinkly doo! scrunkly,,, the widdle. the cutest adornale tienpsy tootsit,,, whem the kity,, n flunf and it,, i,. yay! lookit aw!! lookit the little crungle boinko! aw icamt,,, the kimty and cat sooo mipy. little meowmeow tienpsy and smol sproingle scrunkly,, the liddol blibbly spoinky bintle anmd floof,,, flumfy! sooo springly poinkle n liddol mewmew,,,babey,,tha bleeb,,,blinpus,,, the springle!! widdol liddle kity sooo smol,,, teeny tiney meow kity' 128 | 129 | punctuation = re.compile('[,.!]+\\s*') 130 | 131 | scrunkly_chars = [] 132 | prev_match_start = 0 133 | for match in punctuation.finditer(scrunkly_base): 134 | scrunkly_chars += scrunkly_base[prev_match_start:match.start()] 135 | prev_match_start = match.end() 136 | scrunkly_chars.append(SpecialMarkov.SCRUNKLY_PUNCTUATION) 137 | 138 | if prev_match_start < len(scrunkly_base): 139 | scrunkly_chars += scrunkly_base[prev_match_start:] 140 | 141 | 142 | catgirl_table = MarkovTable(2, *catgirl_nonsense) 143 | keysmash_table = MarkovTable(1, keysmash) 144 | scrunkly_table = MarkovTable(2, scrunkly_chars) 145 | 146 | with open('uwurandom_markov_data.h', 'w', encoding='utf-8') as f: 147 | f.write("""#ifndef _UWURANDOM_MARKOV_DATA_H 148 | #define _UWURANDOM_MARKOV_DATA_H 149 | 150 | #include "uwurandom_types.h" 151 | #include "uwurandom_markov_special.h" 152 | 153 | """) 154 | f.write(catgirl_table.to_c('catnonsense', ('m', 'r'))) 155 | f.write('\n\n') 156 | f.write(keysmash_table.to_c('keysmash')) 157 | f.write('\n\n') 158 | f.write(scrunkly_table.to_c('scrunkly', ('a', 'w'), 'scrunkly_specials')) 159 | f.write("\n\n#endif\n") 160 | -------------------------------------------------------------------------------- /uwurandom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "uwurandom_core.h" 12 | #include "uwurandom_ops.h" 13 | 14 | MODULE_LICENSE("Dual MIT/GPL"); 15 | MODULE_DESCRIPTION("urandom but better"); 16 | MODULE_AUTHOR("valadaptive"); 17 | MODULE_VERSION("0.1"); 18 | 19 | static ssize_t dev_read(struct file *, char *, size_t, loff_t *); 20 | static int dev_open(struct inode *, struct file *); 21 | static int dev_release(struct inode *, struct file *); 22 | 23 | static struct file_operations fops = { 24 | .owner = THIS_MODULE, 25 | .read = dev_read, 26 | .open = dev_open, 27 | .release = dev_release 28 | }; 29 | 30 | static int major; 31 | static struct class* dev_class; 32 | static dev_t dev_num; 33 | 34 | static ssize_t 35 | dev_read(struct file *fp, char *buf, size_t n, loff_t *of) { 36 | uwu_state* state = fp->private_data; 37 | 38 | int result = uwu_write_chars(state, buf, n); 39 | if (result < 0) return result; 40 | 41 | return n; 42 | } 43 | 44 | static int 45 | dev_open(struct inode *ino, struct file *fp) { 46 | size_t len = sizeof(uwu_state); 47 | 48 | uwu_state *data = kmalloc(len, GFP_KERNEL); 49 | 50 | if (data == NULL) { 51 | return -ENOMEM; 52 | } 53 | 54 | int init_err = uwu_init_state(data, uwu_op_table_default, ARRAY_SIZE(uwu_op_table_default)); 55 | 56 | int rng_err = uwu_init_rng(data); 57 | if (init_err) { 58 | uwu_destroy_state(data); 59 | kfree(data); 60 | return rng_err; 61 | } 62 | 63 | fp->private_data = data; 64 | 65 | return 0; 66 | } 67 | 68 | static int 69 | dev_release(struct inode *ino, struct file *fp) { 70 | uwu_destroy_state((uwu_state*) fp->private_data); 71 | kfree(fp->private_data); 72 | fp->private_data = NULL; 73 | return 0; 74 | } 75 | 76 | // Kernel versions 6.2 and up take a const* to devices in dev_uevent 77 | #if ( LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0) ) 78 | typedef const struct device* uevent_dev_ptr; 79 | #else 80 | typedef struct device* uevent_dev_ptr; 81 | #endif 82 | 83 | // Make sure all users can thoroughly enjoy /dev/uwurandom 84 | static int 85 | dev_uevent(uevent_dev_ptr dev, struct kobj_uevent_env* env) { 86 | int result = add_uevent_var(env, "DEVMODE=%#o", 0666); 87 | if (!result) { 88 | return result; 89 | } 90 | return 0; 91 | } 92 | 93 | static void 94 | kexit(void) { 95 | device_destroy(dev_class, dev_num); 96 | class_destroy(dev_class); 97 | unregister_chrdev(major, "uwurandom"); 98 | return; 99 | } 100 | 101 | static int 102 | kinit(void) { 103 | struct device* pDev; 104 | 105 | major = register_chrdev(0, "uwurandom", &fops); 106 | 107 | if (major < 0) 108 | return major; 109 | 110 | dev_num = MKDEV(major, 0); 111 | 112 | // Module pointer parameter removed in kernel version 6.4 113 | // https://lore.kernel.org/all/20230313181843.1207845-4-gregkh@linuxfoundation.org/ 114 | #if ( LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0) ) 115 | dev_class = class_create("uwurandom"); 116 | #else 117 | dev_class = class_create(THIS_MODULE, "uwurandom"); 118 | #endif 119 | 120 | if (IS_ERR(dev_class)) { 121 | unregister_chrdev(major, "uwurandom"); 122 | return PTR_ERR(dev_class); 123 | } 124 | 125 | dev_class->dev_uevent = dev_uevent; 126 | 127 | pDev = device_create(dev_class, NULL, dev_num, NULL, "uwurandom"); 128 | if (IS_ERR(pDev)) { 129 | class_destroy(dev_class); 130 | unregister_chrdev(major, "uwurandom"); 131 | return PTR_ERR(pDev); 132 | } 133 | 134 | 135 | return 0; 136 | } 137 | 138 | module_init(kinit); 139 | module_exit(kexit); 140 | -------------------------------------------------------------------------------- /uwurandom_core.h: -------------------------------------------------------------------------------- 1 | #ifndef _UWURANDOM_CORE_H 2 | #define _UWURANDOM_CORE_H 3 | 4 | #include "uwurandom_platform.h" 5 | #include "uwurandom_types.h" 6 | 7 | #define CREATE_PRINT_STRING(printed_string) (uwu_op){\ 8 | .opcode = UWU_PRINT_STRING,\ 9 | .state = {\ 10 | .print_string = {\ 11 | .string = (printed_string),\ 12 | .remaining_chars = sizeof(printed_string) - 1\ 13 | }\ 14 | }\ 15 | } 16 | 17 | #define CREATE_REPEAT_CHARACTER(repeated_character, num_repetitions) (uwu_op){\ 18 | .opcode = UWU_REPEAT_CHARACTER,\ 19 | .state = {\ 20 | .repeat_character = {\ 21 | .character = (repeated_character),\ 22 | .remaining_chars = (num_repetitions)\ 23 | }\ 24 | }\ 25 | } 26 | 27 | #define CREATE_MARKOV(markov_data, starting_ngram, len) (uwu_op){\ 28 | .opcode = UWU_MARKOV,\ 29 | .state = {\ 30 | .markov = {\ 31 | .prev_ngram = (starting_ngram),\ 32 | .remaining_chars = (len),\ 33 | .ngrams = &(markov_data)\ 34 | }\ 35 | }\ 36 | }\ 37 | 38 | static inline int 39 | uwu_push_op(uwu_state* state, uwu_op op) { 40 | if (state->current_op == MAX_OPS - 1) { 41 | return -1; 42 | } 43 | 44 | state->current_op++; 45 | state->ops[state->current_op] = op; 46 | 47 | return 0; 48 | } 49 | 50 | // Pick a random program from the list of programs and write it to the ops list 51 | static void 52 | generate_new_ops(uwu_state* state) { 53 | uwu_random_number op_idx = uwu_random_int(state); 54 | 55 | if (state->prev_op == -1) { 56 | op_idx %= state->num_ops; 57 | } else { 58 | // don't repeat previous op 59 | op_idx %= state->num_ops - 1; 60 | if (op_idx >= (unsigned int)state->prev_op) { 61 | op_idx += 1; 62 | } 63 | } 64 | 65 | state->prev_op = op_idx; 66 | 67 | // print a space after the op is done executing 68 | uwu_push_op(state, CREATE_PRINT_STRING(" ")); 69 | 70 | state->ops_table[op_idx](state); 71 | } 72 | 73 | // Execute an operation once. Returns the number of characters written, or a negative value on error. 74 | static int uwu_exec_op(uwu_state* state, char* buf, size_t len) { 75 | uwu_op* op = &state->ops[state->current_op]; 76 | switch (op->opcode) { 77 | case UWU_PRINT_STRING: { 78 | char* string = op->state.print_string.string; 79 | size_t remaining = op->state.print_string.remaining_chars; 80 | 81 | if (remaining == 0) { 82 | state->current_op--; 83 | return 0; 84 | } 85 | 86 | size_t num_chars_to_copy = remaining > len ? len : remaining; 87 | 88 | COPY_STR(buf, string, num_chars_to_copy); 89 | 90 | // Advance state by number of characters copied; 91 | op->state.print_string.string += num_chars_to_copy; 92 | op->state.print_string.remaining_chars -= num_chars_to_copy; 93 | 94 | return num_chars_to_copy; 95 | } 96 | 97 | case UWU_MARKOV: { 98 | size_t ngram_index = op->state.markov.prev_ngram; 99 | const uwu_markov_table* table = op->state.markov.ngrams; 100 | const uwu_markov_ngram* ngrams = table->ngrams; 101 | const uwu_markov_choice* choices = table->choices; 102 | size_t remaining = op->state.markov.remaining_chars; 103 | 104 | if (remaining == 0) { 105 | state->current_op--; 106 | return 0; 107 | } 108 | 109 | size_t num_chars_to_copy = remaining > len ? len : remaining; 110 | 111 | size_t i; 112 | for (i = 0; i < num_chars_to_copy; i++) { 113 | uwu_markov_ngram ngram = ngrams[ngram_index]; 114 | uwu_random_number random = uwu_random_int(state); 115 | random %= ngram.total_probability; 116 | int j = 0; 117 | while (true) { 118 | uwu_markov_choice choice = choices[ngram.choices + j]; 119 | size_t cumulative_probability = choice.cumulative_probability; 120 | if (random < cumulative_probability) { 121 | ngram_index = choice.next_ngram; 122 | break; 123 | } 124 | j++; 125 | } 126 | 127 | char ngram_char = ngram.character; 128 | 129 | if (ngram_char < 0) { 130 | size_t special_idx = -1 - ngram_char; 131 | table->specials[special_idx](state); 132 | break; 133 | } else { 134 | COPY_CHAR(ngram_char, buf + i); 135 | } 136 | } 137 | 138 | op->state.markov.prev_ngram = ngram_index; 139 | op->state.markov.remaining_chars -= i; 140 | 141 | return i; 142 | } 143 | 144 | case UWU_REPEAT_CHARACTER: { 145 | char c = op->state.repeat_character.character; 146 | size_t i; 147 | for (i = 0; i < len; i++) { 148 | if (op->state.repeat_character.remaining_chars == 0) { 149 | // Out of characters. Return the number of characters thus written. 150 | state->current_op--; 151 | return i; 152 | } 153 | COPY_CHAR(c, buf + i); 154 | op->state.repeat_character.remaining_chars--; 155 | } 156 | return len; 157 | } 158 | 159 | default: return 0; 160 | } 161 | } 162 | 163 | // Fill the given buffer with UwU 164 | static int uwu_write_chars(uwu_state* state, char* buf, size_t n) { 165 | size_t total_written = 0; 166 | while (total_written < n) { 167 | if (state->current_op == -1) { 168 | // regenerate ops 169 | generate_new_ops(state); 170 | } 171 | 172 | size_t chars_written = uwu_exec_op(state, buf + total_written, n - total_written); 173 | if (chars_written < 0) return chars_written; 174 | 175 | total_written += chars_written; 176 | } 177 | return 0; 178 | } 179 | 180 | static int uwu_init_state(uwu_state* state, uwu_op_factory** ops_table, size_t num_ops) { 181 | int rng_err = uwu_init_rng(state); 182 | if (rng_err) return rng_err; 183 | 184 | state->ops_table = ops_table; 185 | state->num_ops = num_ops; 186 | 187 | state->current_op = -1; 188 | state->prev_op = -1; 189 | 190 | return 0; 191 | } 192 | 193 | static void uwu_destroy_state(uwu_state* state) { 194 | uwu_destroy_rng(state); 195 | } 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /uwurandom_markov_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _UWURANDOM_MARKOV_DATA_H 2 | #define _UWURANDOM_MARKOV_DATA_H 3 | 4 | #include "uwurandom_types.h" 5 | #include "uwurandom_markov_special.h" 6 | 7 | static const uwu_markov_choice catnonsense_choices[] = { 8 | // ngram 0 ('m', 'r') 9 | {.next_ngram = 22, .cumulative_probability = 15}, 10 | {.next_ngram = 1, .cumulative_probability = 24}, 11 | {.next_ngram = 7, .cumulative_probability = 28}, 12 | {.next_ngram = 19, .cumulative_probability = 29}, 13 | {.next_ngram = 20, .cumulative_probability = 30}, 14 | // ngram 1 ('r', 'a') 15 | {.next_ngram = 2, .cumulative_probability = 9}, 16 | // ngram 2 ('a', 'o') 17 | {.next_ngram = 3, .cumulative_probability = 9}, 18 | // ngram 3 ('o', 'w') 19 | {.next_ngram = 4, .cumulative_probability = 22}, 20 | {.next_ngram = 23, .cumulative_probability = 32}, 21 | {.next_ngram = 13, .cumulative_probability = 36}, 22 | {.next_ngram = 18, .cumulative_probability = 37}, 23 | {.next_ngram = 24, .cumulative_probability = 38}, 24 | // ngram 4 ('w', 'm') 25 | {.next_ngram = 0, .cumulative_probability = 17}, 26 | {.next_ngram = 5, .cumulative_probability = 30}, 27 | // ngram 5 ('m', 'e') 28 | {.next_ngram = 21, .cumulative_probability = 12}, 29 | {.next_ngram = 6, .cumulative_probability = 20}, 30 | // ngram 6 ('e', 'w') 31 | {.next_ngram = 4, .cumulative_probability = 6}, 32 | {.next_ngram = 13, .cumulative_probability = 7}, 33 | {.next_ngram = 24, .cumulative_probability = 8}, 34 | // ngram 7 ('r', 'r') 35 | {.next_ngram = 7, .cumulative_probability = 7}, 36 | {.next_ngram = 12, .cumulative_probability = 10}, 37 | {.next_ngram = 22, .cumulative_probability = 13}, 38 | {.next_ngram = 8, .cumulative_probability = 14}, 39 | // ngram 8 ('r', 'p') 40 | {.next_ngram = 9, .cumulative_probability = 1}, 41 | // ngram 9 ('p', 'p') 42 | {.next_ngram = 10, .cumulative_probability = 1}, 43 | // ngram 10 ('p', 'u') 44 | {.next_ngram = 11, .cumulative_probability = 3}, 45 | // ngram 11 ('u', 'r') 46 | {.next_ngram = 7, .cumulative_probability = 3}, 47 | // ngram 12 ('r', 'm') 48 | {.next_ngram = 0, .cumulative_probability = 5}, 49 | {.next_ngram = 5, .cumulative_probability = 10}, 50 | // ngram 13 ('w', 'n') 51 | {.next_ngram = 14, .cumulative_probability = 5}, 52 | // ngram 14 ('n', 'y') 53 | {.next_ngram = 15, .cumulative_probability = 9}, 54 | // ngram 15 ('y', 'a') 55 | {.next_ngram = 25, .cumulative_probability = 4}, 56 | {.next_ngram = 16, .cumulative_probability = 5}, 57 | {.next_ngram = 17, .cumulative_probability = 6}, 58 | // ngram 16 ('a', 'n') 59 | {.next_ngram = 14, .cumulative_probability = 1}, 60 | // ngram 17 ('a', 'm') 61 | {.next_ngram = 0, .cumulative_probability = 3}, 62 | {.next_ngram = 5, .cumulative_probability = 4}, 63 | // ngram 18 ('w', 'w') 64 | {.next_ngram = 18, .cumulative_probability = 3}, 65 | {.next_ngram = 4, .cumulative_probability = 4}, 66 | // ngram 19 ('r', 'w') 67 | {.next_ngram = 4, .cumulative_probability = 1}, 68 | // ngram 20 ('r', 'e') 69 | {.next_ngram = 21, .cumulative_probability = 1}, 70 | // ngram 21 ('e', 'o') 71 | {.next_ngram = 3, .cumulative_probability = 13}, 72 | // ngram 22 ('r', 'o') 73 | {.next_ngram = 3, .cumulative_probability = 18}, 74 | // ngram 23 ('w', 'r') 75 | {.next_ngram = 12, .cumulative_probability = 7}, 76 | {.next_ngram = 26, .cumulative_probability = 10}, 77 | // ngram 24 ('w', 'p') 78 | {.next_ngram = 10, .cumulative_probability = 2}, 79 | // ngram 25 ('a', 'a') 80 | {.next_ngram = 25, .cumulative_probability = 6}, 81 | {.next_ngram = 17, .cumulative_probability = 9}, 82 | // ngram 26 ('r', 'n') 83 | {.next_ngram = 14, .cumulative_probability = 3}, 84 | }; 85 | 86 | static const uwu_markov_ngram catnonsense_ngrams[] = { 87 | {.choices = 0, .total_probability = 30, .character = 'r'}, // "('m', 'r')" 88 | {.choices = 5, .total_probability = 9, .character = 'a'}, // "('r', 'a')" 89 | {.choices = 6, .total_probability = 9, .character = 'o'}, // "('a', 'o')" 90 | {.choices = 7, .total_probability = 38, .character = 'w'}, // "('o', 'w')" 91 | {.choices = 12, .total_probability = 30, .character = 'm'}, // "('w', 'm')" 92 | {.choices = 14, .total_probability = 20, .character = 'e'}, // "('m', 'e')" 93 | {.choices = 16, .total_probability = 8, .character = 'w'}, // "('e', 'w')" 94 | {.choices = 19, .total_probability = 14, .character = 'r'}, // "('r', 'r')" 95 | {.choices = 23, .total_probability = 1, .character = 'p'}, // "('r', 'p')" 96 | {.choices = 24, .total_probability = 1, .character = 'p'}, // "('p', 'p')" 97 | {.choices = 25, .total_probability = 3, .character = 'u'}, // "('p', 'u')" 98 | {.choices = 26, .total_probability = 3, .character = 'r'}, // "('u', 'r')" 99 | {.choices = 27, .total_probability = 10, .character = 'm'}, // "('r', 'm')" 100 | {.choices = 29, .total_probability = 5, .character = 'n'}, // "('w', 'n')" 101 | {.choices = 30, .total_probability = 9, .character = 'y'}, // "('n', 'y')" 102 | {.choices = 31, .total_probability = 6, .character = 'a'}, // "('y', 'a')" 103 | {.choices = 34, .total_probability = 1, .character = 'n'}, // "('a', 'n')" 104 | {.choices = 35, .total_probability = 4, .character = 'm'}, // "('a', 'm')" 105 | {.choices = 37, .total_probability = 4, .character = 'w'}, // "('w', 'w')" 106 | {.choices = 39, .total_probability = 1, .character = 'w'}, // "('r', 'w')" 107 | {.choices = 40, .total_probability = 1, .character = 'e'}, // "('r', 'e')" 108 | {.choices = 41, .total_probability = 13, .character = 'o'}, // "('e', 'o')" 109 | {.choices = 42, .total_probability = 18, .character = 'o'}, // "('r', 'o')" 110 | {.choices = 43, .total_probability = 10, .character = 'r'}, // "('w', 'r')" 111 | {.choices = 45, .total_probability = 2, .character = 'p'}, // "('w', 'p')" 112 | {.choices = 46, .total_probability = 9, .character = 'a'}, // "('a', 'a')" 113 | {.choices = 48, .total_probability = 3, .character = 'n'}, // "('r', 'n')" 114 | }; 115 | 116 | static const uwu_markov_table catnonsense_table = { 117 | .specials = NULL, 118 | .initial_ngram=0, 119 | .num_ngrams=27, 120 | .choices=catnonsense_choices, 121 | .ngrams=catnonsense_ngrams 122 | }; 123 | 124 | static const uwu_markov_choice keysmash_choices[] = { 125 | // ngram 0 ('a',) 126 | {.next_ngram = 5, .cumulative_probability = 7}, 127 | {.next_ngram = 9, .cumulative_probability = 13}, 128 | {.next_ngram = 6, .cumulative_probability = 18}, 129 | {.next_ngram = 1, .cumulative_probability = 21}, 130 | {.next_ngram = 11, .cumulative_probability = 24}, 131 | {.next_ngram = 8, .cumulative_probability = 26}, 132 | {.next_ngram = 4, .cumulative_probability = 28}, 133 | {.next_ngram = 7, .cumulative_probability = 29}, 134 | {.next_ngram = 12, .cumulative_probability = 30}, 135 | // ngram 1 ('l',) 136 | {.next_ngram = 2, .cumulative_probability = 4}, 137 | {.next_ngram = 7, .cumulative_probability = 6}, 138 | {.next_ngram = 3, .cumulative_probability = 7}, 139 | {.next_ngram = 8, .cumulative_probability = 8}, 140 | {.next_ngram = 6, .cumulative_probability = 9}, 141 | {.next_ngram = 4, .cumulative_probability = 10}, 142 | {.next_ngram = 0, .cumulative_probability = 11}, 143 | // ngram 2 ('k',) 144 | {.next_ngram = 0, .cumulative_probability = 6}, 145 | {.next_ngram = 6, .cumulative_probability = 10}, 146 | {.next_ngram = 8, .cumulative_probability = 13}, 147 | {.next_ngram = 9, .cumulative_probability = 16}, 148 | {.next_ngram = 3, .cumulative_probability = 17}, 149 | {.next_ngram = 4, .cumulative_probability = 18}, 150 | {.next_ngram = 1, .cumulative_probability = 19}, 151 | {.next_ngram = 5, .cumulative_probability = 20}, 152 | // ngram 3 ('s',) 153 | {.next_ngram = 4, .cumulative_probability = 2}, 154 | {.next_ngram = 2, .cumulative_probability = 4}, 155 | // ngram 4 ('d',) 156 | {.next_ngram = 6, .cumulative_probability = 7}, 157 | {.next_ngram = 5, .cumulative_probability = 12}, 158 | {.next_ngram = 3, .cumulative_probability = 13}, 159 | {.next_ngram = 8, .cumulative_probability = 14}, 160 | {.next_ngram = 2, .cumulative_probability = 15}, 161 | {.next_ngram = 9, .cumulative_probability = 16}, 162 | {.next_ngram = 10, .cumulative_probability = 17}, 163 | // ngram 5 ('h',) 164 | {.next_ngram = 8, .cumulative_probability = 7}, 165 | {.next_ngram = 9, .cumulative_probability = 11}, 166 | {.next_ngram = 6, .cumulative_probability = 14}, 167 | {.next_ngram = 2, .cumulative_probability = 17}, 168 | {.next_ngram = 0, .cumulative_probability = 20}, 169 | {.next_ngram = 4, .cumulative_probability = 23}, 170 | {.next_ngram = 13, .cumulative_probability = 25}, 171 | {.next_ngram = 12, .cumulative_probability = 27}, 172 | {.next_ngram = 7, .cumulative_probability = 28}, 173 | {.next_ngram = 14, .cumulative_probability = 29}, 174 | {.next_ngram = 5, .cumulative_probability = 30}, 175 | {.next_ngram = 11, .cumulative_probability = 31}, 176 | // ngram 6 ('f',) 177 | {.next_ngram = 8, .cumulative_probability = 12}, 178 | {.next_ngram = 2, .cumulative_probability = 16}, 179 | {.next_ngram = 9, .cumulative_probability = 19}, 180 | {.next_ngram = 1, .cumulative_probability = 21}, 181 | {.next_ngram = 5, .cumulative_probability = 23}, 182 | {.next_ngram = 4, .cumulative_probability = 25}, 183 | {.next_ngram = 0, .cumulative_probability = 26}, 184 | // ngram 7 (';',) 185 | {.next_ngram = 0, .cumulative_probability = 4}, 186 | {.next_ngram = 2, .cumulative_probability = 5}, 187 | {.next_ngram = 4, .cumulative_probability = 6}, 188 | {.next_ngram = 1, .cumulative_probability = 7}, 189 | {.next_ngram = 5, .cumulative_probability = 8}, 190 | // ngram 8 ('g',) 191 | {.next_ngram = 0, .cumulative_probability = 8}, 192 | {.next_ngram = 5, .cumulative_probability = 14}, 193 | {.next_ngram = 7, .cumulative_probability = 18}, 194 | {.next_ngram = 9, .cumulative_probability = 22}, 195 | {.next_ngram = 1, .cumulative_probability = 25}, 196 | {.next_ngram = 10, .cumulative_probability = 27}, 197 | {.next_ngram = 6, .cumulative_probability = 29}, 198 | {.next_ngram = 4, .cumulative_probability = 30}, 199 | {.next_ngram = 3, .cumulative_probability = 31}, 200 | {.next_ngram = 2, .cumulative_probability = 32}, 201 | {.next_ngram = 11, .cumulative_probability = 33}, 202 | {.next_ngram = 14, .cumulative_probability = 34}, 203 | // ngram 9 ('j',) 204 | {.next_ngram = 5, .cumulative_probability = 5}, 205 | {.next_ngram = 4, .cumulative_probability = 9}, 206 | {.next_ngram = 2, .cumulative_probability = 12}, 207 | {.next_ngram = 6, .cumulative_probability = 15}, 208 | {.next_ngram = 0, .cumulative_probability = 17}, 209 | {.next_ngram = 12, .cumulative_probability = 18}, 210 | {.next_ngram = 15, .cumulative_probability = 19}, 211 | {.next_ngram = 16, .cumulative_probability = 20}, 212 | {.next_ngram = 1, .cumulative_probability = 21}, 213 | {.next_ngram = 8, .cumulative_probability = 22}, 214 | // ngram 10 ('b',) 215 | {.next_ngram = 2, .cumulative_probability = 1}, 216 | {.next_ngram = 0, .cumulative_probability = 2}, 217 | {.next_ngram = 5, .cumulative_probability = 3}, 218 | // ngram 11 ('u',) 219 | {.next_ngram = 12, .cumulative_probability = 3}, 220 | {.next_ngram = 0, .cumulative_probability = 4}, 221 | {.next_ngram = 6, .cumulative_probability = 5}, 222 | {.next_ngram = 9, .cumulative_probability = 6}, 223 | {.next_ngram = 15, .cumulative_probability = 7}, 224 | // ngram 12 ('r',) 225 | {.next_ngram = 8, .cumulative_probability = 4}, 226 | {.next_ngram = 0, .cumulative_probability = 6}, 227 | {.next_ngram = 5, .cumulative_probability = 7}, 228 | // ngram 13 ('i',) 229 | {.next_ngram = 11, .cumulative_probability = 2}, 230 | // ngram 14 ('n',) 231 | {.next_ngram = 8, .cumulative_probability = 1}, 232 | {.next_ngram = 5, .cumulative_probability = 2}, 233 | // ngram 15 ('e',) 234 | {.next_ngram = 8, .cumulative_probability = 2}, 235 | // ngram 16 ('o',) 236 | {.next_ngram = 8, .cumulative_probability = 1}, 237 | }; 238 | 239 | static const uwu_markov_ngram keysmash_ngrams[] = { 240 | {.choices = 0, .total_probability = 30, .character = 'a'}, // "('a',)" 241 | {.choices = 9, .total_probability = 11, .character = 'l'}, // "('l',)" 242 | {.choices = 16, .total_probability = 20, .character = 'k'}, // "('k',)" 243 | {.choices = 24, .total_probability = 4, .character = 's'}, // "('s',)" 244 | {.choices = 26, .total_probability = 17, .character = 'd'}, // "('d',)" 245 | {.choices = 33, .total_probability = 31, .character = 'h'}, // "('h',)" 246 | {.choices = 45, .total_probability = 26, .character = 'f'}, // "('f',)" 247 | {.choices = 52, .total_probability = 8, .character = ';'}, // "(';',)" 248 | {.choices = 57, .total_probability = 34, .character = 'g'}, // "('g',)" 249 | {.choices = 69, .total_probability = 22, .character = 'j'}, // "('j',)" 250 | {.choices = 79, .total_probability = 3, .character = 'b'}, // "('b',)" 251 | {.choices = 82, .total_probability = 7, .character = 'u'}, // "('u',)" 252 | {.choices = 87, .total_probability = 7, .character = 'r'}, // "('r',)" 253 | {.choices = 90, .total_probability = 2, .character = 'i'}, // "('i',)" 254 | {.choices = 91, .total_probability = 2, .character = 'n'}, // "('n',)" 255 | {.choices = 93, .total_probability = 2, .character = 'e'}, // "('e',)" 256 | {.choices = 94, .total_probability = 1, .character = 'o'}, // "('o',)" 257 | }; 258 | 259 | static const uwu_markov_table keysmash_table = { 260 | .specials = NULL, 261 | .initial_ngram=-1, 262 | .num_ngrams=17, 263 | .choices=keysmash_choices, 264 | .ngrams=keysmash_ngrams 265 | }; 266 | 267 | static const uwu_markov_choice scrunkly_choices[] = { 268 | // ngram 0 ('t', 'h') 269 | {.next_ngram = 1, .cumulative_probability = 15}, 270 | {.next_ngram = 67, .cumulative_probability = 16}, 271 | // ngram 1 ('h', 'e') 272 | {.next_ngram = 2, .cumulative_probability = 14}, 273 | {.next_ngram = 12, .cumulative_probability = 16}, 274 | {.next_ngram = 65, .cumulative_probability = 17}, 275 | {.next_ngram = 115, .cumulative_probability = 18}, 276 | // ngram 2 ('e', ' ') 277 | {.next_ngram = 9, .cumulative_probability = 6}, 278 | {.next_ngram = 59, .cumulative_probability = 11}, 279 | {.next_ngram = 3, .cumulative_probability = 15}, 280 | {.next_ngram = 20, .cumulative_probability = 18}, 281 | {.next_ngram = 30, .cumulative_probability = 21}, 282 | {.next_ngram = 71, .cumulative_probability = 24}, 283 | {.next_ngram = 82, .cumulative_probability = 26}, 284 | {.next_ngram = 86, .cumulative_probability = 28}, 285 | {.next_ngram = 138, .cumulative_probability = 29}, 286 | {.next_ngram = 56, .cumulative_probability = 30}, 287 | // ngram 3 (' ', 'l') 288 | {.next_ngram = 4, .cumulative_probability = 8}, 289 | // ngram 4 ('l', 'i') 290 | {.next_ngram = 5, .cumulative_probability = 3}, 291 | {.next_ngram = 107, .cumulative_probability = 6}, 292 | {.next_ngram = 47, .cumulative_probability = 7}, 293 | {.next_ngram = 63, .cumulative_probability = 8}, 294 | {.next_ngram = 102, .cumulative_probability = 9}, 295 | {.next_ngram = 149, .cumulative_probability = 10}, 296 | {.next_ngram = 89, .cumulative_probability = 11}, 297 | // ngram 5 ('i', 't') 298 | {.next_ngram = 6, .cumulative_probability = 3}, 299 | {.next_ngram = 42, .cumulative_probability = 6}, 300 | {.next_ngram = 36, .cumulative_probability = 9}, 301 | {.next_ngram = 118, .cumulative_probability = 12}, 302 | // ngram 6 ('t', 't') 303 | {.next_ngram = 7, .cumulative_probability = 3}, 304 | // ngram 7 ('t', 'l') 305 | {.next_ngram = 8, .cumulative_probability = 5}, 306 | // ngram 8 ('l', 'e') 307 | {.next_ngram = 2, .cumulative_probability = 14}, 308 | {.next_ngram = 65, .cumulative_probability = 16}, 309 | {.next_ngram = 169, .cumulative_probability = 17}, 310 | // ngram 9 (' ', 't') 311 | {.next_ngram = 0, .cumulative_probability = 7}, 312 | {.next_ngram = 10, .cumulative_probability = 11}, 313 | {.next_ngram = 37, .cumulative_probability = 15}, 314 | {.next_ngram = 53, .cumulative_probability = 16}, 315 | // ngram 10 ('t', 'i') 316 | {.next_ngram = 11, .cumulative_probability = 4}, 317 | {.next_ngram = 89, .cumulative_probability = 5}, 318 | // ngram 11 ('i', 'e') 319 | {.next_ngram = 12, .cumulative_probability = 4}, 320 | {.next_ngram = 65, .cumulative_probability = 5}, 321 | // ngram 12 ('e', 'n') 322 | {.next_ngram = 13, .cumulative_probability = 4}, 323 | {.next_ngram = 84, .cumulative_probability = 5}, 324 | {.next_ngram = 62, .cumulative_probability = 6}, 325 | {.next_ngram = 172, .cumulative_probability = 7}, 326 | // ngram 13 ('n', 'p') 327 | {.next_ngram = 14, .cumulative_probability = 4}, 328 | {.next_ngram = 92, .cumulative_probability = 5}, 329 | // ngram 14 ('p', 's') 330 | {.next_ngram = 15, .cumulative_probability = 4}, 331 | // ngram 15 ('s', 'y') 332 | {.next_ngram = 70, .cumulative_probability = 3}, 333 | {.next_ngram = 16, .cumulative_probability = 4}, 334 | // ngram 16 ('y', ) 335 | {.next_ngram = 17, .cumulative_probability = 3}, 336 | {.next_ngram = 85, .cumulative_probability = 6}, 337 | {.next_ngram = 130, .cumulative_probability = 8}, 338 | {.next_ngram = 119, .cumulative_probability = 9}, 339 | // ngram 17 (, 's') 340 | {.next_ngram = 18, .cumulative_probability = 2}, 341 | {.next_ngram = 75, .cumulative_probability = 4}, 342 | {.next_ngram = 98, .cumulative_probability = 5}, 343 | // ngram 18 ('s', 'o') 344 | {.next_ngram = 38, .cumulative_probability = 3}, 345 | {.next_ngram = 19, .cumulative_probability = 5}, 346 | // ngram 19 ('o', ' ') 347 | {.next_ngram = 59, .cumulative_probability = 2}, 348 | {.next_ngram = 20, .cumulative_probability = 3}, 349 | {.next_ngram = 60, .cumulative_probability = 4}, 350 | {.next_ngram = 3, .cumulative_probability = 5}, 351 | {.next_ngram = 86, .cumulative_probability = 6}, 352 | {.next_ngram = 138, .cumulative_probability = 7}, 353 | // ngram 20 (' ', 'a') 354 | {.next_ngram = 27, .cumulative_probability = 6}, 355 | {.next_ngram = 21, .cumulative_probability = 8}, 356 | {.next_ngram = 44, .cumulative_probability = 9}, 357 | // ngram 21 ('a', 'd') 358 | {.next_ngram = 22, .cumulative_probability = 2}, 359 | // ngram 22 ('d', 'o') 360 | {.next_ngram = 146, .cumulative_probability = 3}, 361 | {.next_ngram = 23, .cumulative_probability = 5}, 362 | {.next_ngram = 38, .cumulative_probability = 7}, 363 | {.next_ngram = 50, .cumulative_probability = 8}, 364 | // ngram 23 ('o', 'r') 365 | {.next_ngram = 24, .cumulative_probability = 2}, 366 | // ngram 24 ('r', 'n') 367 | {.next_ngram = 25, .cumulative_probability = 2}, 368 | // ngram 25 ('n', 'a') 369 | {.next_ngram = 26, .cumulative_probability = 2}, 370 | // ngram 26 ('a', 'l') 371 | {.next_ngram = 8, .cumulative_probability = 2}, 372 | // ngram 27 ('a', 'n') 373 | {.next_ngram = 28, .cumulative_probability = 5}, 374 | {.next_ngram = 62, .cumulative_probability = 6}, 375 | {.next_ngram = 154, .cumulative_probability = 7}, 376 | // ngram 28 ('n', 'd') 377 | {.next_ngram = 29, .cumulative_probability = 5}, 378 | // ngram 29 ('d', ' ') 379 | {.next_ngram = 30, .cumulative_probability = 2}, 380 | {.next_ngram = 49, .cumulative_probability = 3}, 381 | {.next_ngram = 60, .cumulative_probability = 4}, 382 | {.next_ngram = 59, .cumulative_probability = 5}, 383 | {.next_ngram = 120, .cumulative_probability = 6}, 384 | // ngram 30 (' ', 'c') 385 | {.next_ngram = 31, .cumulative_probability = 3}, 386 | {.next_ngram = 61, .cumulative_probability = 5}, 387 | {.next_ngram = 76, .cumulative_probability = 6}, 388 | // ngram 31 ('c', 'u') 389 | {.next_ngram = 32, .cumulative_probability = 3}, 390 | // ngram 32 ('u', 't') 391 | {.next_ngram = 33, .cumulative_probability = 3}, 392 | // ngram 33 ('t', 'e') 393 | {.next_ngram = 34, .cumulative_probability = 2}, 394 | {.next_ngram = 65, .cumulative_probability = 3}, 395 | {.next_ngram = 169, .cumulative_probability = 4}, 396 | // ngram 34 ('e', 's') 397 | {.next_ngram = 35, .cumulative_probability = 2}, 398 | // ngram 35 ('s', 't') 399 | {.next_ngram = 36, .cumulative_probability = 2}, 400 | // ngram 36 ('t', ' ') 401 | {.next_ngram = 9, .cumulative_probability = 2}, 402 | {.next_ngram = 20, .cumulative_probability = 4}, 403 | {.next_ngram = 30, .cumulative_probability = 5}, 404 | {.next_ngram = 59, .cumulative_probability = 6}, 405 | // ngram 37 ('t', 'o') 406 | {.next_ngram = 38, .cumulative_probability = 3}, 407 | {.next_ngram = 19, .cumulative_probability = 4}, 408 | // ngram 38 ('o', 'o') 409 | {.next_ngram = 39, .cumulative_probability = 3}, 410 | {.next_ngram = 38, .cumulative_probability = 6}, 411 | {.next_ngram = 19, .cumulative_probability = 9}, 412 | {.next_ngram = 97, .cumulative_probability = 11}, 413 | {.next_ngram = 131, .cumulative_probability = 13}, 414 | {.next_ngram = 156, .cumulative_probability = 14}, 415 | // ngram 39 ('o', 't') 416 | {.next_ngram = 40, .cumulative_probability = 3}, 417 | // ngram 40 ('t', 's') 418 | {.next_ngram = 41, .cumulative_probability = 3}, 419 | // ngram 41 ('s', 'i') 420 | {.next_ngram = 5, .cumulative_probability = 2}, 421 | {.next_ngram = 11, .cumulative_probability = 3}, 422 | // ngram 42 ('t', ) 423 | {.next_ngram = 43, .cumulative_probability = 1}, 424 | {.next_ngram = 114, .cumulative_probability = 2}, 425 | {.next_ngram = 125, .cumulative_probability = 3}, 426 | {.next_ngram = 85, .cumulative_probability = 4}, 427 | // ngram 43 (, 'a') 428 | {.next_ngram = 44, .cumulative_probability = 4}, 429 | // ngram 44 ('a', 'w') 430 | {.next_ngram = 45, .cumulative_probability = 3}, 431 | {.next_ngram = 132, .cumulative_probability = 4}, 432 | {.next_ngram = 46, .cumulative_probability = 5}, 433 | // ngram 45 ('w', 'w') 434 | {.next_ngram = 46, .cumulative_probability = 3}, 435 | {.next_ngram = 45, .cumulative_probability = 5}, 436 | // ngram 46 ('w', ' ') 437 | {.next_ngram = 9, .cumulative_probability = 2}, 438 | {.next_ngram = 3, .cumulative_probability = 3}, 439 | {.next_ngram = 59, .cumulative_probability = 4}, 440 | {.next_ngram = 82, .cumulative_probability = 5}, 441 | {.next_ngram = 60, .cumulative_probability = 6}, 442 | {.next_ngram = 71, .cumulative_probability = 7}, 443 | // ngram 47 ('i', 'k') 444 | {.next_ngram = 48, .cumulative_probability = 1}, 445 | // ngram 48 ('k', 'e') 446 | {.next_ngram = 2, .cumulative_probability = 1}, 447 | // ngram 49 (' ', 'd') 448 | {.next_ngram = 22, .cumulative_probability = 3}, 449 | // ngram 50 ('o', 'u') 450 | {.next_ngram = 51, .cumulative_probability = 1}, 451 | // ngram 51 ('u', 'b') 452 | {.next_ngram = 52, .cumulative_probability = 1}, 453 | // ngram 52 ('b', 'l') 454 | {.next_ngram = 8, .cumulative_probability = 2}, 455 | {.next_ngram = 104, .cumulative_probability = 4}, 456 | {.next_ngram = 4, .cumulative_probability = 6}, 457 | {.next_ngram = 81, .cumulative_probability = 7}, 458 | // ngram 53 ('t', 'a') 459 | {.next_ngram = 54, .cumulative_probability = 1}, 460 | // ngram 54 ('a', 'p') 461 | {.next_ngram = 55, .cumulative_probability = 1}, 462 | {.next_ngram = 68, .cumulative_probability = 2}, 463 | // ngram 55 ('p', ' ') 464 | {.next_ngram = 56, .cumulative_probability = 1}, 465 | // ngram 56 (' ', 'n') 466 | {.next_ngram = 57, .cumulative_probability = 1}, 467 | {.next_ngram = 62, .cumulative_probability = 2}, 468 | // ngram 57 ('n', 'o') 469 | {.next_ngram = 58, .cumulative_probability = 1}, 470 | // ngram 58 ('o', 'w') 471 | {.next_ngram = 46, .cumulative_probability = 3}, 472 | {.next_ngram = 143, .cumulative_probability = 4}, 473 | // ngram 59 (' ', 's') 474 | {.next_ngram = 91, .cumulative_probability = 6}, 475 | {.next_ngram = 75, .cumulative_probability = 10}, 476 | {.next_ngram = 18, .cumulative_probability = 13}, 477 | {.next_ngram = 144, .cumulative_probability = 15}, 478 | // ngram 60 (' ', 'i') 479 | {.next_ngram = 5, .cumulative_probability = 2}, 480 | {.next_ngram = 135, .cumulative_probability = 3}, 481 | // ngram 61 ('c', 'a') 482 | {.next_ngram = 27, .cumulative_probability = 1}, 483 | {.next_ngram = 136, .cumulative_probability = 2}, 484 | {.next_ngram = 137, .cumulative_probability = 3}, 485 | // ngram 62 ('n', ' ') 486 | {.next_ngram = 9, .cumulative_probability = 2}, 487 | {.next_ngram = 120, .cumulative_probability = 3}, 488 | {.next_ngram = 3, .cumulative_probability = 4}, 489 | // ngram 63 ('i', 'v') 490 | {.next_ngram = 64, .cumulative_probability = 1}, 491 | // ngram 64 ('v', 'e') 492 | {.next_ngram = 2, .cumulative_probability = 1}, 493 | // ngram 65 ('e', ) 494 | {.next_ngram = 85, .cumulative_probability = 3}, 495 | {.next_ngram = 95, .cumulative_probability = 5}, 496 | {.next_ngram = 66, .cumulative_probability = 6}, 497 | {.next_ngram = 114, .cumulative_probability = 7}, 498 | // ngram 66 (, 'h') 499 | {.next_ngram = 67, .cumulative_probability = 1}, 500 | // ngram 67 ('h', 'a') 501 | {.next_ngram = 54, .cumulative_probability = 1}, 502 | {.next_ngram = 168, .cumulative_probability = 2}, 503 | // ngram 68 ('p', 'p') 504 | {.next_ngram = 69, .cumulative_probability = 1}, 505 | // ngram 69 ('p', 'y') 506 | {.next_ngram = 70, .cumulative_probability = 1}, 507 | {.next_ngram = 16, .cumulative_probability = 2}, 508 | // ngram 70 ('y', ' ') 509 | {.next_ngram = 59, .cumulative_probability = 4}, 510 | {.next_ngram = 9, .cumulative_probability = 7}, 511 | {.next_ngram = 49, .cumulative_probability = 9}, 512 | {.next_ngram = 20, .cumulative_probability = 11}, 513 | {.next_ngram = 71, .cumulative_probability = 12}, 514 | {.next_ngram = 82, .cumulative_probability = 13}, 515 | {.next_ngram = 86, .cumulative_probability = 14}, 516 | {.next_ngram = 162, .cumulative_probability = 15}, 517 | {.next_ngram = 138, .cumulative_probability = 16}, 518 | // ngram 71 (' ', 'k') 519 | {.next_ngram = 117, .cumulative_probability = 4}, 520 | {.next_ngram = 72, .cumulative_probability = 5}, 521 | // ngram 72 ('k', 'd') 522 | {.next_ngram = 73, .cumulative_probability = 1}, 523 | // ngram 73 ('d', 'b') 524 | {.next_ngram = 74, .cumulative_probability = 1}, 525 | // ngram 74 ('b', ) 526 | {.next_ngram = 43, .cumulative_probability = 1}, 527 | {.next_ngram = 113, .cumulative_probability = 2}, 528 | // ngram 75 ('s', 'c') 529 | {.next_ngram = 76, .cumulative_probability = 6}, 530 | // ngram 76 ('c', 'r') 531 | {.next_ngram = 77, .cumulative_probability = 5}, 532 | {.next_ngram = 96, .cumulative_probability = 9}, 533 | // ngram 77 ('r', 'u') 534 | {.next_ngram = 78, .cumulative_probability = 5}, 535 | // ngram 78 ('u', 'n') 536 | {.next_ngram = 79, .cumulative_probability = 4}, 537 | {.next_ngram = 93, .cumulative_probability = 7}, 538 | {.next_ngram = 123, .cumulative_probability = 8}, 539 | // ngram 79 ('n', 'k') 540 | {.next_ngram = 80, .cumulative_probability = 8}, 541 | {.next_ngram = 90, .cumulative_probability = 11}, 542 | {.next_ngram = 110, .cumulative_probability = 12}, 543 | {.next_ngram = 134, .cumulative_probability = 13}, 544 | // ngram 80 ('k', 'l') 545 | {.next_ngram = 81, .cumulative_probability = 6}, 546 | {.next_ngram = 8, .cumulative_probability = 8}, 547 | // ngram 81 ('l', 'y') 548 | {.next_ngram = 70, .cumulative_probability = 5}, 549 | {.next_ngram = 16, .cumulative_probability = 8}, 550 | // ngram 82 (' ', 'w') 551 | {.next_ngram = 83, .cumulative_probability = 2}, 552 | {.next_ngram = 106, .cumulative_probability = 4}, 553 | // ngram 83 ('w', 'h') 554 | {.next_ngram = 1, .cumulative_probability = 3}, 555 | // ngram 84 ('n', ) 556 | {.next_ngram = 85, .cumulative_probability = 1}, 557 | // ngram 85 (, 't') 558 | {.next_ngram = 0, .cumulative_probability = 8}, 559 | {.next_ngram = 10, .cumulative_probability = 9}, 560 | {.next_ngram = 33, .cumulative_probability = 10}, 561 | // ngram 86 (' ', 'b') 562 | {.next_ngram = 87, .cumulative_probability = 3}, 563 | {.next_ngram = 52, .cumulative_probability = 5}, 564 | {.next_ngram = 152, .cumulative_probability = 6}, 565 | // ngram 87 ('b', 'o') 566 | {.next_ngram = 88, .cumulative_probability = 4}, 567 | // ngram 88 ('o', 'i') 568 | {.next_ngram = 89, .cumulative_probability = 7}, 569 | // ngram 89 ('i', 'n') 570 | {.next_ngram = 79, .cumulative_probability = 8}, 571 | {.next_ngram = 93, .cumulative_probability = 11}, 572 | {.next_ngram = 153, .cumulative_probability = 12}, 573 | {.next_ngram = 13, .cumulative_probability = 13}, 574 | {.next_ngram = 173, .cumulative_probability = 14}, 575 | // ngram 90 ('k', 'y') 576 | {.next_ngram = 70, .cumulative_probability = 3}, 577 | // ngram 91 ('s', 'p') 578 | {.next_ngram = 148, .cumulative_probability = 3}, 579 | {.next_ngram = 92, .cumulative_probability = 5}, 580 | {.next_ngram = 151, .cumulative_probability = 6}, 581 | // ngram 92 ('p', 'u') 582 | {.next_ngram = 78, .cumulative_probability = 2}, 583 | {.next_ngram = 111, .cumulative_probability = 3}, 584 | // ngram 93 ('n', 'g') 585 | {.next_ngram = 133, .cumulative_probability = 4}, 586 | {.next_ngram = 94, .cumulative_probability = 6}, 587 | // ngram 94 ('g', 'e') 588 | {.next_ngram = 65, .cumulative_probability = 2}, 589 | // ngram 95 (, 'c') 590 | {.next_ngram = 76, .cumulative_probability = 2}, 591 | // ngram 96 ('r', 'i') 592 | {.next_ngram = 89, .cumulative_probability = 4}, 593 | {.next_ngram = 102, .cumulative_probability = 6}, 594 | // ngram 97 ('o', ) 595 | {.next_ngram = 17, .cumulative_probability = 2}, 596 | {.next_ngram = 43, .cumulative_probability = 4}, 597 | // ngram 98 ('s', 'h') 598 | {.next_ngram = 99, .cumulative_probability = 1}, 599 | // ngram 99 ('h', 'r') 600 | {.next_ngram = 100, .cumulative_probability = 1}, 601 | // ngram 100 ('r', 'o') 602 | {.next_ngram = 101, .cumulative_probability = 1}, 603 | {.next_ngram = 88, .cumulative_probability = 2}, 604 | // ngram 101 ('o', 'n') 605 | {.next_ngram = 79, .cumulative_probability = 1}, 606 | // ngram 102 ('i', 'm') 607 | {.next_ngram = 103, .cumulative_probability = 2}, 608 | {.next_ngram = 105, .cumulative_probability = 4}, 609 | // ngram 103 ('m', 'b') 610 | {.next_ngram = 52, .cumulative_probability = 2}, 611 | // ngram 104 ('l', 'o') 612 | {.next_ngram = 38, .cumulative_probability = 3}, 613 | {.next_ngram = 97, .cumulative_probability = 4}, 614 | {.next_ngram = 19, .cumulative_probability = 5}, 615 | // ngram 105 ('m', 't') 616 | {.next_ngram = 7, .cumulative_probability = 1}, 617 | {.next_ngram = 42, .cumulative_probability = 2}, 618 | {.next_ngram = 118, .cumulative_probability = 3}, 619 | // ngram 106 ('w', 'i') 620 | {.next_ngram = 107, .cumulative_probability = 3}, 621 | // ngram 107 ('i', 'd') 622 | {.next_ngram = 108, .cumulative_probability = 6}, 623 | // ngram 108 ('d', 'd') 624 | {.next_ngram = 109, .cumulative_probability = 3}, 625 | {.next_ngram = 22, .cumulative_probability = 6}, 626 | // ngram 109 ('d', 'l') 627 | {.next_ngram = 8, .cumulative_probability = 3}, 628 | // ngram 110 ('k', 'u') 629 | {.next_ngram = 111, .cumulative_probability = 1}, 630 | // ngram 111 ('u', 's') 631 | {.next_ngram = 112, .cumulative_probability = 2}, 632 | // ngram 112 ('s', ) 633 | {.next_ngram = 113, .cumulative_probability = 1}, 634 | {.next_ngram = 85, .cumulative_probability = 2}, 635 | // ngram 113 (, 'b') 636 | {.next_ngram = 87, .cumulative_probability = 1}, 637 | {.next_ngram = 164, .cumulative_probability = 2}, 638 | {.next_ngram = 52, .cumulative_probability = 3}, 639 | // ngram 114 (, 'w') 640 | {.next_ngram = 83, .cumulative_probability = 1}, 641 | {.next_ngram = 106, .cumulative_probability = 2}, 642 | // ngram 115 ('e', 'm') 643 | {.next_ngram = 116, .cumulative_probability = 1}, 644 | // ngram 116 ('m', ' ') 645 | {.next_ngram = 9, .cumulative_probability = 1}, 646 | // ngram 117 ('k', 'i') 647 | {.next_ngram = 5, .cumulative_probability = 5}, 648 | {.next_ngram = 102, .cumulative_probability = 6}, 649 | // ngram 118 ('t', 'y') 650 | {.next_ngram = 70, .cumulative_probability = 2}, 651 | {.next_ngram = 16, .cumulative_probability = 3}, 652 | // ngram 119 (, 'n') 653 | {.next_ngram = 62, .cumulative_probability = 1}, 654 | // ngram 120 (' ', 'f') 655 | {.next_ngram = 121, .cumulative_probability = 2}, 656 | // ngram 121 ('f', 'l') 657 | {.next_ngram = 122, .cumulative_probability = 2}, 658 | {.next_ngram = 104, .cumulative_probability = 3}, 659 | // ngram 122 ('l', 'u') 660 | {.next_ngram = 78, .cumulative_probability = 1}, 661 | {.next_ngram = 159, .cumulative_probability = 2}, 662 | // ngram 123 ('n', 'f') 663 | {.next_ngram = 124, .cumulative_probability = 1}, 664 | // ngram 124 ('f', ' ') 665 | {.next_ngram = 20, .cumulative_probability = 1}, 666 | // ngram 125 (, 'i') 667 | {.next_ngram = 126, .cumulative_probability = 1}, 668 | // ngram 126 ('i', ) 669 | {.next_ngram = 127, .cumulative_probability = 1}, 670 | // ngram 127 (, 'y') 671 | {.next_ngram = 128, .cumulative_probability = 1}, 672 | // ngram 128 ('y', 'a') 673 | {.next_ngram = 129, .cumulative_probability = 1}, 674 | // ngram 129 ('a', 'y') 675 | {.next_ngram = 16, .cumulative_probability = 1}, 676 | // ngram 130 (, 'l') 677 | {.next_ngram = 104, .cumulative_probability = 2}, 678 | {.next_ngram = 4, .cumulative_probability = 3}, 679 | // ngram 131 ('o', 'k') 680 | {.next_ngram = 117, .cumulative_probability = 2}, 681 | // ngram 132 ('w', ) 682 | {.next_ngram = 130, .cumulative_probability = 1}, 683 | {.next_ngram = 113, .cumulative_probability = 2}, 684 | // ngram 133 ('g', 'l') 685 | {.next_ngram = 8, .cumulative_probability = 3}, 686 | {.next_ngram = 81, .cumulative_probability = 4}, 687 | // ngram 134 ('k', 'o') 688 | {.next_ngram = 97, .cumulative_probability = 1}, 689 | // ngram 135 ('i', 'c') 690 | {.next_ngram = 61, .cumulative_probability = 1}, 691 | // ngram 136 ('a', 'm') 692 | {.next_ngram = 105, .cumulative_probability = 1}, 693 | // ngram 137 ('a', 't') 694 | {.next_ngram = 36, .cumulative_probability = 1}, 695 | // ngram 138 (' ', 'm') 696 | {.next_ngram = 141, .cumulative_probability = 3}, 697 | {.next_ngram = 139, .cumulative_probability = 4}, 698 | // ngram 139 ('m', 'i') 699 | {.next_ngram = 140, .cumulative_probability = 1}, 700 | // ngram 140 ('i', 'p') 701 | {.next_ngram = 69, .cumulative_probability = 1}, 702 | // ngram 141 ('m', 'e') 703 | {.next_ngram = 142, .cumulative_probability = 3}, 704 | {.next_ngram = 163, .cumulative_probability = 5}, 705 | // ngram 142 ('e', 'o') 706 | {.next_ngram = 58, .cumulative_probability = 3}, 707 | // ngram 143 ('w', 'm') 708 | {.next_ngram = 141, .cumulative_probability = 2}, 709 | // ngram 144 ('s', 'm') 710 | {.next_ngram = 145, .cumulative_probability = 2}, 711 | // ngram 145 ('m', 'o') 712 | {.next_ngram = 146, .cumulative_probability = 2}, 713 | // ngram 146 ('o', 'l') 714 | {.next_ngram = 147, .cumulative_probability = 4}, 715 | {.next_ngram = 171, .cumulative_probability = 5}, 716 | // ngram 147 ('l', ' ') 717 | {.next_ngram = 59, .cumulative_probability = 1}, 718 | {.next_ngram = 86, .cumulative_probability = 2}, 719 | {.next_ngram = 138, .cumulative_probability = 3}, 720 | {.next_ngram = 3, .cumulative_probability = 4}, 721 | // ngram 148 ('p', 'r') 722 | {.next_ngram = 96, .cumulative_probability = 2}, 723 | {.next_ngram = 100, .cumulative_probability = 3}, 724 | // ngram 149 ('i', 'b') 725 | {.next_ngram = 150, .cumulative_probability = 1}, 726 | // ngram 150 ('b', 'b') 727 | {.next_ngram = 52, .cumulative_probability = 1}, 728 | // ngram 151 ('p', 'o') 729 | {.next_ngram = 88, .cumulative_probability = 2}, 730 | // ngram 152 ('b', 'i') 731 | {.next_ngram = 89, .cumulative_probability = 1}, 732 | // ngram 153 ('n', 't') 733 | {.next_ngram = 7, .cumulative_probability = 1}, 734 | // ngram 154 ('n', 'm') 735 | {.next_ngram = 155, .cumulative_probability = 1}, 736 | // ngram 155 ('m', 'd') 737 | {.next_ngram = 29, .cumulative_probability = 1}, 738 | // ngram 156 ('o', 'f') 739 | {.next_ngram = 157, .cumulative_probability = 1}, 740 | // ngram 157 ('f', ) 741 | {.next_ngram = 158, .cumulative_probability = 1}, 742 | // ngram 158 (, 'f') 743 | {.next_ngram = 121, .cumulative_probability = 1}, 744 | // ngram 159 ('u', 'm') 745 | {.next_ngram = 160, .cumulative_probability = 1}, 746 | // ngram 160 ('m', 'f') 747 | {.next_ngram = 161, .cumulative_probability = 1}, 748 | // ngram 161 ('f', 'y') 749 | {.next_ngram = 16, .cumulative_probability = 1}, 750 | // ngram 162 (' ', 'p') 751 | {.next_ngram = 151, .cumulative_probability = 1}, 752 | // ngram 163 ('e', 'w') 753 | {.next_ngram = 143, .cumulative_probability = 1}, 754 | {.next_ngram = 132, .cumulative_probability = 2}, 755 | // ngram 164 ('b', 'a') 756 | {.next_ngram = 165, .cumulative_probability = 1}, 757 | // ngram 165 ('a', 'b') 758 | {.next_ngram = 166, .cumulative_probability = 1}, 759 | // ngram 166 ('b', 'e') 760 | {.next_ngram = 167, .cumulative_probability = 1}, 761 | // ngram 167 ('e', 'y') 762 | {.next_ngram = 16, .cumulative_probability = 1}, 763 | {.next_ngram = 70, .cumulative_probability = 2}, 764 | // ngram 168 ('a', ' ') 765 | {.next_ngram = 86, .cumulative_probability = 1}, 766 | // ngram 169 ('e', 'e') 767 | {.next_ngram = 170, .cumulative_probability = 1}, 768 | {.next_ngram = 12, .cumulative_probability = 2}, 769 | // ngram 170 ('e', 'b') 770 | {.next_ngram = 74, .cumulative_probability = 1}, 771 | // ngram 171 ('l', ) 772 | {.next_ngram = 85, .cumulative_probability = 1}, 773 | // ngram 172 ('n', 'y') 774 | {.next_ngram = 70, .cumulative_probability = 1}, 775 | // ngram 173 ('n', 'e') 776 | {.next_ngram = 167, .cumulative_probability = 1}, 777 | }; 778 | 779 | static const uwu_markov_ngram scrunkly_ngrams[] = { 780 | {.choices = 0, .total_probability = 16, .character = 'h'}, // "('t', 'h')" 781 | {.choices = 2, .total_probability = 18, .character = 'e'}, // "('h', 'e')" 782 | {.choices = 6, .total_probability = 30, .character = ' '}, // "('e', ' ')" 783 | {.choices = 16, .total_probability = 8, .character = 'l'}, // "(' ', 'l')" 784 | {.choices = 17, .total_probability = 11, .character = 'i'}, // "('l', 'i')" 785 | {.choices = 24, .total_probability = 12, .character = 't'}, // "('i', 't')" 786 | {.choices = 28, .total_probability = 3, .character = 't'}, // "('t', 't')" 787 | {.choices = 29, .total_probability = 5, .character = 'l'}, // "('t', 'l')" 788 | {.choices = 30, .total_probability = 17, .character = 'e'}, // "('l', 'e')" 789 | {.choices = 33, .total_probability = 16, .character = 't'}, // "(' ', 't')" 790 | {.choices = 37, .total_probability = 5, .character = 'i'}, // "('t', 'i')" 791 | {.choices = 39, .total_probability = 5, .character = 'e'}, // "('i', 'e')" 792 | {.choices = 41, .total_probability = 7, .character = 'n'}, // "('e', 'n')" 793 | {.choices = 45, .total_probability = 5, .character = 'p'}, // "('n', 'p')" 794 | {.choices = 47, .total_probability = 4, .character = 's'}, // "('p', 's')" 795 | {.choices = 48, .total_probability = 4, .character = 'y'}, // "('s', 'y')" 796 | {.choices = 50, .total_probability = 9, .character = -1}, // "('y', )" 797 | {.choices = 54, .total_probability = 5, .character = 's'}, // "(, 's')" 798 | {.choices = 57, .total_probability = 5, .character = 'o'}, // "('s', 'o')" 799 | {.choices = 59, .total_probability = 7, .character = ' '}, // "('o', ' ')" 800 | {.choices = 65, .total_probability = 9, .character = 'a'}, // "(' ', 'a')" 801 | {.choices = 68, .total_probability = 2, .character = 'd'}, // "('a', 'd')" 802 | {.choices = 69, .total_probability = 8, .character = 'o'}, // "('d', 'o')" 803 | {.choices = 73, .total_probability = 2, .character = 'r'}, // "('o', 'r')" 804 | {.choices = 74, .total_probability = 2, .character = 'n'}, // "('r', 'n')" 805 | {.choices = 75, .total_probability = 2, .character = 'a'}, // "('n', 'a')" 806 | {.choices = 76, .total_probability = 2, .character = 'l'}, // "('a', 'l')" 807 | {.choices = 77, .total_probability = 7, .character = 'n'}, // "('a', 'n')" 808 | {.choices = 80, .total_probability = 5, .character = 'd'}, // "('n', 'd')" 809 | {.choices = 81, .total_probability = 6, .character = ' '}, // "('d', ' ')" 810 | {.choices = 86, .total_probability = 6, .character = 'c'}, // "(' ', 'c')" 811 | {.choices = 89, .total_probability = 3, .character = 'u'}, // "('c', 'u')" 812 | {.choices = 90, .total_probability = 3, .character = 't'}, // "('u', 't')" 813 | {.choices = 91, .total_probability = 4, .character = 'e'}, // "('t', 'e')" 814 | {.choices = 94, .total_probability = 2, .character = 's'}, // "('e', 's')" 815 | {.choices = 95, .total_probability = 2, .character = 't'}, // "('s', 't')" 816 | {.choices = 96, .total_probability = 6, .character = ' '}, // "('t', ' ')" 817 | {.choices = 100, .total_probability = 4, .character = 'o'}, // "('t', 'o')" 818 | {.choices = 102, .total_probability = 14, .character = 'o'}, // "('o', 'o')" 819 | {.choices = 108, .total_probability = 3, .character = 't'}, // "('o', 't')" 820 | {.choices = 109, .total_probability = 3, .character = 's'}, // "('t', 's')" 821 | {.choices = 110, .total_probability = 3, .character = 'i'}, // "('s', 'i')" 822 | {.choices = 112, .total_probability = 4, .character = -1}, // "('t', )" 823 | {.choices = 116, .total_probability = 4, .character = 'a'}, // "(, 'a')" 824 | {.choices = 117, .total_probability = 5, .character = 'w'}, // "('a', 'w')" 825 | {.choices = 120, .total_probability = 5, .character = 'w'}, // "('w', 'w')" 826 | {.choices = 122, .total_probability = 7, .character = ' '}, // "('w', ' ')" 827 | {.choices = 128, .total_probability = 1, .character = 'k'}, // "('i', 'k')" 828 | {.choices = 129, .total_probability = 1, .character = 'e'}, // "('k', 'e')" 829 | {.choices = 130, .total_probability = 3, .character = 'd'}, // "(' ', 'd')" 830 | {.choices = 131, .total_probability = 1, .character = 'u'}, // "('o', 'u')" 831 | {.choices = 132, .total_probability = 1, .character = 'b'}, // "('u', 'b')" 832 | {.choices = 133, .total_probability = 7, .character = 'l'}, // "('b', 'l')" 833 | {.choices = 137, .total_probability = 1, .character = 'a'}, // "('t', 'a')" 834 | {.choices = 138, .total_probability = 2, .character = 'p'}, // "('a', 'p')" 835 | {.choices = 140, .total_probability = 1, .character = ' '}, // "('p', ' ')" 836 | {.choices = 141, .total_probability = 2, .character = 'n'}, // "(' ', 'n')" 837 | {.choices = 143, .total_probability = 1, .character = 'o'}, // "('n', 'o')" 838 | {.choices = 144, .total_probability = 4, .character = 'w'}, // "('o', 'w')" 839 | {.choices = 146, .total_probability = 15, .character = 's'}, // "(' ', 's')" 840 | {.choices = 150, .total_probability = 3, .character = 'i'}, // "(' ', 'i')" 841 | {.choices = 152, .total_probability = 3, .character = 'a'}, // "('c', 'a')" 842 | {.choices = 155, .total_probability = 4, .character = ' '}, // "('n', ' ')" 843 | {.choices = 158, .total_probability = 1, .character = 'v'}, // "('i', 'v')" 844 | {.choices = 159, .total_probability = 1, .character = 'e'}, // "('v', 'e')" 845 | {.choices = 160, .total_probability = 7, .character = -1}, // "('e', )" 846 | {.choices = 164, .total_probability = 1, .character = 'h'}, // "(, 'h')" 847 | {.choices = 165, .total_probability = 2, .character = 'a'}, // "('h', 'a')" 848 | {.choices = 167, .total_probability = 1, .character = 'p'}, // "('p', 'p')" 849 | {.choices = 168, .total_probability = 2, .character = 'y'}, // "('p', 'y')" 850 | {.choices = 170, .total_probability = 16, .character = ' '}, // "('y', ' ')" 851 | {.choices = 179, .total_probability = 5, .character = 'k'}, // "(' ', 'k')" 852 | {.choices = 181, .total_probability = 1, .character = 'd'}, // "('k', 'd')" 853 | {.choices = 182, .total_probability = 1, .character = 'b'}, // "('d', 'b')" 854 | {.choices = 183, .total_probability = 2, .character = -1}, // "('b', )" 855 | {.choices = 185, .total_probability = 6, .character = 'c'}, // "('s', 'c')" 856 | {.choices = 186, .total_probability = 9, .character = 'r'}, // "('c', 'r')" 857 | {.choices = 188, .total_probability = 5, .character = 'u'}, // "('r', 'u')" 858 | {.choices = 189, .total_probability = 8, .character = 'n'}, // "('u', 'n')" 859 | {.choices = 192, .total_probability = 13, .character = 'k'}, // "('n', 'k')" 860 | {.choices = 196, .total_probability = 8, .character = 'l'}, // "('k', 'l')" 861 | {.choices = 198, .total_probability = 8, .character = 'y'}, // "('l', 'y')" 862 | {.choices = 200, .total_probability = 4, .character = 'w'}, // "(' ', 'w')" 863 | {.choices = 202, .total_probability = 3, .character = 'h'}, // "('w', 'h')" 864 | {.choices = 203, .total_probability = 1, .character = -1}, // "('n', )" 865 | {.choices = 204, .total_probability = 10, .character = 't'}, // "(, 't')" 866 | {.choices = 207, .total_probability = 6, .character = 'b'}, // "(' ', 'b')" 867 | {.choices = 210, .total_probability = 4, .character = 'o'}, // "('b', 'o')" 868 | {.choices = 211, .total_probability = 7, .character = 'i'}, // "('o', 'i')" 869 | {.choices = 212, .total_probability = 14, .character = 'n'}, // "('i', 'n')" 870 | {.choices = 217, .total_probability = 3, .character = 'y'}, // "('k', 'y')" 871 | {.choices = 218, .total_probability = 6, .character = 'p'}, // "('s', 'p')" 872 | {.choices = 221, .total_probability = 3, .character = 'u'}, // "('p', 'u')" 873 | {.choices = 223, .total_probability = 6, .character = 'g'}, // "('n', 'g')" 874 | {.choices = 225, .total_probability = 2, .character = 'e'}, // "('g', 'e')" 875 | {.choices = 226, .total_probability = 2, .character = 'c'}, // "(, 'c')" 876 | {.choices = 227, .total_probability = 6, .character = 'i'}, // "('r', 'i')" 877 | {.choices = 229, .total_probability = 4, .character = -1}, // "('o', )" 878 | {.choices = 231, .total_probability = 1, .character = 'h'}, // "('s', 'h')" 879 | {.choices = 232, .total_probability = 1, .character = 'r'}, // "('h', 'r')" 880 | {.choices = 233, .total_probability = 2, .character = 'o'}, // "('r', 'o')" 881 | {.choices = 235, .total_probability = 1, .character = 'n'}, // "('o', 'n')" 882 | {.choices = 236, .total_probability = 4, .character = 'm'}, // "('i', 'm')" 883 | {.choices = 238, .total_probability = 2, .character = 'b'}, // "('m', 'b')" 884 | {.choices = 239, .total_probability = 5, .character = 'o'}, // "('l', 'o')" 885 | {.choices = 242, .total_probability = 3, .character = 't'}, // "('m', 't')" 886 | {.choices = 245, .total_probability = 3, .character = 'i'}, // "('w', 'i')" 887 | {.choices = 246, .total_probability = 6, .character = 'd'}, // "('i', 'd')" 888 | {.choices = 247, .total_probability = 6, .character = 'd'}, // "('d', 'd')" 889 | {.choices = 249, .total_probability = 3, .character = 'l'}, // "('d', 'l')" 890 | {.choices = 250, .total_probability = 1, .character = 'u'}, // "('k', 'u')" 891 | {.choices = 251, .total_probability = 2, .character = 's'}, // "('u', 's')" 892 | {.choices = 252, .total_probability = 2, .character = -1}, // "('s', )" 893 | {.choices = 254, .total_probability = 3, .character = 'b'}, // "(, 'b')" 894 | {.choices = 257, .total_probability = 2, .character = 'w'}, // "(, 'w')" 895 | {.choices = 259, .total_probability = 1, .character = 'm'}, // "('e', 'm')" 896 | {.choices = 260, .total_probability = 1, .character = ' '}, // "('m', ' ')" 897 | {.choices = 261, .total_probability = 6, .character = 'i'}, // "('k', 'i')" 898 | {.choices = 263, .total_probability = 3, .character = 'y'}, // "('t', 'y')" 899 | {.choices = 265, .total_probability = 1, .character = 'n'}, // "(, 'n')" 900 | {.choices = 266, .total_probability = 2, .character = 'f'}, // "(' ', 'f')" 901 | {.choices = 267, .total_probability = 3, .character = 'l'}, // "('f', 'l')" 902 | {.choices = 269, .total_probability = 2, .character = 'u'}, // "('l', 'u')" 903 | {.choices = 271, .total_probability = 1, .character = 'f'}, // "('n', 'f')" 904 | {.choices = 272, .total_probability = 1, .character = ' '}, // "('f', ' ')" 905 | {.choices = 273, .total_probability = 1, .character = 'i'}, // "(, 'i')" 906 | {.choices = 274, .total_probability = 1, .character = -1}, // "('i', )" 907 | {.choices = 275, .total_probability = 1, .character = 'y'}, // "(, 'y')" 908 | {.choices = 276, .total_probability = 1, .character = 'a'}, // "('y', 'a')" 909 | {.choices = 277, .total_probability = 1, .character = 'y'}, // "('a', 'y')" 910 | {.choices = 278, .total_probability = 3, .character = 'l'}, // "(, 'l')" 911 | {.choices = 280, .total_probability = 2, .character = 'k'}, // "('o', 'k')" 912 | {.choices = 281, .total_probability = 2, .character = -1}, // "('w', )" 913 | {.choices = 283, .total_probability = 4, .character = 'l'}, // "('g', 'l')" 914 | {.choices = 285, .total_probability = 1, .character = 'o'}, // "('k', 'o')" 915 | {.choices = 286, .total_probability = 1, .character = 'c'}, // "('i', 'c')" 916 | {.choices = 287, .total_probability = 1, .character = 'm'}, // "('a', 'm')" 917 | {.choices = 288, .total_probability = 1, .character = 't'}, // "('a', 't')" 918 | {.choices = 289, .total_probability = 4, .character = 'm'}, // "(' ', 'm')" 919 | {.choices = 291, .total_probability = 1, .character = 'i'}, // "('m', 'i')" 920 | {.choices = 292, .total_probability = 1, .character = 'p'}, // "('i', 'p')" 921 | {.choices = 293, .total_probability = 5, .character = 'e'}, // "('m', 'e')" 922 | {.choices = 295, .total_probability = 3, .character = 'o'}, // "('e', 'o')" 923 | {.choices = 296, .total_probability = 2, .character = 'm'}, // "('w', 'm')" 924 | {.choices = 297, .total_probability = 2, .character = 'm'}, // "('s', 'm')" 925 | {.choices = 298, .total_probability = 2, .character = 'o'}, // "('m', 'o')" 926 | {.choices = 299, .total_probability = 5, .character = 'l'}, // "('o', 'l')" 927 | {.choices = 301, .total_probability = 4, .character = ' '}, // "('l', ' ')" 928 | {.choices = 305, .total_probability = 3, .character = 'r'}, // "('p', 'r')" 929 | {.choices = 307, .total_probability = 1, .character = 'b'}, // "('i', 'b')" 930 | {.choices = 308, .total_probability = 1, .character = 'b'}, // "('b', 'b')" 931 | {.choices = 309, .total_probability = 2, .character = 'o'}, // "('p', 'o')" 932 | {.choices = 310, .total_probability = 1, .character = 'i'}, // "('b', 'i')" 933 | {.choices = 311, .total_probability = 1, .character = 't'}, // "('n', 't')" 934 | {.choices = 312, .total_probability = 1, .character = 'm'}, // "('n', 'm')" 935 | {.choices = 313, .total_probability = 1, .character = 'd'}, // "('m', 'd')" 936 | {.choices = 314, .total_probability = 1, .character = 'f'}, // "('o', 'f')" 937 | {.choices = 315, .total_probability = 1, .character = -1}, // "('f', )" 938 | {.choices = 316, .total_probability = 1, .character = 'f'}, // "(, 'f')" 939 | {.choices = 317, .total_probability = 1, .character = 'm'}, // "('u', 'm')" 940 | {.choices = 318, .total_probability = 1, .character = 'f'}, // "('m', 'f')" 941 | {.choices = 319, .total_probability = 1, .character = 'y'}, // "('f', 'y')" 942 | {.choices = 320, .total_probability = 1, .character = 'p'}, // "(' ', 'p')" 943 | {.choices = 321, .total_probability = 2, .character = 'w'}, // "('e', 'w')" 944 | {.choices = 323, .total_probability = 1, .character = 'a'}, // "('b', 'a')" 945 | {.choices = 324, .total_probability = 1, .character = 'b'}, // "('a', 'b')" 946 | {.choices = 325, .total_probability = 1, .character = 'e'}, // "('b', 'e')" 947 | {.choices = 326, .total_probability = 2, .character = 'y'}, // "('e', 'y')" 948 | {.choices = 328, .total_probability = 1, .character = ' '}, // "('a', ' ')" 949 | {.choices = 329, .total_probability = 2, .character = 'e'}, // "('e', 'e')" 950 | {.choices = 331, .total_probability = 1, .character = 'b'}, // "('e', 'b')" 951 | {.choices = 332, .total_probability = 1, .character = -1}, // "('l', )" 952 | {.choices = 333, .total_probability = 1, .character = 'y'}, // "('n', 'y')" 953 | {.choices = 334, .total_probability = 1, .character = 'e'}, // "('n', 'e')" 954 | }; 955 | 956 | static const uwu_markov_table scrunkly_table = { 957 | .specials = scrunkly_specials, 958 | .initial_ngram=44, 959 | .num_ngrams=174, 960 | .choices=scrunkly_choices, 961 | .ngrams=scrunkly_ngrams 962 | }; 963 | 964 | #endif 965 | -------------------------------------------------------------------------------- /uwurandom_markov_special.h: -------------------------------------------------------------------------------- 1 | #include "uwurandom_types.h" 2 | #include "uwurandom_core.h" 3 | 4 | static void scrunkly_punctuation(uwu_state* state) { 5 | uwu_random_number random = uwu_random_int(state) % 3; 6 | 7 | switch (random) { 8 | case 0: 9 | uwu_push_op(state, CREATE_PRINT_STRING("! ")); 10 | break; 11 | case 1: 12 | case 2: { 13 | char punctuation = random == 1 ? '.' : ','; 14 | uwu_random_number repeats = (uwu_random_int(state) % 5) + 1; 15 | 16 | // randomly decide whether or not to add a space 17 | if (repeats == 1 || uwu_random_int(state) % 2 == 0) { 18 | uwu_push_op(state, CREATE_PRINT_STRING(" ")); 19 | } 20 | 21 | uwu_push_op(state, CREATE_REPEAT_CHARACTER(punctuation, repeats)); 22 | break; 23 | } 24 | } 25 | } 26 | 27 | static uwu_op_factory* scrunkly_specials[] = { 28 | scrunkly_punctuation 29 | }; 30 | -------------------------------------------------------------------------------- /uwurandom_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef _UWURANDOM_OPS_H 2 | #define _UWURANDOM_OPS_H 3 | 4 | #include "uwurandom_platform.h" 5 | #include "uwurandom_types.h" 6 | #include "uwurandom_markov_data.h" 7 | #include "uwurandom_core.h" 8 | 9 | static string_with_len actions[] = { 10 | STRING_WITH_LEN("*tilts head*"), 11 | STRING_WITH_LEN("*twitches ears slightly*"), 12 | STRING_WITH_LEN("*purrs*"), 13 | STRING_WITH_LEN("*falls asleep*"), 14 | STRING_WITH_LEN("*sits on ur keyboard*"), 15 | STRING_WITH_LEN("*nuzzles*"), 16 | STRING_WITH_LEN("*stares at u*"), 17 | STRING_WITH_LEN("*points towards case of monster zero ultra*"), 18 | STRING_WITH_LEN("*sneezes*"), 19 | STRING_WITH_LEN("*plays with yarn*"), 20 | STRING_WITH_LEN("*eats all ur doritos*"), 21 | STRING_WITH_LEN("*lies down on a random surface*"), 22 | STRING_WITH_LEN("*rolls around on the floor*"), 23 | STRING_WITH_LEN("*spins around*"), 24 | STRING_WITH_LEN("*tugs on ur sleeve*"), 25 | STRING_WITH_LEN("*jumps a little*"), 26 | STRING_WITH_LEN("*yawns*") 27 | }; 28 | 29 | static void uwu_op_uwu(uwu_state* state) { 30 | uwu_push_op(state, CREATE_PRINT_STRING("uwu")); 31 | } 32 | static void uwu_op_catgirl_nonsense(uwu_state* state) { 33 | uwu_random_number len = (uwu_random_int(state) % 125) + 25; 34 | uwu_push_op(state, CREATE_PRINT_STRING("nya")); 35 | uwu_push_op(state, CREATE_MARKOV(catnonsense_table, catnonsense_table.initial_ngram, len)); 36 | uwu_push_op(state, CREATE_PRINT_STRING("mr")); 37 | } 38 | static void uwu_op_nya(uwu_state* state) { 39 | uwu_random_number repeats = (uwu_random_int(state) % 7) + 1; 40 | uwu_push_op(state, CREATE_REPEAT_CHARACTER('a', repeats)); 41 | uwu_push_op(state, CREATE_PRINT_STRING("ny")); 42 | } 43 | static void uwu_op_blush(uwu_state* state) { 44 | uwu_random_number repeats = (uwu_random_int(state) % 4) + 3; 45 | uwu_push_op(state, CREATE_PRINT_STRING("<")); 46 | uwu_push_op(state, CREATE_REPEAT_CHARACTER('/', repeats)); 47 | uwu_push_op(state, CREATE_PRINT_STRING(">")); 48 | } 49 | static void uwu_op_smiley(uwu_state* state) { 50 | if (uwu_random_int(state) % 100 == 0) { 51 | uwu_push_op(state, CREATE_PRINT_STRING("c")); 52 | } 53 | uwu_push_op(state, CREATE_PRINT_STRING(":3")); 54 | } 55 | static void uwu_op_actions(uwu_state* state) { 56 | string_with_len action = actions[uwu_random_int(state) % ARRAY_SIZE(actions)]; 57 | uwu_push_op(state, (uwu_op){ 58 | .opcode = UWU_PRINT_STRING, 59 | .state = { 60 | .print_string = { 61 | .string = action.string, 62 | .remaining_chars = action.len 63 | } 64 | } 65 | }); 66 | } 67 | static void uwu_op_keyboard_mash(uwu_state* state) { 68 | uwu_random_number len = (uwu_random_int(state) % 125) + 25; 69 | uwu_random_number start_ngram = uwu_random_int(state) % keysmash_table.num_ngrams; 70 | uwu_push_op(state, CREATE_MARKOV(keysmash_table, start_ngram, len)); 71 | } 72 | static void uwu_op_screaming(uwu_state* state) { 73 | uwu_random_number repeats = (uwu_random_int(state) % 12) + 5; 74 | uwu_push_op(state, CREATE_REPEAT_CHARACTER('A', repeats)); 75 | } 76 | static void uwu_op_scrunkly(uwu_state* state) { 77 | uwu_random_number len = (uwu_random_int(state) % 75) + 25; 78 | uwu_push_op(state, CREATE_MARKOV(scrunkly_table, scrunkly_table.initial_ngram, len)); 79 | uwu_push_op(state, CREATE_PRINT_STRING("aw")); 80 | } 81 | static void uwu_op_owo(uwu_state* state) { 82 | uwu_push_op(state, CREATE_PRINT_STRING("owo")); 83 | } 84 | static void uwu_op_uweh(uwu_state* state) { 85 | uwu_random_number repeats = (uwu_random_int(state) % 5) + 3; 86 | uwu_push_op(state, CREATE_REPEAT_CHARACTER('h', repeats)); 87 | uwu_push_op(state, CREATE_PRINT_STRING("uwe")); 88 | } 89 | 90 | static uwu_op_factory* uwu_op_table_default[] = { 91 | uwu_op_uwu, 92 | uwu_op_catgirl_nonsense, 93 | uwu_op_nya, 94 | uwu_op_blush, 95 | uwu_op_smiley, 96 | uwu_op_actions, 97 | uwu_op_keyboard_mash, 98 | uwu_op_screaming, 99 | uwu_op_scrunkly, 100 | uwu_op_owo, 101 | uwu_op_uweh 102 | }; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /uwurandom_platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _UWURANDOM_PLATFORM_H 2 | #define _UWURANDOM_PLATFORM_H 3 | 4 | #ifdef __KERNEL__ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #else 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #endif // __KERNEL__ 18 | 19 | #include "uwurandom_types.h" 20 | 21 | #ifdef __KERNEL__ 22 | 23 | #define RAND_SIZE 128 24 | 25 | static int uwu_init_rng(uwu_state* state) { 26 | uwu_random_number* rng_buf = kmalloc(RAND_SIZE * sizeof(uwu_random_number), GFP_KERNEL); 27 | 28 | if (rng_buf == NULL) { 29 | return -ENOMEM; 30 | } 31 | 32 | state->rng_buf = rng_buf; 33 | 34 | // mark the offset into rng_buf as just past the end of the buffer, 35 | // meaning we'll regenerate the buffer the first time we ask for random bytes 36 | state->rng_idx = RAND_SIZE; 37 | 38 | return 0; 39 | } 40 | 41 | static void uwu_destroy_rng(uwu_state* state) { 42 | if (state->rng_buf) { 43 | kfree(state->rng_buf); 44 | state->rng_buf = NULL; 45 | } 46 | } 47 | 48 | static uwu_random_number uwu_random_int(uwu_state* state) { 49 | if (state->rng_idx >= RAND_SIZE) { 50 | get_random_bytes(state->rng_buf, RAND_SIZE * sizeof(uwu_random_number)); 51 | state->rng_idx = 0; 52 | } 53 | uwu_random_number rand_value = state->rng_buf[state->rng_idx]; 54 | state->rng_idx++; 55 | return rand_value; 56 | } 57 | 58 | #define COPY_STR(dst, src, len) do {\ 59 | int result = copy_to_user((dst), (src), (len));\ 60 | if (result) {\ 61 | return -EFAULT;\ 62 | }\ 63 | } while (0) 64 | 65 | #define COPY_CHAR(value, dst) do {\ 66 | int result = put_user((value), (dst));\ 67 | if (result) {\ 68 | return result;\ 69 | }\ 70 | } while (0) 71 | 72 | #else 73 | 74 | #include 75 | #include 76 | 77 | const size_t RAND_SIZE = 128; 78 | 79 | static int uwu_init_rng(uwu_state* state) { 80 | uwu_random_number* rng_buf = malloc(RAND_SIZE * sizeof(uwu_random_number)); 81 | 82 | if (rng_buf == NULL) { 83 | return -ENOMEM; 84 | } 85 | 86 | state->rng_buf = rng_buf; 87 | 88 | // mark the offset into rng_buf as just past the end of the buffer, 89 | // meaning we'll regenerate the buffer the first time we ask for random bytes 90 | state->rng_idx = RAND_SIZE; 91 | 92 | return 0; 93 | } 94 | 95 | static void uwu_destroy_rng(uwu_state* state) { 96 | if (state->rng_buf) { 97 | free(state->rng_buf); 98 | state->rng_buf = NULL; 99 | } 100 | } 101 | 102 | static uwu_random_number uwu_random_int(uwu_state* state) { 103 | if (state->rng_idx >= RAND_SIZE) { 104 | getrandom(state->rng_buf, RAND_SIZE * sizeof(uwu_random_number), 0); 105 | state->rng_idx = 0; 106 | } 107 | uwu_random_number rand_value = state->rng_buf[state->rng_idx]; 108 | state->rng_idx++; 109 | return rand_value; 110 | } 111 | 112 | #define COPY_STR(dst, src, len) do {\ 113 | memcpy((dst), (src), (len));\ 114 | } while (0) 115 | 116 | #define COPY_CHAR(value, dst) do {\ 117 | *(dst) = (value);\ 118 | } while (0) 119 | 120 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 121 | 122 | #endif // __KERNEL__ 123 | 124 | #endif // _UWURANDOM_PLATFORM_H 125 | -------------------------------------------------------------------------------- /uwurandom_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _UWURANDOM_TYPES_H 2 | #define _UWURANDOM_TYPES_H 3 | 4 | #ifdef __KERNEL__ 5 | #include 6 | 7 | #else 8 | #include 9 | #include 10 | #include 11 | #endif 12 | 13 | typedef uint32_t uwu_random_number; 14 | 15 | typedef struct uwu_markov_choice uwu_markov_choice; 16 | struct uwu_markov_choice { 17 | uint16_t next_ngram; 18 | uint16_t cumulative_probability; 19 | }; 20 | 21 | typedef struct { 22 | uint16_t choices; 23 | uint16_t total_probability; 24 | char character; 25 | } uwu_markov_ngram; 26 | 27 | typedef struct uwu_state uwu_state; 28 | typedef void uwu_op_factory(uwu_state* state); 29 | 30 | typedef struct { 31 | uwu_op_factory** specials; 32 | int32_t initial_ngram; 33 | uint32_t num_ngrams; 34 | const uwu_markov_choice* choices; 35 | const uwu_markov_ngram* ngrams; 36 | } uwu_markov_table; 37 | 38 | // Stores the state for a Markov chain operation. 39 | typedef struct { 40 | size_t prev_ngram; /* previous ngram */ 41 | size_t remaining_chars; /* number of remaining characters */ 42 | const uwu_markov_table* ngrams /* ngram table */; 43 | } uwu_markov_state; 44 | 45 | // Stores the state for a "print string" operation. 46 | typedef struct { 47 | char* string; /* pointer to string */ 48 | size_t remaining_chars; /* number of remaining characters */ 49 | } uwu_print_string_state; 50 | 51 | // Stores the state for a "repeat this character" operation. 52 | typedef struct { 53 | char character; 54 | size_t remaining_chars; /* number of remaining times to repeat the character */ 55 | } uwu_repeat_character_state; 56 | 57 | // Because we're asked to read a certain amount of data at a time, and we 58 | // can't control what that amount is, we need a way to store what we're 59 | // currently doing. This is done using opcodes--currently "repeat character", 60 | // "print string", and the most complicated one, "print using Markov chain". 61 | // An op is executed repeatedly as many times as we need characters. 62 | // Once it's run out of characters, move on to the next one. 63 | // If we're all out of ops, generate a new program. 64 | 65 | typedef union { 66 | uwu_markov_state markov; 67 | uwu_print_string_state print_string; 68 | uwu_repeat_character_state repeat_character; 69 | } uwu_op_state; 70 | 71 | typedef enum { 72 | UWU_MARKOV, 73 | UWU_PRINT_STRING, 74 | UWU_REPEAT_CHARACTER 75 | } UWU_OPCODE; 76 | 77 | typedef struct { 78 | UWU_OPCODE opcode; 79 | uwu_op_state state; 80 | } uwu_op; 81 | 82 | #define MAX_OPS 6 83 | 84 | struct uwu_state { 85 | uwu_op_factory** ops_table; 86 | int32_t num_ops; 87 | int32_t prev_op; 88 | 89 | uwu_op ops[MAX_OPS]; 90 | int8_t current_op; 91 | 92 | uwu_random_number* rng_buf; 93 | size_t rng_idx; 94 | }; 95 | 96 | typedef struct { 97 | size_t len; 98 | char* string; 99 | } string_with_len; 100 | 101 | #define STRING_WITH_LEN(literal) {.len = (sizeof(literal) - 1), .string = literal} 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /uwurandom_user.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "uwurandom_core.h" 8 | #include "uwurandom_ops.h" 9 | 10 | static volatile sig_atomic_t keep_running = 1; 11 | 12 | static void sig_handler(int _) { 13 | keep_running = 0; 14 | } 15 | 16 | #define BUF_SIZE 8192 17 | 18 | int main(void) { 19 | uwu_state data = {0}; 20 | 21 | int init_err = uwu_init_state(&data, uwu_op_table_default, ARRAY_SIZE(uwu_op_table_default)); 22 | 23 | if (init_err) { 24 | return init_err; 25 | } 26 | 27 | char* output_buf = malloc(BUF_SIZE); 28 | if (output_buf == NULL) { 29 | uwu_destroy_state(&data); 30 | return -ENOMEM; 31 | } 32 | 33 | signal(SIGINT, sig_handler); 34 | while (keep_running) { 35 | uwu_write_chars(&data, output_buf, BUF_SIZE); 36 | fwrite(output_buf, 1, BUF_SIZE, stdout); 37 | } 38 | 39 | uwu_destroy_state(&data); 40 | free(output_buf); 41 | 42 | return 0; 43 | } 44 | --------------------------------------------------------------------------------