Skip to content

Instantly share code, notes, and snippets.

@dereknheiley
Last active April 12, 2018 15:08
Show Gist options
  • Save dereknheiley/c8a1479f484390bdd36733ae8331f020 to your computer and use it in GitHub Desktop.
Save dereknheiley/c8a1479f484390bdd36733ae8331f020 to your computer and use it in GitHub Desktop.
def buyHouse(buyer):
startSearch = date()
while wantAHouse:
listings = getNewHouseListings()
houses = filterByCriteria(listings, beds > 2, garage=True, walkscore > 85, alreadyConsidered=False)
health -= sum( [1 for house in houses if house.price > 1,000,000] )
if health < 1:
findChocolate(buyer)
continue
houses = filterByCriteria(houses, price < 650000, isFallingApart=false, recentHomocides=0)
candidates.append(houses)
if len(candidates) < 1 and len(listings) > 0:
raise Exception('Not enough pepperonies.')
for house in (top3 + candidates):
if sold(house):
top3.remove(house)
candidates.remove(house)
else:
updatePreference(buyer, house)
top3 = sortByPreferenceAndOpenOffer(candidates)[:3]
for house in top3
if house.notViewed:
bookViewing(house)
if house.pendingViewing:
view(house)
updatePreference(buyer, house)
if house.OfferExpired:
openOffer = false
for house in top3:
if house.preference > random(MEH, ARBITRARILY_HIGH):
imagineLivingIn(house)
drawFloorplansForFutureRenos(house)
researchOffer(house)
updatePreference(buyer, house)
if not openOffer and buyer.feelingBrave:
makeOffer(pickOne(buyer, top3))
openOffer = True
for house in top3:
if house.acceptedOffer:
panic(days=random(0,3))
if house.notInspected:
inspect(house)
elif random(0,9) > 0:
wait(days=random(0,60))
return moneyPit(house)
elif house.counterOffer:
panic(days=random(0,3))
if random(0,2) > 0:
makeOffer(house)
else:
archiveOffer(buyer, house)
openOffer = False
elif house.rejectedOffer:
archiveOffer(buyer, house)
openOffer = False
wantAHouse = False
panic(days=random(0,3))
wantAHouse = random(0, (date()-startDate)) == 1
sleep()
wantAHouse = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment