Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
algo tweaks in preparations for refactoring the way events work
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Schultheis committed Jan 27, 2013
1 parent c59407b commit a6e7026
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions bin/pa_auction_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ def parse_cmd_line
auction_observer.hooks[:on_new_auction] = OnNewAuction
auction_observer.hooks[:on_auction_end] = OnAuctionEnd
auction_observer.hooks[:on_timer_threshold] = OnTimerThreshold
auction_observer.hooks[:four_seconds_left] = FourSecondsLeft if defined? FourSecondsLeft

auction_observer.observe_auction
9 changes: 8 additions & 1 deletion bots/bidder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@
end
}


FourSecondsLeft = lambda {|secs, browser|
if @model.would_bid
if rand < 0.07
puts "Random Bid!"
browser.bid(true)
end
end
}
8 changes: 4 additions & 4 deletions bots/bidder_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def process_new_bids new_bids

def would_bid

#return false if @num_bids < 25
return false if @uniques[:u10] > 8
#return false if @uniques[:u20] > 9
#return false if (@autoq > 40) && (@uniques[:u10] > 3)
return false if @num_bids < 10
return false if @uniques[:u10] > 6
return false if @uniques[:u20] > 9
return false if (@autoq > 30) && (@uniques[:u10] > 3)

return true
end
Expand Down
4 changes: 4 additions & 0 deletions lib/pa_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def observe_auction
process_event :on_timer_threshold, cur_secs, @pa_site
end

if cur_secs == 4
process_event :four_seconds_left, cur_secs, @pa_site
end

puts " - " + cur_secs.to_s

#If the timer went up, then we have new bids to process
Expand Down
7 changes: 4 additions & 3 deletions site_bindings/quibids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def refresh_auction
end
end

def bid
def bid(force=false)
sleep 0.1 #this pause can be tweaked to give better last second catches
if seconds_left < 3
if force || (seconds_left < 3)
if @logged_in
@auction_els[:bid_btn].click
puts "BID clicked!"
Expand Down Expand Up @@ -111,6 +111,7 @@ def get_new_bids
hdoc.search('//tr').reverse.each do |tr|
bidder, amt, type = tr.search('//td').map {|tr| tr.inner_html}[1..3]
amt = amt.pa_calc_amt
type = (type == 'BidOMatic') ? :automatic : :manual
if amt > @last_amt
bids << {
:bidder => bidder,
Expand All @@ -126,7 +127,7 @@ def get_new_bids
def login username, password
@browser.text_field(:name, 'username').set username
@browser.text_field(:name, 'password').set password
@browser.button(:id, 'login-btn').click
@browser.button(:id, 'login').click
goto_auction
@logged_in = true
end
Expand Down

0 comments on commit a6e7026

Please sign in to comment.