Skip to content

Instantly share code, notes, and snippets.

@martinpovolny
Created January 15, 2013 09:30
Show Gist options
  • Save martinpovolny/4537506 to your computer and use it in GitHub Desktop.
Save martinpovolny/4537506 to your computer and use it in GitHub Desktop.
def penalty_for_cost(price,mode)
base = 100
reward = case mode
when 1
price*base
when 2
Math.log(price*base)*10
when 3
(price*base/10)**2
else
0
end
reward=100 if reward>100
reward=-100 if reward<-100
reward
end
[0.001,0.002,0.01,0.02,0.1,0.2,1,2].each { |price|
p [price,
penalty_for_cost(price,1),
penalty_for_cost(price,2),
penalty_for_cost(price,3)
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment