Initial commit
This commit is contained in:
		
						commit
						7e397c3c56
					
				
					 6 changed files with 871 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| /target | ||||
							
								
								
									
										496
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										496
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,496 @@ | |||
| # This file is automatically @generated by Cargo. | ||||
| # It is not intended for manual editing. | ||||
| version = 3 | ||||
| 
 | ||||
| [[package]] | ||||
| name = "ahash" | ||||
| version = "0.8.6" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" | ||||
| dependencies = [ | ||||
|  "cfg-if", | ||||
|  "once_cell", | ||||
|  "version_check", | ||||
|  "zerocopy", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "allocator-api2" | ||||
| version = "0.2.16" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "autocfg" | ||||
| version = "1.1.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "bitflags" | ||||
| version = "1.3.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "bitflags" | ||||
| version = "2.4.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "cassowary" | ||||
| version = "0.3.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "cfg-if" | ||||
| version = "1.0.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "crossterm" | ||||
| version = "0.27.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" | ||||
| dependencies = [ | ||||
|  "bitflags 2.4.1", | ||||
|  "crossterm_winapi", | ||||
|  "libc", | ||||
|  "mio", | ||||
|  "parking_lot", | ||||
|  "signal-hook", | ||||
|  "signal-hook-mio", | ||||
|  "winapi", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "crossterm_winapi" | ||||
| version = "0.9.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" | ||||
| dependencies = [ | ||||
|  "winapi", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "either" | ||||
| version = "1.9.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "hashbrown" | ||||
| version = "0.14.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" | ||||
| dependencies = [ | ||||
|  "ahash", | ||||
|  "allocator-api2", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "heck" | ||||
| version = "0.4.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "indoc" | ||||
| version = "2.0.4" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "itertools" | ||||
| version = "0.11.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" | ||||
| dependencies = [ | ||||
|  "either", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "libc" | ||||
| version = "0.2.151" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "lock_api" | ||||
| version = "0.4.11" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" | ||||
| dependencies = [ | ||||
|  "autocfg", | ||||
|  "scopeguard", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "log" | ||||
| version = "0.4.20" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "lru" | ||||
| version = "0.12.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" | ||||
| dependencies = [ | ||||
|  "hashbrown", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "mio" | ||||
| version = "0.8.10" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
|  "log", | ||||
|  "wasi", | ||||
|  "windows-sys", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "once_cell" | ||||
| version = "1.19.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "parking_lot" | ||||
| version = "0.12.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" | ||||
| dependencies = [ | ||||
|  "lock_api", | ||||
|  "parking_lot_core", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "parking_lot_core" | ||||
| version = "0.9.9" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" | ||||
| dependencies = [ | ||||
|  "cfg-if", | ||||
|  "libc", | ||||
|  "redox_syscall", | ||||
|  "smallvec", | ||||
|  "windows-targets", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "paste" | ||||
| version = "1.0.14" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "proc-macro2" | ||||
| version = "1.0.70" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" | ||||
| dependencies = [ | ||||
|  "unicode-ident", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "quote" | ||||
| version = "1.0.33" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rand" | ||||
| version = "0.8.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" | ||||
| dependencies = [ | ||||
|  "rand_core", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rand_core" | ||||
| version = "0.6.4" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rand_xoshiro" | ||||
| version = "0.6.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" | ||||
| dependencies = [ | ||||
|  "rand_core", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "ratatui" | ||||
| version = "0.24.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" | ||||
| dependencies = [ | ||||
|  "bitflags 2.4.1", | ||||
|  "cassowary", | ||||
|  "crossterm", | ||||
|  "indoc", | ||||
|  "itertools", | ||||
|  "lru", | ||||
|  "paste", | ||||
|  "strum", | ||||
|  "unicode-segmentation", | ||||
|  "unicode-width", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "redox_syscall" | ||||
| version = "0.4.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" | ||||
| dependencies = [ | ||||
|  "bitflags 1.3.2", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "rustversion" | ||||
| version = "1.0.14" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "scopeguard" | ||||
| version = "1.2.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "signal-hook" | ||||
| version = "0.3.17" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
|  "signal-hook-registry", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "signal-hook-mio" | ||||
| version = "0.2.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
|  "mio", | ||||
|  "signal-hook", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "signal-hook-registry" | ||||
| version = "1.4.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "smallvec" | ||||
| version = "1.11.2" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "strum" | ||||
| version = "0.25.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" | ||||
| dependencies = [ | ||||
|  "strum_macros", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "strum_macros" | ||||
| version = "0.25.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" | ||||
| dependencies = [ | ||||
|  "heck", | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "rustversion", | ||||
|  "syn", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "syn" | ||||
| version = "2.0.41" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "unicode-ident", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "three-ore" | ||||
| version = "0.1.0" | ||||
| dependencies = [ | ||||
|  "crossterm", | ||||
|  "rand", | ||||
|  "rand_xoshiro", | ||||
|  "ratatui", | ||||
|  "xxhash-rust", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-ident" | ||||
| version = "1.0.12" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-segmentation" | ||||
| version = "1.10.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-width" | ||||
| version = "0.1.11" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "version_check" | ||||
| version = "0.9.4" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasi" | ||||
| version = "0.11.0+wasi-snapshot-preview1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "winapi" | ||||
| version = "0.3.9" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" | ||||
| dependencies = [ | ||||
|  "winapi-i686-pc-windows-gnu", | ||||
|  "winapi-x86_64-pc-windows-gnu", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "winapi-i686-pc-windows-gnu" | ||||
| version = "0.4.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "winapi-x86_64-pc-windows-gnu" | ||||
| version = "0.4.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-sys" | ||||
| version = "0.48.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" | ||||
| dependencies = [ | ||||
|  "windows-targets", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows-targets" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" | ||||
| dependencies = [ | ||||
|  "windows_aarch64_gnullvm", | ||||
|  "windows_aarch64_msvc", | ||||
|  "windows_i686_gnu", | ||||
|  "windows_i686_msvc", | ||||
|  "windows_x86_64_gnu", | ||||
|  "windows_x86_64_gnullvm", | ||||
|  "windows_x86_64_msvc", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_aarch64_gnullvm" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_aarch64_msvc" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_i686_gnu" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_i686_msvc" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_x86_64_gnu" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_x86_64_gnullvm" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "windows_x86_64_msvc" | ||||
| version = "0.48.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "xxhash-rust" | ||||
| version = "0.8.7" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "9828b178da53440fa9c766a3d2f73f7cf5d0ac1fe3980c1e5018d899fd19e07b" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "zerocopy" | ||||
| version = "0.7.31" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" | ||||
| dependencies = [ | ||||
|  "zerocopy-derive", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "zerocopy-derive" | ||||
| version = "0.7.31" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn", | ||||
| ] | ||||
							
								
								
									
										13
									
								
								Cargo.toml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Cargo.toml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| [package] | ||||
| name = "three-ore" | ||||
| version = "0.1.0" | ||||
| edition = "2021" | ||||
| 
 | ||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||
| 
 | ||||
| [dependencies] | ||||
| crossterm = "0.27.0" | ||||
| rand = { version = "0.8.5", default-features = false } | ||||
| rand_xoshiro = "0.6.0" | ||||
| ratatui = "0.24.0" | ||||
| xxhash-rust = { version = "0.8.7", features = ["xxh3"] } | ||||
							
								
								
									
										189
									
								
								src/board.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										189
									
								
								src/board.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,189 @@ | |||
| use crate::logic::*; | ||||
| use rand::seq::SliceRandom; | ||||
| use rand::{Rng, SeedableRng}; | ||||
| use rand_xoshiro::SplitMix64; | ||||
| use xxhash_rust::xxh3::xxh3_64; | ||||
| 
 | ||||
| impl Board { | ||||
|     pub fn new(seed: &str) -> Board { | ||||
|         let mut rng = SplitMix64::seed_from_u64(xxh3_64(seed.as_bytes())); | ||||
|         let hexes = { | ||||
|             let mut arr = [[None; 7]; 7]; | ||||
|             for h in Board::hexes(&mut rng) { | ||||
|                 arr[h.position.0 as usize][h.position.1 as usize] = Some(h); | ||||
|             } | ||||
|             arr | ||||
|         }; | ||||
|         let (edges, vertices) = { | ||||
|             let mut es = [[None; 15]; 15]; | ||||
|             let mut vs = [[None; 15]; 15]; | ||||
|             for hex in hexes.iter().flatten() { | ||||
|                 match hex { | ||||
|                     Some(Hex { | ||||
|                         hextype: HexType::Resource | HexType::Desert, | ||||
|                         position: p, | ||||
|                         .. | ||||
|                     }) => { | ||||
|                         let mut d = Position::new(1, 0); | ||||
|                         for _ in 0..6 { | ||||
|                             let e = p.edge(&d); | ||||
|                             if es[e.0 as usize][e.1 as usize].is_none() { | ||||
|                                 es[e.0 as usize][e.1 as usize] = Some(Edge { | ||||
|                                     position: e, | ||||
|                                     road: None, | ||||
|                                 }); | ||||
|                             } | ||||
|                             if vs[e.0 as usize][e.1 as usize].is_none() { | ||||
|                                 vs[e.0 as usize][e.1 as usize] = Some(Vertex { | ||||
|                                     position: e.vertex(&d), | ||||
|                                     settlement: None, | ||||
|                                     city: None, | ||||
|                                 }); | ||||
|                             } | ||||
|                             d.rotate(); | ||||
|                         } | ||||
|                     } | ||||
|                     _ => (), | ||||
|                 } | ||||
|             } | ||||
|             (es, vs) | ||||
|         }; | ||||
| 
 | ||||
|         let board = Board { | ||||
|             hexes, | ||||
|             edges, | ||||
|             vertices, | ||||
|             robber: hexes | ||||
|                 .iter() | ||||
|                 .flatten() | ||||
|                 .find(|h| h.is_some() && h.unwrap().hextype == HexType::Desert) | ||||
|                 .unwrap() | ||||
|                 .unwrap() | ||||
|                 .position, | ||||
|         }; | ||||
|         board | ||||
|     } | ||||
| 
 | ||||
|     fn hexes<R: Rng>(mut rng: &mut R) -> Vec<Hex> { | ||||
|         // get random direction
 | ||||
|         let direction = { | ||||
|             let mut d = Position::new(1, 0); | ||||
|             for _ in 0..rng.gen_range(0..6) { | ||||
|                 d.rotate(); | ||||
|             } | ||||
|             d | ||||
|         }; | ||||
|         let ps = Board::spiral_order(&direction); | ||||
|         let mut hexes = Vec::new(); | ||||
| 
 | ||||
|         // randomize port resources
 | ||||
|         let mut port_resources = { | ||||
|             let mut v = vec![ | ||||
|                 None, | ||||
|                 None, | ||||
|                 None, | ||||
|                 None, | ||||
|                 Some(Resource::Wood), | ||||
|                 Some(Resource::Brick), | ||||
|                 Some(Resource::Sheep), | ||||
|                 Some(Resource::Wheat), | ||||
|                 Some(Resource::Ore), | ||||
|             ]; | ||||
|             v.shuffle(&mut rng); | ||||
|             v | ||||
|         }; | ||||
|         let mut orientation = direction; | ||||
|         orientation.rotate().rotate(); | ||||
|         for (i, p) in ps[0..18].iter().enumerate() { | ||||
|             if i % 2 == 0 { | ||||
|                 //is a port
 | ||||
|                 if i % 3 != 2 { | ||||
|                     orientation.rotate(); | ||||
|                 } | ||||
|                 hexes.push(Hex { | ||||
|                     hextype: HexType::Port, | ||||
|                     resource: port_resources.pop().unwrap(), | ||||
|                     position: *p, | ||||
|                     number: None, | ||||
|                     orientation: Some(orientation), | ||||
|                 }); | ||||
|             } else { | ||||
|                 hexes.push(Hex { | ||||
|                     hextype: HexType::Ocean, | ||||
|                     resource: None, | ||||
|                     position: *p, | ||||
|                     number: None, | ||||
|                     orientation: None, | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         let mut numbers = { | ||||
|             let mut v = vec![5, 2, 6, 3, 8, 10, 9, 12, 11, 4, 8, 10, 9, 4, 5, 6, 3, 11]; | ||||
|             v.reverse(); | ||||
|             v | ||||
|         }; | ||||
|         let mut hex_resources = { | ||||
|             let mut h = Vec::new(); | ||||
|             for _ in 0..4 { | ||||
|                 h.push(Resource::Wood); | ||||
|                 h.push(Resource::Sheep); | ||||
|                 h.push(Resource::Wheat); | ||||
|             } | ||||
|             for _ in 0..3 { | ||||
|                 h.push(Resource::Brick); | ||||
|                 h.push(Resource::Ore); | ||||
|             } | ||||
|             h.shuffle(&mut rng); | ||||
|             h | ||||
|         }; | ||||
|         let desert_pos = rng.gen_range(0..18); | ||||
|         for (i, p) in ps[18..].iter().enumerate() { | ||||
|             if i == desert_pos { | ||||
|                 hexes.push(Hex { | ||||
|                     hextype: HexType::Desert, | ||||
|                     resource: None, | ||||
|                     position: *p, | ||||
|                     number: None, | ||||
|                     orientation: None, | ||||
|                 }); | ||||
|             } else { | ||||
|                 hexes.push(Hex { | ||||
|                     hextype: HexType::Resource, | ||||
|                     resource: Some(hex_resources.pop().unwrap()), | ||||
|                     position: *p, | ||||
|                     number: Some(numbers.pop().unwrap()), | ||||
|                     orientation: None, | ||||
|                 }); | ||||
|             }; | ||||
|         } | ||||
|         hexes | ||||
|     } | ||||
| 
 | ||||
|     fn spiral_order(direction: &Position) -> Vec<Position> { | ||||
|         let mut ps = Vec::new(); | ||||
|         for r in (1..=3).rev() { | ||||
|             ps.extend(&Board::ring(&direction, r)); | ||||
|         } | ||||
|         ps.push(Position::new(3, 3)); | ||||
|         ps | ||||
|     } | ||||
| 
 | ||||
|     fn ring(direction: &Position, radius: u32) -> Vec<Position> { | ||||
|         let mut ps = Vec::new(); | ||||
|         let mut current = Position::new(3, 3); | ||||
|         for _ in 0..radius { | ||||
|             current.add(direction); | ||||
|         } | ||||
|         let mut d = *direction; | ||||
|         d.rotate().rotate(); | ||||
|         for _ in 0..6 { | ||||
|             for _ in 0..radius { | ||||
|                 ps.push(current); | ||||
|                 current.add(&d); | ||||
|             } | ||||
|             d.rotate(); | ||||
|         } | ||||
|         ps | ||||
|     } | ||||
| } | ||||
							
								
								
									
										162
									
								
								src/logic.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								src/logic.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,162 @@ | |||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub enum Color { | ||||
|     Red, | ||||
|     Green, | ||||
|     Yellow, | ||||
|     Blue, | ||||
| } | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub enum Resource { | ||||
|     Brick, | ||||
|     Wood, | ||||
|     Sheep, | ||||
|     Wheat, | ||||
|     Ore, | ||||
| } | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub enum DevCard { | ||||
|     Knight, | ||||
|     VictoryPoint, | ||||
|     RoadBuilding, | ||||
|     YearOfPlenty, | ||||
|     Monopoly, | ||||
| } | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub enum HexType { | ||||
|     Desert, | ||||
|     Resource, | ||||
|     Port, | ||||
|     Ocean, | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| * Skewed 2d coordinate system | ||||
| * | ||||
| *    \ | ||||
| *     \ | ||||
| * -----\-----> y | ||||
| *       \ 60 deg | ||||
| *        \ x | ||||
| */ | ||||
| #[derive(Eq, Ord, PartialEq, PartialOrd, Copy, Clone, Debug)] | ||||
| pub struct Position(pub i32, pub i32); | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct Settlement(pub Color); | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct City(pub Color); | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct Road(pub Color); | ||||
| 
 | ||||
| pub struct Player { | ||||
|     pub name: String, | ||||
|     pub color: Color, | ||||
|     pub resources: Vec<Resource>, | ||||
|     pub dev_cards: Vec<DevCard>, | ||||
|     pub settlements: u32, | ||||
|     pub cities: u32, | ||||
|     pub roads: u32, | ||||
|     pub knights: u32, | ||||
|     pub points: u32, | ||||
|     pub ports: Vec<Resource>, | ||||
| } | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct Hex { | ||||
|     pub hextype: HexType, | ||||
|     pub resource: Option<Resource>, | ||||
|     pub position: Position, | ||||
|     pub number: Option<u32>, | ||||
|     pub orientation: Option<Position>, // orientation of the port
 | ||||
| } | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct Edge { | ||||
|     pub position: Position, // half scale coordinates
 | ||||
|     pub road: Option<Road>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||||
| pub struct Vertex { | ||||
|     pub position: Position, // rotated 30 deg, half scale coordinates
 | ||||
|     pub settlement: Option<Settlement>, | ||||
|     pub city: Option<City>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct Board { | ||||
|     pub hexes: [[Option<Hex>; 7]; 7], // center is 3,3
 | ||||
|     pub edges: [[Option<Edge>; 15]; 15], | ||||
|     pub vertices: [[Option<Vertex>; 15]; 15], | ||||
|     pub robber: Position, | ||||
| } | ||||
| 
 | ||||
| pub enum GamePhase { | ||||
|     Setup, | ||||
|     Main, | ||||
| } | ||||
| 
 | ||||
| pub struct Game { | ||||
|     pub players: Vec<Player>, | ||||
|     pub board: Board, | ||||
|     pub phase: GamePhase, | ||||
|     pub turn: Player, | ||||
|     pub dev_cards: Vec<DevCard>, | ||||
|     pub longest_road: Option<Player>, | ||||
|     pub larget_army: Option<Player>, | ||||
| } | ||||
| 
 | ||||
| impl Position { | ||||
|     pub fn new(x: i32, y: i32) -> Position { | ||||
|         Position(x, y) | ||||
|     } | ||||
| 
 | ||||
|     pub fn distance(&self, other: &Position) -> u32 { | ||||
|         let a = self.0 - other.0; | ||||
|         let b = self.1 - other.1; | ||||
|         if a ^ b >= 0 { | ||||
|             (a.abs() + b.abs()) as u32 | ||||
|         } else { | ||||
|             (a.abs().max(b.abs())) as u32 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn rotate(&mut self) -> &mut Position { | ||||
|         let x = self.0; | ||||
|         let y = self.1; | ||||
|         self.0 = -y; | ||||
|         self.1 = x + y; | ||||
|         self | ||||
|     } | ||||
| 
 | ||||
|     pub fn add(&mut self, other: &Position) -> &mut Position { | ||||
|         self.0 += other.0; | ||||
|         self.1 += other.1; | ||||
|         self | ||||
|     } | ||||
| 
 | ||||
|     pub fn neg(&mut self) -> &mut Position { | ||||
|         self.0 = -self.0; | ||||
|         self.1 = -self.1; | ||||
|         self | ||||
|     } | ||||
| 
 | ||||
|     pub fn scale(&mut self, n: i32) -> &mut Position { | ||||
|         self.0 *= n; | ||||
|         self.1 *= n; | ||||
|         self | ||||
|     } | ||||
| 
 | ||||
|     pub fn edge(&self, direction: &Position) -> Position { | ||||
|         let mut p = *self; | ||||
|         p.scale(2).add(&Position(1, 1)).add(direction); | ||||
|         p | ||||
|     } | ||||
| 
 | ||||
|     pub fn vertex(&self, direction: &Position) -> Position { | ||||
|         let Position(x, y) = *self; | ||||
|         Position(2 * x + y - 2 + direction.0, y - x + 7 + direction.1) | ||||
|     } | ||||
| } | ||||
							
								
								
									
										10
									
								
								src/main.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/main.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| mod board; | ||||
| mod logic; | ||||
| 
 | ||||
| /**
 | ||||
| * Three Ore Two Wheat | ||||
| */ | ||||
| 
 | ||||
| fn main() { | ||||
|     println!("Hello, world!"); | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 danial23
						danial23