Compare commits

..

No commits in common. "58efb6fec886dad1c72b2b81293cdf7dd7eaa1b1" and "5f052f8d98fe534a37a4c66e96e134e04fa21b87" have entirely different histories.

5 changed files with 43 additions and 46 deletions

View File

@ -29,6 +29,7 @@ func RunAuction(g BidderGenerator) (float64, Bidder) {
return prevBid, highBidder return prevBid, highBidder
} }
/** /**
* RunAuctionVerbosely simulates a single-bid second-price auction with no * RunAuctionVerbosely simulates a single-bid second-price auction with no
* reserve price between all bidders emitted by the provided generator, * reserve price between all bidders emitted by the provided generator,
@ -38,7 +39,7 @@ func RunAuction(g BidderGenerator) (float64, Bidder) {
* Use CappedBidderGenerator to limit the size of the auction and therefore * Use CappedBidderGenerator to limit the size of the auction and therefore
* the number of bidders on the list. * the number of bidders on the list.
*/ */
func RunAuctionVerbosely(g BidderGenerator) (float64, []Bidder) { func RunAuctionVerbosely(g BidderGenerator) float64, []Bidder {
var bidders []Bidder var bidders []Bidder
for b, ok := g.Generate(); ok; b, ok = g.Generate() { for b, ok := g.Generate(); ok; b, ok = g.Generate() {
bidders = append(bidders, b) bidders = append(bidders, b)

View File

@ -57,9 +57,8 @@ type Bidder struct {
/** /**
* ValueBelief returns how much the bidder *thinks* the item is worth to them. * ValueBelief returns how much the bidder *thinks* the item is worth to them.
* The actual value to them is b.Value. * The actual value to them is b.Value.
*/
func (b Bidder) ValueBelief() float64 { func (b Bidder) ValueBelief() float64 {
return b.Value + b.Irrationality return b.Value + b.Irrationality;
} }
/** /**
@ -80,7 +79,7 @@ func (b Bidder) BidCeiling() float64 {
* than their calculated ceiling if they had the money to do so, but they don't. * than their calculated ceiling if they had the money to do so, but they don't.
*/ */
func (b Bidder) CashCapped() bool { func (b Bidder) CashCapped() bool {
return b.ValueBelief() > b.Cash return b.ValueBelief() > b.Cash;
} }
/** /**

View File

@ -12,7 +12,7 @@ type Distribution interface {
* Draw returns the next float64 from the distribution and true, or * Draw returns the next float64 from the distribution and true, or
* zero and false if the distribution is exhausted or otherwise unusable. * zero and false if the distribution is exhausted or otherwise unusable.
*/ */
Draw() (float64, bool) Draw() float64, bool
} }
/** /**
@ -23,7 +23,7 @@ type BidderGenerator interface {
* Generate returns the next Bidder and true, or a zero Bidder and false if * Generate returns the next Bidder and true, or a zero Bidder and false if
* the generator is exhausted or otherwise unusable. * the generator is exhausted or otherwise unusable.
*/ */
Generate() (Bidder, bool) Generate() Bidder, bool
} }
/** /**
@ -88,7 +88,7 @@ type ConstDistribution float64
* Draw implements Distribution. * Draw implements Distribution.
*/ */
func (c ConstDistribution) Draw() (float64, bool) { func (c ConstDistribution) Draw() (float64, bool) {
return float64(c), true return (float64)c, true
} }
/** /**

3
go.mod
View File

@ -1,3 +0,0 @@
module git.chromaticdragon.app/kistaro/auctionsim
go 1.20