diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-04-03 19:21:20 -0400 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-04-03 19:21:20 -0400 |
commit | e5cc06ddd5e6f725605ccabd312bcd5c5da2aa8c (patch) | |
tree | 42fde640ee2a6f3a0e85a74cb364805d8525abc5 /ai_trade.c | |
parent | Halicarnassus bug fixes (diff) | |
download | 7w-e5cc06ddd5e6f725605ccabd312bcd5c5da2aa8c.tar.gz 7w-e5cc06ddd5e6f725605ccabd312bcd5c5da2aa8c.tar.bz2 7w-e5cc06ddd5e6f725605ccabd312bcd5c5da2aa8c.zip |
Can now see history of previous turn
Diffstat (limited to 'ai_trade.c')
-rw-r--r-- | ai_trade.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -20,9 +20,10 @@ void ai_cleartrade(int trade[3][GOLD]) trade[i][j] = 0; } -void recurse(int ret[], int cost, int trade[3][GOLD], int player, int era, int card) +int recurse(int ret[], int cost, int trade[3][GOLD], int player, int era, int card) { int i, j; + int tradea, tradeb; if(data_canafford(player, era, card)) { if(cost < ret[2] || ret[2] == 0) { ret[2] = cost; @@ -33,20 +34,21 @@ void recurse(int ret[], int cost, int trade[3][GOLD], int player, int era, int c } } } - return; //if we can afford it, don't bother recursing further. + return 1; //if we can afford it, don't bother recursing further. } for(i = 0; i < 2; i++) { for(j = 0; j < GOLD; j++) { if(data_getgold(player) - cost - get_trade(player, j, i) >= 0 && trade_gettradables(player, i)[j] >= trade[i][j]+1) { - trade[i][j]++; - trade[2][j]++; + tradea = trade[i][j]++; + tradeb = trade[2][j]++; trade_set(player, trade); - recurse(ret, cost+get_trade(player, j, i), trade, player, era, card); - trade[i][j]--; - trade[2][j]--; + if(recurse(ret, cost+get_trade(player, j, i), trade, player, era, card)) return 1; + trade[i][j] = tradea; + trade[2][j] = tradeb; } } } + return 0; } int* ai_trade(int player, int era, int card) |