Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Author: ThymineC
- # Date: 23/11/2013
- # Python version: 2.7
- # Description: Evaluates the behaviour of a miner AI using a greedy algorithm that
- # bases its behaviour at each tick on whatever action maximises
- # value/tick ratio
- def valMineReturn(t, X, Y, Z):
- assert(t <= Y)
- return float(Z) / float(X + Y - t)
- def valReturnNow(t, X, Y, Z):
- assert(t <= Y)
- return (Z / float(Y))*t / float(X)
- def decision(t, X, Y, Z):
- if valMineReturn(t, X, Y, Z) > valReturnNow(t, X, Y, Z):
- return "Mines and returns"
- else:
- return "Returns now"
- def main():
- xMax = 2
- yMax = 2
- zMax = 3
- print "Travel tick range: [1, %s]" % xMax
- print "Mining tick range: [1, %s]" % yMax
- print "Ore value range: [0, %s]\n\n" % zMax
- for X in range(1, xMax+1):
- for Y in range(1, yMax+1):
- for Z in range(0, zMax+1):
- for t in range(1, 2):
- print "t: %s" % t
- print "travelTicks: %s" % X
- print "mineTicks: %s" % Y
- print "oreValue: %s" % Z
- print "V(mine+return): %s" % valMineReturn(t, X, Y, Z)
- print "V(return now): %s" % valReturnNow(t, X, Y, Z)
- print "decision: %s\n" % decision(t, X, Y, Z)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement