diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-04-29 21:04:29 -0400 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-04-29 21:04:29 -0400 |
commit | 61477ba75dd35655f38b3f280cd20cbe43b46d5a (patch) | |
tree | 2a234bb75325707c7461ec11bc7a8516cec473da /ai_weights.c | |
parent | Fixed ai trying to play cards not in its hand (diff) | |
download | 7w-61477ba75dd35655f38b3f280cd20cbe43b46d5a.tar.gz 7w-61477ba75dd35655f38b3f280cd20cbe43b46d5a.tar.bz2 7w-61477ba75dd35655f38b3f280cd20cbe43b46d5a.zip |
Fixed bug causing array content to be overwritten
Diffstat (limited to 'ai_weights.c')
-rw-r--r-- | ai_weights.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ai_weights.c b/ai_weights.c index 67fbd8e..23b25e1 100644 --- a/ai_weights.c +++ b/ai_weights.c @@ -4,7 +4,6 @@ int data_getdir(int dir, int p); //0 is east, 1 is west, 2 returns player int* cards_getproduction(int era, int card); int* cards_getcost(int era, int card); int data_canafford(int p, int era, int card); -int* data_getdefinites(int p); int** data_getindefinites(int p); int* data_gettradables(int p); int data_productiontype(int e, int card); @@ -75,14 +74,15 @@ int weight_resource(int era, int card, int player) { int weight = 0; int *prod = cards_getproduction(era, card); - int *trade = data_gettradables(player); + int trade[GOLD+1]; + arraycpy(data_gettradables(player), trade, GOLD+1); int i, j; for(i = 0; i < GOLD; i++) { if(prod[i] && !trade[i]) weight += 5; if(prod[i] && (i == STONE || i == ORE) && trade[i] < 2) weight += 2; } for(j = 0; j < 2; j++) { - trade = data_gettradables(data_getdir(j, player)); + arraycpy(data_gettradables(data_getdir(j, player)), trade, GOLD+1); for(i = 0; i < GOLD; i++) { if(prod[i] && !trade[i]) weight++; if(prod[i] && trade[i] && get_trade(player, i, j) == 1) weight--; |