reset password
Author Message
Eric Liao
Posts: 158
Posted 23:14 Mar 08, 2014 |
Introduction

A few updates has been made to the project description and template codes to clear a few things out. Important things are AI_TemplateTest, BiddingGame, and GameEngine. First of all, I provides various test cases for you to test your AI_Template code. Also, you may use the BiddingGame and GameEngine to play against your AI now. Just run GameEngine and select "playing against bot", you should be able to play against your own bot by doing this.

Changes:

TESTING
AI_TemplateTest

I provides a few test cases to clarify what I want from the method. If you are confused on what method should return, check the AI_TemplateTest.java

AI Logic
AI_Template

I add the calculateBid and aiStrategy methods in the AI_Template.java now. Specially check the comment to see what each method supposes to do.

Game Logic
BiddingGame

For those of you who finished the first part, you can take a look to see how much difference from my implementation to yours.

Feel free to comment my code

What is this AI Template!?

Goal of the AI_Template is to create an smart agent that will bid the good amount of money in the Bidding Game. In order to achieve the goal, we will start from the calculate_bid method that is being provided to use from HackerRank.com. Nevertheless, the calculate_bid method that is being provided is not as convenient as what we expected to compute the bidding amount. Therefore, I decide that we should separate the calculate_bid method into 2 small methods. In addition to the convenience of us, the true benefit of split this calculate_bid method into 2 sub-methods are simple to debug and supporting Unit Test better. For instance, when you are working with some large project like this, sometimes you will have bugs/errors in your program. And when you are debugging your code to figure where it is, it's always better to debug small part at once instead of the a few hundred lines of code at once. Moreover, if you code your program in this small method approach, you can also implement unit test to test each method individually to ensure all your methods work correctly by itself before you are about to use them in other methods. Based on the benefits gained from coding in small methods, you should always do this approach later on for your projects. Anyway, we will explain what you need to do in these 2 part in detail.

 

Updated Tasks:

First part is to simplify and convert the information from the array of integer(history moves) to integer(player money). Basically, you use the list of history moves to compute how much money you have and how much money opponent has. Using the amount money each you and opponent has to compute how much bid is the second part.

In the first part, you will need to finish the calculateMoney and calculateBid method in order to simplify the information so that on the second part you can concentrate on computing how much money you should bid. You can use the AI_TemplateTest.java to test whether your code is working as expected or not. When you run all tests, it should pass at least all the testCalculateMoney and testCalculateBid tests.

On the second part, you will need to compute how much you need to bid. Starting from not bidding invalid bids, which is bid zero when there is no money left. And then, if opponent has no money left, you should keep bidding one until you win the game. After the above 2, you might also want to prevent losing by bidding opponent's money + 1 or just exact the same amount. Finally, bid just enough money each move to slowly gain advantage over opponent...

After tasks the above are all done, you probably want to play against your own bot a few times to see if you are satisfied of your bot. For instance, when you are playing against your bot and figure out that your bot shouldn't bid this much each move. You may fix it right away!

Finally, hopefully these hints can help you all finishing the bot as you expected. We will use half hour on the coming lab for a final show off. I will write a script that runs all your bots on that day and see which one is the best.

Eric Liao
If you are still lost, feel free to bring up discussion here.
Eric Liao
Good luck and have fun on the project!
Last edited by Eric Liao at 00:32 Mar 09, 2014.