-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outline of pizza cube maximizer #2149
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,14 +1,19 @@ | ||||||||||||
import { | ||||||||||||
autosellPrice, | ||||||||||||
descToItem, | ||||||||||||
Effect, | ||||||||||||
handlingChoice, | ||||||||||||
Item, | ||||||||||||
mallPrice, | ||||||||||||
runChoice, | ||||||||||||
toSlot, | ||||||||||||
visitUrl, | ||||||||||||
} from "kolmafia"; | ||||||||||||
import { | ||||||||||||
$item, | ||||||||||||
$items, | ||||||||||||
$monsters, | ||||||||||||
$slot, | ||||||||||||
arrayEquals, | ||||||||||||
get, | ||||||||||||
maxBy, | ||||||||||||
|
@@ -21,6 +26,7 @@ import { candyFactoryValue } from "../lib"; | |||||||||||
import { garboAverageValue, garboValue } from "../garboValue"; | ||||||||||||
import { estimatedGarboTurns } from "../turns"; | ||||||||||||
import { copyTargetCount } from "../target"; | ||||||||||||
import { Potion } from "../potions"; | ||||||||||||
|
||||||||||||
const GOOD_TRAIN_STATIONS = [ | ||||||||||||
{ piece: TrainSet.Station.GAIN_MEAT, value: () => 900 }, | ||||||||||||
|
@@ -157,3 +163,62 @@ export function grabMedicine(): void { | |||||||||||
} | ||||||||||||
if (handlingChoice()) visitUrl("main.php"); | ||||||||||||
} | ||||||||||||
|
||||||||||||
// Function to calculate the value for each item | ||||||||||||
function calculateItemValue(item: Item, effect: Effect): number { | ||||||||||||
return ( | ||||||||||||
new Potion($item`diabolic pizza`, { | ||||||||||||
effect: effect, | ||||||||||||
duration: Math.sqrt(autosellPrice(item)), | ||||||||||||
}).gross(copyTargetCount()) - | ||||||||||||
mallPrice(item) + | ||||||||||||
(toSlot(item) === $slot`familiar` | ||||||||||||
? mallPrice($item`box of Familiar Jacks`) | ||||||||||||
: 0) + | ||||||||||||
item.name.length / 10 | ||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
// Consolidated function to get the best item for a given letter | ||||||||||||
function bestPizzaItemForLetter(letter: string, effect: Effect): Item { | ||||||||||||
const items = $items.all().filter((i) => i.name.startsWith(letter)); | ||||||||||||
|
||||||||||||
const itemsWithValues = items.map((item) => ({ | ||||||||||||
item, | ||||||||||||
value: calculateItemValue(item, effect), | ||||||||||||
})); | ||||||||||||
|
||||||||||||
return maxBy(itemsWithValues, (entry) => entry.value).item; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also fwiw if you aren't using the values outside of the maxby it makes more sense to not do the map at all and to instead just ```typescript
|
||||||||||||
} | ||||||||||||
|
||||||||||||
// Function to design the pizza based on the effect's name letters | ||||||||||||
function designPizza(effect: Effect): Item[] { | ||||||||||||
return effect.name | ||||||||||||
.substring(0, 4) | ||||||||||||
.split("") | ||||||||||||
.map((letter) => bestPizzaItemForLetter(letter, effect)); | ||||||||||||
} | ||||||||||||
|
||||||||||||
// Simulation to calculate pizza cost and benefit | ||||||||||||
export function simCreatePizza(effect: Effect): [number, number] { | ||||||||||||
const pizzaItems = designPizza(effect); | ||||||||||||
|
||||||||||||
const benefit = pizzaItems.reduce( | ||||||||||||
(acc, it) => acc + calculateItemValue(it, effect), | ||||||||||||
0, | ||||||||||||
); | ||||||||||||
Comment on lines
+206
to
+209
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
const cost = pizzaItems.reduce((acc, it) => acc + mallPrice(it), 0); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
return [cost, benefit]; | ||||||||||||
} | ||||||||||||
|
||||||||||||
// Function to create the pizza by calling the appropriate URL | ||||||||||||
export function createPizza(effect: Effect) { | ||||||||||||
const pizzaItems = designPizza(effect); | ||||||||||||
|
||||||||||||
visitUrl( | ||||||||||||
`campground.php?action=makepizza&pizza=${pizzaItems.map((item) => item.id).join(",")}`, | ||||||||||||
true, | ||||||||||||
true, | ||||||||||||
); | ||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't get multiple jacks from having multiple familiar items unfortunately