Author | Message |
---|---|
Anonymous
Posts: 166
|
Posted 22:00 Mar 05, 2014 |
I do not understand what the calculateMoney method is doing in regards to the helper method. How is it helping? Better yet, which method is helping which? there are four parameters in the calculate_bid method, (player, pos, first_moves, and second_moves) but only three are used in the int[ ] info. There is so much information, and I don't know which to use, nor how to use it. |
ytsai8
Posts: 47
|
Posted 22:11 Mar 05, 2014 |
While you're trying to do the logic for your AI, you will notice you have nowhere to get access to "p1Money" , "p2Money" , and "tieBreaker". Without those info, your AI can mostly bid blindly rather than logically. This helper method can help you keep track of the gold in banks and player turns. You can calculate each info using the parameters (alot similar to doMove method) however the infos are in arrays. |
Eric Liao
Posts: 158
|
Posted 22:14 Mar 05, 2014 |
To understand the calculate_bid method, you have to understand what are those four parameters (player, pos, first_moves, second_moves) As I explained in the lab today, player will indicate which player your AI is playing as. This will be either 1 or 2 to indicate you are first player or second player. And pos is just the position of the token. first_moves and second_moves is an array of integer that shows what are the history moves from first player and second player. The helper method (caluclateMoney) is to help you to calculate the money out of the history moves. Keep this in mind that you as an AI developer does not know the money of each player directly. You know the history moves from both player, and that is it. Therefore, you have to create some method that computer the money based on the history moves. In the pseudocode you have to do a for loop for the history moves (first_moves and second_moves) to computer each move individually so that you can reuse the similar logic you implemented in the part 1 of the lab. Try to recall how you implement doMoves() method in the part 1 of the lab. essentially you are implement biased from that doMoves method. |
lakerfan94
Posts: 143
|
Posted 22:16 Mar 05, 2014 |
"Initialize both player's money as 100 in the method. Since this method is a static method, you don't need to initialize/create the object to use the static method. Next week I will go over the detail of static vs instance using java example. So, in your calculateMoney. You would need to initialize the p1money to be 100, p2 money to be 100 too. At the end you return an array of integer containing p1money, p2money, and who has the tie breaker later." This is what Eric replied to a question I had about calculateMoney. Honestly, the calculateMoney method is a lot like the doMoves method that we had in week 7 or 8. Read the description in the homework. It says that the method is similar to the doMoves() method we did in lab in week 7 or 8. Last edited by lakerfan94 at
22:17 Mar 05, 2014.
|
Anonymous
Posts: 166
|
Posted 22:58 Mar 05, 2014 |
I've got the calculateMoney part down, but is there a specific way to calculate a bid? Or is just based on the strategy the AI developer chooses to implement? Otherwise, where did the 5 come from? Thanks to all the replies! |
lakerfan94
Posts: 143
|
Posted 23:03 Mar 05, 2014 |
I have a question though. Is it only the calculateMoney method we submit? |
Anonymous
Posts: 166
|
Posted 23:06 Mar 05, 2014 |
I submitted both, I figured it couldn't hurt. @ LakerFan94 |
Eric Liao
Posts: 158
|
Posted 23:18 Mar 05, 2014 |
For the lab, you only need to submit the calculateMoney and the test cases. For the logic of implementing the actual bid, you know each player's money now. You can start to play with your strategy about how much you should bid. A starting point can be the following: 1. Never bid invalid bid (e.g. if you have no money, bid zero) 2. When your AI is about to lose (say if you lose this bid you lose the game), try to win this bid by bid one more than what opponent has if possible 3. When your AI is about to win (say if you win this bid you win the game), try to bid everything you have 4. If opponent has no money left, bid one until you have no money as well 5. Figure out some formula/strategy you want to implement. |