Game tree and Dynamic Planning (the computed sub-problems are stored and used directly in the future)

Source: Internet
Author: User



Public class gametree {
/**
* Deduce the number of remaining balls. Who can win the final one,
* If one person is used for retrieval, we first take the result by default. If yes, true is returned. Otherwise, false is returned.
* @ Param X number of remaining balls
* @ Return
*/
Static Boolean F (int x ){
Int [] OP = {1, 3, 7, 8}; // there are only four cases for getting the ball each time.
For (INT I = 0; I <op. length; I ++ ){
If (x> = op [I]) {
If (f (x-op [I]) = false) return true; // game theory, the other party will lose, then we will win
}
}
Return false; // no matter how the other party goes, it is true, so we will lose
}
Public static void main (string [] ARGs ){
// Allocate adds efficiency using dynamic planning, stores computed sub-problems, and uses them directly in the future
System. Out. println (f (100 ));

}


}

Game tree and Dynamic Planning (the computed sub-problems are stored and used directly in the future)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.