Skip to content

Baseball diamond functionality - #894

Closed
Ignose wants to merge 12 commits into
mainfrom
baseball-diamond-functionality
Closed

Ignose wants to merge 12 commits into
mainfrom
baseball-diamond-functionality

Conversation

@Ignose

@Ignose Ignose commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@spaghetti-squash spaghetti-squash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments and docstrings here are an excellent example of how comments and docstrings are the worst thing to use LLMs for: they're excessively verbose, spend too much time elucidating simple concepts while eliding complex ones, and are somehow too dense to plod through while also containing remarkably little information.

} as const;

type Pitch = keyof typeof PITCH_ELEMENTS;
type Element = (typeof PITCH_ELEMENTS)[Pitch];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be pretty surprised to discover that this is the only notion of an element string type that exists or should-exist in libram. This type should probably be defined in lib and exported, if it doesn't already exist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe kolmafia's ElementType includes the fake-elements like Slime and Bad Spelling; now that we know they are for sure not real elements in kol, it may be sensible to retire them. cc @gausie for feedback. I suspect the answer will be "slime as a real element has nonzero utility due to slime resistance, and maybe supercold has something similar?", which I suppose would be enough to put a damper on that wild dream.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual element doesn't matter; but I can import and use $element<element> instead of just the string if you'd prefer. I cannot stress enough, the actual element doesn't matter.

Comment on lines +102 to +108
const PITCHES_BY_ELEMENT: Record<Element, [Pitch, Pitch, Pitch]> = {
Hot: ["Throw Some Smoke", "Bring the Heat", "Schenectady Scorcher"],
Cold: ["Deep Freeze", "Snowball", "Ice Him Out"],
Spooky: ["Ghost Pitch", "Skullball", "Non-Euclidean Curveball"],
Stench: ["Garbageball", "Beanball", "Some Cheddar"],
Sleaze: ["Slurveball", "Bacon-Wrapped Slider", "Screwball"],
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't redundantly construct both objects, one should be constructed from the other using either a reduce or an Object.fromEntries

* The first two entries are lesser pitches. The third entry is the greater
* pitch.
*/
const PITCHES_BY_ELEMENT: Record<Element, [Pitch, Pitch, Pitch]> = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the existing Tuple type in libram, rather than repeating Pitch thrice

Comment on lines +71 to +91
const PITCH_ELEMENTS = {
"Throw Some Smoke": "Hot",
"Bring the Heat": "Hot",
"Schenectady Scorcher": "Hot",

"Deep Freeze": "Cold",
Snowball: "Cold",
"Ice Him Out": "Cold",

"Ghost Pitch": "Spooky",
Skullball: "Spooky",
"Non-Euclidean Curveball": "Spooky",

Garbageball: "Stench",
Beanball: "Stench",
"Some Cheddar": "Stench",

Slurveball: "Sleaze",
"Bacon-Wrapped Slider": "Sleaze",
Screwball: "Sleaze",
} as const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be the one that gets programmatically defined.

Comment on lines +158 to +163
monster1: Monster,
pitch1: Pitch,
monster2?: Monster,
pitch2?: Pitch,
monster3?: Monster,
pitch3?: Pitch,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this accept a spread tuple of length >= 3 of { monster, pitch } objects--alternating arguments is just going to lead to more confusion, and requires a bizarre input validation rather than relying on TypeScript to do it for you.

let pitch: Pitch;

if (state[index] < 2) {
pitch = PITCHES_BY_ELEMENT[element][0];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon seeing PITCHES_BY_ELEMENT in action, I think it would probably make more sense to have two separate object, one for major pitches, one for minor; I didn't assume this on first reading the code, but I do now.

Comment on lines +287 to +292
monster1: Monster,
pitch1: Pitch,
monster2?: Monster,
pitch2?: Pitch,
monster3?: Monster,
pitch3?: Pitch,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark re: arg sequencing

return false;
}

visitUrl(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the directlyUse utility here


const lineup = get("baseballTeam").split(",").map(Number);

if (lineup.length !== 9) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is less computationally expensive and more "base" than doing findPitchOrder; it should be the first reason to return false

const currentMonsterId = lineup[position];

// Try matching an requested pitch if the monster at this index matches
for (let i = 0; i < unmatchedRequests.length; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterating over the indices of an array isn't an antipattern in typescript, but you should in general view it as a sign that you may be on the wrong path. It seems like the only place where we use it is in filtering unmatchedRequests, which IS the array you're iterating over.

I think that probably this entire block can be replaced with some amount of map/reduce/flatMap use, be condensed significantly, and in doing so be made more legible. I can't discern exactly what this is trying to do easily enough to provide more specific guidance right now, although maybe after some changes I'll be able to.

@Ignose Ignose closed this Sep 30, 2026
@Ignose
Ignose deleted the baseball-diamond-functionality branch September 30, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants