horsegen: spam vectors to try to limit type check time

This commit is contained in:
2026-02-16 14:06:51 -05:00
parent 2184515938
commit b0e422ac01
14 changed files with 157 additions and 6644 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -2,485 +2,18 @@ module horse/global/saddle
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id import horse/game-id
pub import horse/race pub import horse/race
pub import horse/global/race pub import horse/global/race
// Enumeration of all saddles for type-safe programming. extern create-id-table(): vector<int>
pub type saddle c inline "int32_t arr[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,};\nkk_vector_from_cint32array(arr, (kk_ssize_t)155, kk_context())"
Classic-Triple-Crown js inline "[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,]"
Senior-Autumn-Triple-Crown // Vector of all saddle IDs in order for easy iterating.
Triple-Tiara val all = once(create-id-table)
Senior-Spring-Triple-Crown
Tenno-Sweep
Dual-Grand-Prix
Dual-Miles
Dual-Sprints
Dual-Dirts
Arima-Kinen
Japan-C
Japanese-Derby
Tenno-Sho-Spring
Takarazuka-Kinen
Tenno-Sho-Autumn
Kikuka-Sho
Osaka-Hai
Satsuki-Sho
Japanese-Oaks
Takamatsunomiya-Kinen
Yasuda-Kinen
Sprinters-S
Mile-Ch
Oka-Sho
Victoria-Mile
Queen-Elizabeth-II-Cup
NHK-Mile-C
Shuka-Sho
Champions-C
February-S
JBC-Classic
Tokyo-Daishoten
Asahi-Hai-FS
Hopeful-S
Hanshin-JF
Teio-Sho
JBC-Sprint
JD-Derby
JBC-L-Classic
Nikkei-Shinshun-Hai
Tokai-S
American-JCC
Kyoto-Kinen
Nakayama-Kinen
Yayoi-Sho
Kinko-Sho
Fillies-Revue
Hanshin-Daishoten
Spring-S
Nikkei-Sho
Hanshin-Umamusume-S
New-Zealand-T
Yomiuri-Milers-C
Flora-S
Aoba-Sho
Kyoto-Shimbun-Hai
Keio-Hai-Spring-C
Meguro-Kinen
Sapporo-Kinen
Centaur-S
Rose-S
St-Lite-Kinen
Kobe-Shimbun-Hai
All-Comers
Mainichi-Okan
Kyoto-Daishoten
Fuchu-Umamusume-S
Swan-S
Keio-Hai-Junior-S
Copa-Republica-Argentina
Daily-Hai-Junior-S
Stayers-S
Hanshin-C
Kyoto-Kimpai
Nakayama-Kimpai
Shinzan-Kinen
Fairy-S
Aichi-Hai
Keisei-Hai
Silk-Road-S
Negishi-S
Kisaragi-Sho
Tokyo-Shimbun-Hai
Queen-C
Kyodo-News-Hai
Kyoto-Umamusume-S
Diamond-S
Kokura-Daishoten
Arlington-C
Hankyu-Hai
Tulip-Sho
Ocean-S
Nakayama-Umamusume-S
Falcon-S
Flower-C
Mainichi-Hai
March-S
Lord-Derby-CT
Antares-S
Fukushima-Umamusume-S
Niigata-Daishoten
Heian-S
Naruo-Kinen
Mermaid-S
Epsom-C
Unicorn-S
Hakodate-Sprint-S
CBC-Sho
Radio-Nikkei-Sho
Procyon-S
Tanabata-Sho
Hakodate-Kinen
Chukyo-Kinen
Hakodate-Junior-S
Ibis-Summer-D
Queen-S
Kokura-Kinen
Leopard-S
Sekiya-Kinen
Elm-S
Kitakyushu-Kinen
Niigata-Junior-S
Keeneland-C
Sapporo-Junior-S
Kokura-Junior-S
Niigata-Kinen
Shion-S
Keisei-Hai-AH
Sirius-S
Saudi-Arabia-RC
Fuji-S
Artemis-S
Fantasy-S
Miyako-S
Musashino-S
Fukushima-Kinen
Tokyo-Sports-Hai-Junior-S
Kyoto-Junior-S
Keihan-Hai
Challenge-C
Chunichi-Shimbun-Hai
Capella-S
Turquoise-S
Classic-Triple-Crown-Alt144
Senior-Spring-Triple-Crown-Alt145
Dual-Grand-Prix-Alt146
Takarazuka-Kinen-Alt147
Kikuka-Sho-Alt148
Spring-S-Alt149
Aoi-S
Senior-Spring-Triple-Crown-Alt151
Tenno-Sweep-Alt152
Tenno-Sho-Spring-Alt153
Classic-Triple-Crown-Alt154
Satsuki-Sho-Alt155
// Get the saddle ID for a saddle.
pub fun saddle-id(s: saddle): saddle-id
match s
Classic-Triple-Crown -> Saddle-id(1)
Senior-Autumn-Triple-Crown -> Saddle-id(2)
Triple-Tiara -> Saddle-id(3)
Senior-Spring-Triple-Crown -> Saddle-id(4)
Tenno-Sweep -> Saddle-id(5)
Dual-Grand-Prix -> Saddle-id(6)
Dual-Miles -> Saddle-id(7)
Dual-Sprints -> Saddle-id(8)
Dual-Dirts -> Saddle-id(9)
Arima-Kinen -> Saddle-id(10)
Japan-C -> Saddle-id(11)
Japanese-Derby -> Saddle-id(12)
Tenno-Sho-Spring -> Saddle-id(13)
Takarazuka-Kinen -> Saddle-id(14)
Tenno-Sho-Autumn -> Saddle-id(15)
Kikuka-Sho -> Saddle-id(16)
Osaka-Hai -> Saddle-id(17)
Satsuki-Sho -> Saddle-id(18)
Japanese-Oaks -> Saddle-id(19)
Takamatsunomiya-Kinen -> Saddle-id(20)
Yasuda-Kinen -> Saddle-id(21)
Sprinters-S -> Saddle-id(22)
Mile-Ch -> Saddle-id(23)
Oka-Sho -> Saddle-id(24)
Victoria-Mile -> Saddle-id(25)
Queen-Elizabeth-II-Cup -> Saddle-id(26)
NHK-Mile-C -> Saddle-id(27)
Shuka-Sho -> Saddle-id(28)
Champions-C -> Saddle-id(29)
February-S -> Saddle-id(30)
JBC-Classic -> Saddle-id(31)
Tokyo-Daishoten -> Saddle-id(32)
Asahi-Hai-FS -> Saddle-id(33)
Hopeful-S -> Saddle-id(34)
Hanshin-JF -> Saddle-id(35)
Teio-Sho -> Saddle-id(36)
JBC-Sprint -> Saddle-id(37)
JD-Derby -> Saddle-id(38)
JBC-L-Classic -> Saddle-id(39)
Nikkei-Shinshun-Hai -> Saddle-id(40)
Tokai-S -> Saddle-id(41)
American-JCC -> Saddle-id(42)
Kyoto-Kinen -> Saddle-id(43)
Nakayama-Kinen -> Saddle-id(44)
Yayoi-Sho -> Saddle-id(45)
Kinko-Sho -> Saddle-id(46)
Fillies-Revue -> Saddle-id(47)
Hanshin-Daishoten -> Saddle-id(48)
Spring-S -> Saddle-id(49)
Nikkei-Sho -> Saddle-id(50)
Hanshin-Umamusume-S -> Saddle-id(51)
New-Zealand-T -> Saddle-id(52)
Yomiuri-Milers-C -> Saddle-id(53)
Flora-S -> Saddle-id(54)
Aoba-Sho -> Saddle-id(55)
Kyoto-Shimbun-Hai -> Saddle-id(56)
Keio-Hai-Spring-C -> Saddle-id(57)
Meguro-Kinen -> Saddle-id(58)
Sapporo-Kinen -> Saddle-id(59)
Centaur-S -> Saddle-id(60)
Rose-S -> Saddle-id(61)
St-Lite-Kinen -> Saddle-id(62)
Kobe-Shimbun-Hai -> Saddle-id(63)
All-Comers -> Saddle-id(64)
Mainichi-Okan -> Saddle-id(65)
Kyoto-Daishoten -> Saddle-id(66)
Fuchu-Umamusume-S -> Saddle-id(67)
Swan-S -> Saddle-id(68)
Keio-Hai-Junior-S -> Saddle-id(69)
Copa-Republica-Argentina -> Saddle-id(70)
Daily-Hai-Junior-S -> Saddle-id(71)
Stayers-S -> Saddle-id(72)
Hanshin-C -> Saddle-id(73)
Kyoto-Kimpai -> Saddle-id(74)
Nakayama-Kimpai -> Saddle-id(75)
Shinzan-Kinen -> Saddle-id(76)
Fairy-S -> Saddle-id(77)
Aichi-Hai -> Saddle-id(78)
Keisei-Hai -> Saddle-id(79)
Silk-Road-S -> Saddle-id(80)
Negishi-S -> Saddle-id(81)
Kisaragi-Sho -> Saddle-id(82)
Tokyo-Shimbun-Hai -> Saddle-id(83)
Queen-C -> Saddle-id(84)
Kyodo-News-Hai -> Saddle-id(85)
Kyoto-Umamusume-S -> Saddle-id(86)
Diamond-S -> Saddle-id(87)
Kokura-Daishoten -> Saddle-id(88)
Arlington-C -> Saddle-id(89)
Hankyu-Hai -> Saddle-id(90)
Tulip-Sho -> Saddle-id(91)
Ocean-S -> Saddle-id(92)
Nakayama-Umamusume-S -> Saddle-id(93)
Falcon-S -> Saddle-id(94)
Flower-C -> Saddle-id(95)
Mainichi-Hai -> Saddle-id(96)
March-S -> Saddle-id(97)
Lord-Derby-CT -> Saddle-id(98)
Antares-S -> Saddle-id(99)
Fukushima-Umamusume-S -> Saddle-id(100)
Niigata-Daishoten -> Saddle-id(101)
Heian-S -> Saddle-id(102)
Naruo-Kinen -> Saddle-id(103)
Mermaid-S -> Saddle-id(104)
Epsom-C -> Saddle-id(105)
Unicorn-S -> Saddle-id(106)
Hakodate-Sprint-S -> Saddle-id(107)
CBC-Sho -> Saddle-id(108)
Radio-Nikkei-Sho -> Saddle-id(109)
Procyon-S -> Saddle-id(110)
Tanabata-Sho -> Saddle-id(111)
Hakodate-Kinen -> Saddle-id(112)
Chukyo-Kinen -> Saddle-id(113)
Hakodate-Junior-S -> Saddle-id(114)
Ibis-Summer-D -> Saddle-id(115)
Queen-S -> Saddle-id(116)
Kokura-Kinen -> Saddle-id(117)
Leopard-S -> Saddle-id(118)
Sekiya-Kinen -> Saddle-id(119)
Elm-S -> Saddle-id(120)
Kitakyushu-Kinen -> Saddle-id(121)
Niigata-Junior-S -> Saddle-id(122)
Keeneland-C -> Saddle-id(123)
Sapporo-Junior-S -> Saddle-id(124)
Kokura-Junior-S -> Saddle-id(125)
Niigata-Kinen -> Saddle-id(126)
Shion-S -> Saddle-id(127)
Keisei-Hai-AH -> Saddle-id(128)
Sirius-S -> Saddle-id(129)
Saudi-Arabia-RC -> Saddle-id(130)
Fuji-S -> Saddle-id(131)
Artemis-S -> Saddle-id(132)
Fantasy-S -> Saddle-id(133)
Miyako-S -> Saddle-id(134)
Musashino-S -> Saddle-id(135)
Fukushima-Kinen -> Saddle-id(136)
Tokyo-Sports-Hai-Junior-S -> Saddle-id(137)
Kyoto-Junior-S -> Saddle-id(138)
Keihan-Hai -> Saddle-id(139)
Challenge-C -> Saddle-id(140)
Chunichi-Shimbun-Hai -> Saddle-id(141)
Capella-S -> Saddle-id(142)
Turquoise-S -> Saddle-id(143)
Classic-Triple-Crown-Alt144 -> Saddle-id(144)
Senior-Spring-Triple-Crown-Alt145 -> Saddle-id(145)
Dual-Grand-Prix-Alt146 -> Saddle-id(146)
Takarazuka-Kinen-Alt147 -> Saddle-id(147)
Kikuka-Sho-Alt148 -> Saddle-id(148)
Spring-S-Alt149 -> Saddle-id(149)
Aoi-S -> Saddle-id(150)
Senior-Spring-Triple-Crown-Alt151 -> Saddle-id(151)
Tenno-Sweep-Alt152 -> Saddle-id(152)
Tenno-Sho-Spring-Alt153 -> Saddle-id(153)
Classic-Triple-Crown-Alt154 -> Saddle-id(154)
Satsuki-Sho-Alt155 -> Saddle-id(155)
// List of all saddles in ID order for easy iterating.
pub val all = [
Classic-Triple-Crown,
Senior-Autumn-Triple-Crown,
Triple-Tiara,
Senior-Spring-Triple-Crown,
Tenno-Sweep,
Dual-Grand-Prix,
Dual-Miles,
Dual-Sprints,
Dual-Dirts,
Arima-Kinen,
Japan-C,
Japanese-Derby,
Tenno-Sho-Spring,
Takarazuka-Kinen,
Tenno-Sho-Autumn,
Kikuka-Sho,
Osaka-Hai,
Satsuki-Sho,
Japanese-Oaks,
Takamatsunomiya-Kinen,
Yasuda-Kinen,
Sprinters-S,
Mile-Ch,
Oka-Sho,
Victoria-Mile,
Queen-Elizabeth-II-Cup,
NHK-Mile-C,
Shuka-Sho,
Champions-C,
February-S,
JBC-Classic,
Tokyo-Daishoten,
Asahi-Hai-FS,
Hopeful-S,
Hanshin-JF,
Teio-Sho,
JBC-Sprint,
JD-Derby,
JBC-L-Classic,
Nikkei-Shinshun-Hai,
Tokai-S,
American-JCC,
Kyoto-Kinen,
Nakayama-Kinen,
Yayoi-Sho,
Kinko-Sho,
Fillies-Revue,
Hanshin-Daishoten,
Spring-S,
Nikkei-Sho,
Hanshin-Umamusume-S,
New-Zealand-T,
Yomiuri-Milers-C,
Flora-S,
Aoba-Sho,
Kyoto-Shimbun-Hai,
Keio-Hai-Spring-C,
Meguro-Kinen,
Sapporo-Kinen,
Centaur-S,
Rose-S,
St-Lite-Kinen,
Kobe-Shimbun-Hai,
All-Comers,
Mainichi-Okan,
Kyoto-Daishoten,
Fuchu-Umamusume-S,
Swan-S,
Keio-Hai-Junior-S,
Copa-Republica-Argentina,
Daily-Hai-Junior-S,
Stayers-S,
Hanshin-C,
Kyoto-Kimpai,
Nakayama-Kimpai,
Shinzan-Kinen,
Fairy-S,
Aichi-Hai,
Keisei-Hai,
Silk-Road-S,
Negishi-S,
Kisaragi-Sho,
Tokyo-Shimbun-Hai,
Queen-C,
Kyodo-News-Hai,
Kyoto-Umamusume-S,
Diamond-S,
Kokura-Daishoten,
Arlington-C,
Hankyu-Hai,
Tulip-Sho,
Ocean-S,
Nakayama-Umamusume-S,
Falcon-S,
Flower-C,
Mainichi-Hai,
March-S,
Lord-Derby-CT,
Antares-S,
Fukushima-Umamusume-S,
Niigata-Daishoten,
Heian-S,
Naruo-Kinen,
Mermaid-S,
Epsom-C,
Unicorn-S,
Hakodate-Sprint-S,
CBC-Sho,
Radio-Nikkei-Sho,
Procyon-S,
Tanabata-Sho,
Hakodate-Kinen,
Chukyo-Kinen,
Hakodate-Junior-S,
Ibis-Summer-D,
Queen-S,
Kokura-Kinen,
Leopard-S,
Sekiya-Kinen,
Elm-S,
Kitakyushu-Kinen,
Niigata-Junior-S,
Keeneland-C,
Sapporo-Junior-S,
Kokura-Junior-S,
Niigata-Kinen,
Shion-S,
Keisei-Hai-AH,
Sirius-S,
Saudi-Arabia-RC,
Fuji-S,
Artemis-S,
Fantasy-S,
Miyako-S,
Musashino-S,
Fukushima-Kinen,
Tokyo-Sports-Hai-Junior-S,
Kyoto-Junior-S,
Keihan-Hai,
Challenge-C,
Chunichi-Shimbun-Hai,
Capella-S,
Turquoise-S,
Classic-Triple-Crown-Alt144,
Senior-Spring-Triple-Crown-Alt145,
Dual-Grand-Prix-Alt146,
Takarazuka-Kinen-Alt147,
Kikuka-Sho-Alt148,
Spring-S-Alt149,
Aoi-S,
Senior-Spring-Triple-Crown-Alt151,
Tenno-Sweep-Alt152,
Tenno-Sho-Spring-Alt153,
Classic-Triple-Crown-Alt154,
Satsuki-Sho-Alt155,
]
// Get the name for a saddle. // Get the name for a saddle.
// Alternate versions of saddles have an indication of their ID in their names. // Alternate versions of saddles have an indication of their ID in their names.

