Esempio n. 1
0
def main(cursor, options=None):
	w = world.World(cursor)
	
	city_f.apply_city_matrix(w)
	sad_f.supply_and_demand(w)
	
	return ""
Esempio n. 2
0
File: cli.py Progetto: Teifion/Rob3
def trade_real(options):
	from functions import city_f, trade_f, sad_f
	from classes import world
	from rules import sad_rules
	import sys
	
	w = world.World(database.get_cursor())
	city_f.apply_city_matrix(w)
	
	res = sad_f.supply_and_demand(w)
	
	# trade_f.print_reports(w, res, ['res_summary', 'res_surplus', 'res_demand', 'res_producers', 'production', 'demand', 'wealth'])
	# sad_f.print_reports(w, res, ['res_summary', 'demand', 'wealth'])
	
	total_sat = 0
	big_sat = 0
	big_count = 0
	wealth = 0
	for k, v in w.live_cities().items():
		total_sat += v.satisfaction()
		wealth += v.wealth
		
		if v.size > 15000:
			big_sat += v.satisfaction()
			big_count += 1
	
	print("Avg wealth: %s" % (wealth/len(w.live_cities())))
	print("Average: %s" % (total_sat/len(w.live_cities())))
	print("Big average: %s" % (big_sat/big_count))
Esempio n. 3
0
def city_wealth(cursor, verbose):
	queries = []
	
	w = world.World(database.get_cursor())
	city_f.apply_city_matrix(w, compress=False)
	
	if verbose:
		it = cli_f.progressbar(w.live_cities().items(), "cities_check.city_wealth: ", 40, with_eta = True)
	else:
		it = w.live_cities().items()
	
	for k, c in it:
		c.wealth = city_rules.wealth_rate(w, c)
		queries.append("UPDATE cities SET wealth = %d WHERE id = %d;" % (c.wealth, k))
	
	database.query(cursor, *queries)
Esempio n. 4
0
File: cli.py Progetto: Teifion/Rob3
	def test_func(inputs, max_count = 100):
		totals = {}
		sad_rules.supply_factor = inputs
		
		w = world.World(database.get_cursor())
		city_f.apply_city_matrix(w)
		
		for r in sad_rules.res_list:
			totals[r] = 0
		
		# for i in cli_f.progressbar(range(0, max_count), prefix = "", size = 60, with_eta=True):
		for i in range(0, max_count):
			res = trade_f.supply_and_demand(w)
			
			for r in sad_rules.res_list:
				totals[r] += (res['production'][r][0]/res['demand'][r][0])
		
		# Get average
		avg = {}
		for r in sad_rules.res_list:
			avg[r] = totals[r]/max_count
		
		return avg