From 01d411a870580e368d6530a2eaacd9c828a258ce Mon Sep 17 00:00:00 2001 From: Nathan Vance Date: Tue, 24 Mar 2015 12:34:19 -0400 Subject: Implemented ai trading (buggy) --- data.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index 6ad09f2..81bfe56 100644 --- a/data.c +++ b/data.c @@ -288,9 +288,8 @@ int data_productiontype(int e, int card) int* data_getdefinites(int p) { int *ret = get_intarray(GOLD); - int *trade = trade_buffer(); int i, j, k, *prod; - for(i = 0; i < GOLD; i++) ret[i] = trade[i]; + for(i = 0; i < GOLD; i++) ret[i] = 0; for(i = 0; i < 3; i++) { for(j = 0; j < 7; j++) { if(data_productiontype(i, player[p][i][j]) == 1) { @@ -315,6 +314,15 @@ void data_removedefinites(int p, int *cost) } } +void data_removetraded(int p, int *cost) +{ + int *trade = trade_buffer(); + int i; + for(i = 0; i < GOLD; i++) { + cost[i] -= trade[i]; + if(cost[i] < 0) cost[i] = 0; + } +} int** data_getindefinites(int p) { @@ -455,6 +463,7 @@ int data_canafford(int p, int era, int card) if(cost[GOLD] > data_getgold(p)) return 0; int i, j, k; data_removedefinites(p, cost); + data_removetraded(p, cost); if(data_iszerocost(cost)) return 1; return recurse(cost, data_getindefinites(p), 0); } -- cgit