reset password
Author Message
Anonymous
Posts: 166
Posted 16:03 Mar 15, 2014 |

for some reason i can't play against my AI when i enter 2 to play against it it always returns 0 and i win the game. i think this peace of code from the game engine is what makes player 2 the AI.    p2bid = (option.equals("1")) ? in.nextInt() : AI_Template.calculate_bid(
                AIplayer, game.getPos(), game.getFirstMoves(), game.getSecondMoves());

what did you guys do to get it to work.

ytsai8
Posts: 47
Posted 00:45 Mar 16, 2014 |

try changing the 

p2bid = (option.equals("1")) ? in.nextInt() : AI_Template.calculate_bid(AIplayer, game.getPos(), game.getFirstMoves(), game.getSecondMoves());
 

to your AI's name?

or else it would be your calculate_bid method is returning 0, might wanna check both sides

 

Anonymous
Posts: 166
Posted 17:11 Mar 16, 2014 |

i do have my last name instead of AI template, and my calculate bid method does return the expected bid here is my calculate_bid method

 static int calculate_bid(int player, int pos, int[] first_moves,
    int[] second_moves) {
        // simplify the information to myMoney, and enemyMoney
        int[] info = calculateMoney(player, first_moves, second_moves);

        // return the calculated bid
        return aiStrategy(info[0], info[1], info[2], pos, player);
        
    }

ytsai8
Posts: 47
Posted 19:32 Mar 16, 2014 |

calculate_bid seems perfectly fine to me, since its the same as the template code.

Some possible bugs I can think of are 

1. in the class "BiddingGame" (or GameState), you have to change the first_moves and second_moves into ArrayLists, which is different from the original code from Project - Part 1. You can try copying Eric's template from Part 2 and check. 

2. it might be that the logic you set up before is different from what Eric expected. If you have noticed, Eric has 2 methods with similar names in the AI Template (calculate_bid & calculateBid); like myself, I did not use the calculateBid method, so it should help if you trace through the logic again.

3. the GameEngine automatically sets your AI as player 2, if you only design your bot to play as player 1, this would suck. You should modify your bot to detect whether it is playing as player 2 or player 1 and use its strategy according to the information.

Otherwise, I can't really think of the reason why it doesn't work. Might as well try to email Dr.Abbott or Eric your codes (like the whole piece) and ask them.