View File

@@ -2,24 +2,16 @@ module horse/global/scenario
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id import horse/game-id
// Enumeration of all scenarios for type-safe programming. extern create-id-table(): vector<int>
pub type scenario c inline "int32_t arr[] = {1,2,};\nkk_vector_from_cint32array(arr, (kk_ssize_t)2, kk_context())"
URA-Finale js inline "[1,2,]"
Unity-Cup // Vector of all scenario IDs in order for easy iterating.
val all = once(create-id-table)
// Get the scenario ID for a scenario.
pub fun scenario-id(s: scenario): scenario-id
match s
URA-Finale -> Scenario-id(1)
Unity-Cup -> Scenario-id(2)
// List of all scenarios in ID order for easy iterating.
pub val all = [
URA-Finale,
Unity-Cup,
]
// Get the name for a scenario. // Get the name for a scenario.
// If no scenario matches the ID, the result contains the numeric ID. // If no scenario matches the ID, the result contains the numeric ID.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -54,7 +54,7 @@ func PairAffinity(a, b CharacterID) int {
if _, ok := Characters[b]; !ok { if _, ok := Characters[b]; !ok {
return 0 return 0
} }
return int(pairAffinity[a*{{ $.Count }} + b]) return int(pairAffinity[a*{{ $.CharaCount }} + b])
} }
func TrioAffinity(a, b, c CharacterID) int { func TrioAffinity(a, b, c CharacterID) int {
@@ -67,6 +67,6 @@ func TrioAffinity(a, b, c CharacterID) int {
if _, ok := Characters[c]; !ok { if _, ok := Characters[c]; !ok {
return 0 return 0
} }
return int(trioAffinity[a*{{ $.Count }}*{{ $.Count }} + b*{{ $.Count }} + c]) return int(trioAffinity[a*{{ $.CharaCount }}*{{ $.CharaCount }} + b*{{ $.CharaCount }} + c])
} }
{{ end }} {{ end }}

View File

@@ -3,68 +3,55 @@ module horse/{{ $.Region }}/character
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector import std/core/vector
import std/core-extras import std/core-extras
import std/data/rb-map import std/data/rb-map
import horse/game-id import horse/game-id
pub import horse/character pub import horse/character
// Enumeration of all characters for type-safe programming. extern create-id-table(): vector<int>
pub type character c inline "int32_t arr[] = { {{- range $chara := $.Characters }}{{ $chara.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.CharaCount }}, kk_context())"
{{- range $uma := $.Characters }} js inline "[{{ range $chara := $.Characters }}{{ $chara.ID }},{{ end }}]"
{{ kkenum $uma.Name }} // Vector of all character ID values in order for easy iterating.
{{- end }} pub val all = once(create-id-table)
// Get the character ID for a character. val name2id = once()
pub fun character-id(c: character): character-id var m: rbmap<string, int> := empty()
match c all().foreach() fn(id) m := m.set(Character-id(id).show, id)
{{- range $uma := $.Characters }} m
{{ kkenum $uma.Name }} -> Character-id({{ $uma.ID }})
{{- end }}
// List of all characters in ID order for easy iterating.
pub val all = [
{{- range $uma := $.Characters }}
{{ kkenum $uma.Name }},
{{- end }}
]
val name2id: rbmap<string, character-id> = rb-map/empty()
{{- range $uma := $.Characters }}
.set({{ printf "%q" $uma.Name }}, Character-id({{ $uma.ID}}))
{{- end }}
// Get the character ID that has the given exact name. // Get the character ID that has the given exact name.
// If no character matches the name, the result is an invalid ID. // If no character matches the name, the result is an invalid ID.
pub fun from-name(name: string): character-id pub fun from-name(name: string): character-id
name2id.lookup(name).default(Character-id(0)) Character-id(name2id().rb-map/lookup(name).default(0))
// Get the name for a character. // Get the name for a character.
// If no character matches the ID, the result is the numeric ID. // If no character matches the ID, the result is the numeric ID.
pub fun show(c: character-id): string pub fun show(c: character-id): string
match c.game-id match c.game-id
{{- range $uma := $.Characters }} {{- range $chara := $.Characters }}
{{ $uma.ID }} -> {{ printf "%q" $uma.Name }} {{ $chara.ID }} -> {{ printf "%q" $chara.Name }}
{{- end }} {{- end }}
x -> "character " ++ x.show x -> "character " ++ x.show
fun character/index(c: character-id): int fun character/index(c: character-id): int
match c.game-id match c.game-id
{{- range $uma := $.Characters }} {{- range $chara := $.Characters }}
{{ $uma.ID }} -> {{ $uma.Index }} {{ $chara.ID }} -> {{ $chara.Index }}
{{- end }} {{- end }}
_ -> -99999999 _ -> -99999999
// Create the table of all pair affinities. // Create the table of all pair affinities.
// The affinity is the value at a.index*count + b.index. // The affinity is the value at a.index*count + b.index.
extern global/create-pair-table(): vector<int> extern global/create-pair-table(): vector<int>
c inline "kk_intx_t arr[] = { c inline "int32_t arr[] = {
{{- range $a := $.Characters }} {{- range $a := $.Characters }}
{{- range $b := $.Characters }} {{- range $b := $.Characters }}
{{- index $.PairMaps $a.ID $b.ID }}, {{- index $.PairMaps $a.ID $b.ID }},
{{- end }} {{- end }}
{{- end -}} {{- end -}}
};\nkk_vector_from_cintarray(arr, (kk_ssize_t){{ $.Count }} * (kk_ssize_t){{ $.Count }}, kk_context())" };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.CharaCount }} * (kk_ssize_t){{ $.CharaCount }}, kk_context())"
js inline "[ js inline "[
{{- range $a := $.Characters }} {{- range $a := $.Characters }}
{{- range $b := $.Characters }} {{- range $b := $.Characters }}
@@ -76,12 +63,12 @@ val global/pair-table = global/create-pair-table()
// Base affinity between a pair using the global ruleset. // Base affinity between a pair using the global ruleset.
pub fun global/pair-affinity(a: character-id, b: character-id): int pub fun global/pair-affinity(a: character-id, b: character-id): int
global/pair-table.at(a.index * {{ $.Count }} + b.index).default(0) global/pair-table.at(a.index * {{ $.CharaCount }} + b.index).default(0)
// Create the table of all trio affinities. // Create the table of all trio affinities.
// The affinity is the value at a.index*count*count + b.index*count + c.index. // The affinity is the value at a.index*count*count + b.index*count + c.index.
extern global/create-trio-table(): vector<int> extern global/create-trio-table(): vector<int>
c inline "kk_intx_t arr[] = { c inline "int32_t arr[] = {
{{- range $a := $.Characters }} {{- range $a := $.Characters }}
{{- range $b := $.Characters }} {{- range $b := $.Characters }}
{{- range $c := $.Characters }} {{- range $c := $.Characters }}
@@ -89,7 +76,7 @@ extern global/create-trio-table(): vector<int>
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
};\nkk_vector_from_cintarray(arr, (kk_ssize_t){{ $.Count }} * (kk_ssize_t){{ $.Count }} * (kk_ssize_t){{ $.Count }}, kk_context())" };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.CharaCount }} * (kk_ssize_t){{ $.CharaCount }} * (kk_ssize_t){{ $.CharaCount }}, kk_context())"
js inline "[ js inline "[
{{- range $a := $.Characters }} {{- range $a := $.Characters }}
{{- range $b := $.Characters }} {{- range $b := $.Characters }}
@@ -103,6 +90,6 @@ val global/trio-table = global/create-trio-table()
// Base affinity for a trio using the global ruleset. // Base affinity for a trio using the global ruleset.
pub fun global/trio-affinity(a: character-id, b: character-id, c: character-id): int pub fun global/trio-affinity(a: character-id, b: character-id, c: character-id): int
global/trio-table.at(a.index * {{ $.Count }} * {{ $.Count }} + b.index * {{ $.Count }} + c.index).default(0) global/trio-table.at(a.index * {{ $.CharaCount }} * {{ $.CharaCount }} + b.index * {{ $.CharaCount }} + c.index).default(0)
{{- end }} {{- end }}

View File

@@ -59,7 +59,7 @@ func ExecCharacter(t *template.Template, region string, kk, g io.Writer, c []Nam
Trios []AffinityRelation Trios []AffinityRelation
PairMaps map[int]map[int]int PairMaps map[int]map[int]int
TrioMaps map[int]map[int]map[int]int TrioMaps map[int]map[int]map[int]int
Count int CharaCount int
MaxID int MaxID int
}{region, c, pairs, trios, pm, tm, len(c), maxid} }{region, c, pairs, trios, pm, tm, len(c), maxid}
var err error var err error
@@ -78,11 +78,12 @@ func ExecSkill(t *template.Template, region string, kk, g io.Writer, groups []Na
m[t.GroupID] = append(m[t.GroupID], t) m[t.GroupID] = append(m[t.GroupID], t)
} }
data := struct { data := struct {
Region string Region string
Groups []NamedID[SkillGroup] Groups []NamedID[SkillGroup]
Skills []Skill Skills []Skill
Related map[int][]Skill Related map[int][]Skill
}{region, groups, skills, m} SkillCount int
}{region, groups, skills, m, len(skills)}
var err error var err error
if kk != nil { if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-skill", &data)) err = errors.Join(err, t.ExecuteTemplate(kk, "koka-skill", &data))
@@ -95,9 +96,10 @@ func ExecSkill(t *template.Template, region string, kk, g io.Writer, groups []Na
func ExecRace(t *template.Template, region string, kk, g io.Writer, races []Race) error { func ExecRace(t *template.Template, region string, kk, g io.Writer, races []Race) error {
data := struct { data := struct {
Region string Region string
Races []Race Races []Race
}{region, races} RaceCount int
}{region, races, len(races)}
var err error var err error
if kk != nil { if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-race", &data)) err = errors.Join(err, t.ExecuteTemplate(kk, "koka-race", &data))
@@ -110,9 +112,10 @@ func ExecRace(t *template.Template, region string, kk, g io.Writer, races []Race
func ExecSaddle(t *template.Template, region string, kk, g io.Writer, saddles []Saddle) error { func ExecSaddle(t *template.Template, region string, kk, g io.Writer, saddles []Saddle) error {
data := struct { data := struct {
Region string Region string
Saddles []Saddle Saddles []Saddle
}{region, saddles} SaddleCount int
}{region, saddles, len(saddles)}
var err error var err error
if kk != nil { if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-saddle", &data)) err = errors.Join(err, t.ExecuteTemplate(kk, "koka-saddle", &data))
@@ -125,9 +128,10 @@ func ExecSaddle(t *template.Template, region string, kk, g io.Writer, saddles []
func ExecScenario(t *template.Template, region string, kk, g io.Writer, scen []Scenario) error { func ExecScenario(t *template.Template, region string, kk, g io.Writer, scen []Scenario) error {
data := struct { data := struct {
Region string Region string
Scenarios []Scenario Scenarios []Scenario
}{region, scen} ScenarioCount int
}{region, scen, len(scen)}
var err error var err error
if kk != nil { if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-scenario", &data)) err = errors.Join(err, t.ExecuteTemplate(kk, "koka-scenario", &data))
@@ -143,7 +147,8 @@ func ExecSparks(t *template.Template, region string, kk, g io.Writer, sparks []S
Region string Region string
Sparks []Spark Sparks []Spark
SparkEffects map[int]map[int][]SparkEffect SparkEffects map[int]map[int][]SparkEffect
}{region, sparks, effects} SparkCount int
}{region, sparks, effects, len(sparks)}
var err error var err error
if kk != nil { if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-spark", &data)) err = errors.Join(err, t.ExecuteTemplate(kk, "koka-spark", &data))

View File

@@ -3,40 +3,29 @@ module horse/{{ $.Region }}/race
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import std/data/rb-map import std/data/rb-map
import horse/game-id import horse/game-id
pub import horse/race pub import horse/race
// Enumeration of all races for type-safe programming. extern create-id-table(): vector<int>
pub type race c inline "int32_t arr[] = { {{- range $r := $.Races }}{{ $r.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.RaceCount }}, kk_context())"
{{- range $r := $.Races }} js inline "[{{ range $r := $.Races }}{{ $r.ID }},{{ end }}]"
{{ kkenum $r.Name }}{{ if $r.Alternate }}-Alt{{ $r.ID }}{{ end }} // Vector of all race IDs in order for easy iterating.
{{- end }} val all = once(create-id-table)
// Get the race ID for a race. val name2id = once()
pub fun race-id(r: race): race-id var m: rbmap<string, int> := empty()
match r all().foreach() fn(id) m := m.set(Race-id(id).show, id)
{{- range $r := $.Races }} m
{{ kkenum $r.Name }}{{ if $r.Alternate }}-Alt{{ $r.ID }}{{ end }} -> Race-id({{ $r.ID }})
{{- end }}
// List of all races in ID order for easy iterating.
pub val all = [
{{- range $r := $.Races }}
{{ kkenum $r.Name }}{{ if $r.Alternate }}-Alt{{ $r.ID }}{{ end }},
{{- end }}
]
val name2id: rbmap<string, race-id> = rb-map/empty()
{{- range $r := $.Races }}
.set({{ printf "%q" $r.Name }}{{ if $r.Alternate }} ++ " (Alternate {{ $r.ID }})"{{ end }}, Race-id({{ $r.ID }}))
{{- end }}
// Get the race ID that has the given exact name. // Get the race ID that has the given exact name.
// Alternate versions of races have an indication of their ID in their names. // Alternate versions of races have an indication of their ID in their names.
// If no race matches the name, the result is an invalid ID. // If no race matches the name, the result is an invalid ID.
pub fun from-name(name: string): race-id pub fun from-name(name: string): race-id
name2id.lookup(name).default(Race-id(0)) Race-id(name2id().rb-map/lookup(name).default(0))
// Get the name for a race. // Get the name for a race.
// Alternate versions of races have an indication of their ID in their names. // Alternate versions of races have an indication of their ID in their names.

View File

@@ -3,29 +3,18 @@ module horse/{{ $.Region }}/saddle
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id import horse/game-id
pub import horse/race pub import horse/race
pub import horse/{{ $.Region }}/race pub import horse/{{ $.Region }}/race
// Enumeration of all saddles for type-safe programming. extern create-id-table(): vector<int>
pub type saddle c inline "int32_t arr[] = { {{- range $s := $.Saddles }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.SaddleCount }}, kk_context())"
{{- range $s := $.Saddles }} js inline "[{{ range $s := $.Saddles }}{{ $s.ID }},{{ end }}]"
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }} // Vector of all saddle IDs in order for easy iterating.
{{- end }} val all = once(create-id-table)
// Get the saddle ID for a saddle.
pub fun saddle-id(s: saddle): saddle-id
match s
{{- range $s := $.Saddles }}
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }} -> Saddle-id({{ $s.ID }})
{{- end }}
// List of all saddles in ID order for easy iterating.
pub val all = [
{{- range $s := $.Saddles }}
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }},
{{- end }}
]
// Get the name for a saddle. // Get the name for a saddle.
// Alternate versions of saddles have an indication of their ID in their names. // Alternate versions of saddles have an indication of their ID in their names.

View File

@@ -3,27 +3,16 @@ module horse/{{ $.Region }}/scenario
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id import horse/game-id
// Enumeration of all scenarios for type-safe programming. extern create-id-table(): vector<int>
pub type scenario c inline "int32_t arr[] = { {{- range $s := $.Scenarios }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.ScenarioCount }}, kk_context())"
{{- range $s := $.Scenarios }} js inline "[{{ range $s := $.Scenarios }}{{ $s.ID }},{{ end }}]"
{{ kkenum $s.Name }} // Vector of all scenario IDs in order for easy iterating.
{{- end }} val all = once(create-id-table)
// Get the scenario ID for a scenario.
pub fun scenario-id(s: scenario): scenario-id
match s
{{- range $s := $.Scenarios }}
{{ kkenum $s.Name }} -> Scenario-id({{ $s.ID }})
{{- end }}
// List of all scenarios in ID order for easy iterating.
pub val all = [
{{- range $s := $.Scenarios }}
{{ kkenum $s.Name }},
{{- end }}
]
// Get the name for a scenario. // Get the name for a scenario.
// If no scenario matches the ID, the result contains the numeric ID. // If no scenario matches the ID, the result contains the numeric ID.

View File

@@ -3,42 +3,31 @@ module horse/{{ $.Region }}/skill
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import std/data/rb-map import std/data/rb-map
import std/num/decimal import std/num/decimal
import horse/game-id import horse/game-id
import horse/movement import horse/movement
pub import horse/skill pub import horse/skill
// Enumeration of all skills for type-safe programming. extern create-id-table(): vector<int>
pub type skill c inline "int32_t arr[] = { {{- range $s := $.Skills }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.SkillCount }}, kk_context())"
{{- range $s := $.Skills }} js inline "[{{ range $s := $.Skills }}{{ $s.ID }},{{ end }}]"
{{ kkenum $s.Name }}{{ if $s.InheritID }}-Inherit{{ end }} // Vector of all skill ID values in order for easy iterating.
{{- end }} val all = once(create-id-table)
// Get the skill ID for a skill. val name2id = once()
pub fun skill-id(s: skill): skill-id var m: rbmap<string, int> := empty()
match s all().foreach() fn(id) m := m.set(Skill-id(id).show, id)
{{- range $s := $.Skills }} m
{{ kkenum $s.Name }}{{ if $s.InheritID }}-Inherit{{ end }} -> Skill-id({{ $s.ID }})
{{- end }}
// List of all skills in ID order for easy iterating.
pub val all = [
{{- range $s := $.Skills }}
{{ kkenum $s.Name }}{{ if $s.InheritID }}-Inherit{{ end }},
{{- end }}
]
val name2id: rbmap<string, skill-id> = rb-map/empty()
{{- range $s := $.Skills }}
.set({{ printf "%q" $s.Name }}{{ if $s.InheritID }} ++ " (Inherited)"{{ end }}, Skill-id({{ $s.ID }}))
{{- end }}
// Get the skill ID that has the given exact name. // Get the skill ID that has the given exact name.
// Inherited skills have `" (Inherited)"` appended to their names. // Inherited skills have `" (Inherited)"` appended to their names.
// If no skill matches the name, the result is an invalid ID. // If no skill matches the name, the result is an invalid ID.
pub fun from-name(name: string): skill-id pub fun from-name(name: string): skill-id
name2id.lookup(name).default(Skill-id(0)) Skill-id(name2id().rb-map/lookup(name).default(0))
// Get the name for a skill. // Get the name for a skill.
// Inherited skills have `" (Inherited)"` appended to their names. // Inherited skills have `" (Inherited)"` appended to their names.

View File

@@ -3,28 +3,17 @@ module horse/{{ $.Region }}/spark
// Automatically generated with horsegen; DO NOT EDIT // Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id import horse/game-id
pub import horse/spark pub import horse/spark
// Enumeration of all sparks for type-safe programming. extern create-id-table(): vector<int>
pub type spark c inline "int32_t arr[] = { {{- range $s := $.Sparks }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.SparkCount }}, kk_context())"
{{- range $s := $.Sparks }} js inline "[{{ range $s := $.Sparks }}{{ $s.ID }},{{ end }}]"
{{ kkenum $s.Name }}-Lv{{ $s.Rarity }} // Vector of all spark IDs in order for easy iterating.
{{- end }} val all = once(create-id-table)
// Get the ID for a spark.
pub fun spark-id(s: spark): spark-id
match s
{{- range $s := $.Sparks }}
{{ kkenum $s.Name }}-Lv{{ $s.Rarity }} -> Spark-id({{ $s.ID }})
{{- end }}
// List of all sparks in ID order for easy iterating.
pub val all = [
{{- range $s := $.Sparks }}
{{ kkenum $s.Name }}-Lv{{ $s.Rarity }},
{{- end }}
]
// Get the name for a spark. // Get the name for a spark.
// The name does not indicate the spark level. // The name does not indicate the spark level.