very basic UI

This commit is contained in:
Kistaro Windrider 2023-11-18 16:50:53 -08:00
parent f151a9ad76
commit 67432448cf
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

43
main/main.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"fmt"
"log"
"os"
"strconv"
"git.chromaticdragon.app/kistaro/auctionsim/auctionsim"
)
func main() {
num := 1000
if len(os.Args) > 1 {
n, err := strconv.ParseInt(os.Args[1], 0, 64)
if err != nil {
log.Fatalf("can't parse %q as a number of bidders: %v", os.Args[1], err)
}
num = n
}
if num <= 1 {
log.Fatalf("can't run an auction with %d bidders", num)
}
price, bidder := auctionsim.RunAuction(
auctionsim.CappedBidderGenerator{
G: auctionsim.NormalestBidderGenerator(),
Lim: num,
},
)
delta := bidder.Value - price
valueStr := "gaining nothing"
if delta > 0 {
valueStr = fmt.Sprintf("gaining ¤%f", delta)
}
if delta < 0 {
valueStr = fmt.Sprintf("losing ¤%f", -delta)
}
fmt.Printf("The auction winner paid ¤%f, %s.\n", price, valueStr)
fmt.Printf("The item was worth ¤%f to them.\n", bidder.Value)
fmt.Printf("They would have paid up to ¤%f for it.\n", bidder.BidCeiling())
}