Commit Graph

386 Commits (master)

Author SHA1 Message Date
melvin 9a668a9e3b changed tab to four spaces 2011-08-29 22:29:33 +08:00
melvin b0d803470e check for debug property 2011-08-29 16:55:09 +08:00
melvin 4167af70aa throw RuntimeException if there are no choices 2011-08-29 15:44:23 +08:00
melvin f6c06bc635 throw RuntimeException if there are no choices 2011-08-29 15:43:57 +08:00
melvin c0e638ed87 enabled random AI 2011-08-26 14:42:57 +08:00
melvin 850d01d3d1 optimized import statements with IntelliJ 2011-08-10 23:28:35 +08:00
melvin e9cd14b43c removed unused imports 2011-08-10 22:43:46 +08:00
melvin f59ba1d693 documented each try block for more systematic exception handling 2011-08-06 10:49:03 +08:00
melvin 1f5ba7818d changed magic.ai.StateCache to magic.data.LRUCache 2011-08-05 16:41:04 +08:00
melvin cd7d35a16d make sure Exception are final and variable is named ex for consistency 2011-08-04 13:17:26 +08:00
melvin 51181c43b5 replaced new RuntimeException(ex.getMessage()) with new RuntimeException(ex) 2011-08-03 22:47:43 +08:00
melvin 94660c7586 removed catch all 2011-08-03 15:28:10 +08:00
melvin c2fee56f69 replaced Exception with InterruptedException 2011-08-03 15:06:37 +08:00
melvin 3cf889d589 wrapped long lines 2011-08-03 15:06:18 +08:00
melvin 06d8cc2aea removed synchronized from findNextEventChoiceResults 2011-07-28 13:53:06 +08:00
melvin e8f1e744ce removed synchronized for findNextEventChoiceResults 2011-07-28 13:22:00 +08:00
melvin 82148c8a0c replaced default parameters in MCTSAI with tuned ones, increased duration of AI game to 1 hr 2011-07-21 10:52:07 +08:00
melvin 7dc3199d19 moved setting of MCTS parameters to static initalizer block 2011-07-16 12:00:11 +08:00
melvin d4a9677e28 removed empty lines 2011-07-13 17:05:30 +08:00
melvin 97e269fd15 added index and life to debug output of MMAB 2011-07-13 14:39:12 +08:00
melvin f90b28c1a5 changed debugging output to follow MCTSAI 2011-07-13 10:54:23 +08:00
melvin 35473e7445 simplified debugging output 2011-07-13 10:47:14 +08:00
melvin 22c2c15775 moved debugging output into a separate method 2011-07-13 10:34:52 +08:00
melvin 42cf451fa5 store constants in MCTSAI, read from property if defined 2011-07-12 16:34:56 +08:00
melvin 381052deff added early termination based on heuristic score 2011-07-11 22:30:20 +08:00
melvin d9ef12d598 initalize next node to null instead of curr.first 2011-07-08 15:35:59 +08:00
melvin d959e22f2c removed unnecessary import 2011-07-06 12:12:45 +08:00
melvin 426b124ac7 removed empty lines 2011-07-06 12:09:23 +08:00
melvin ec1906581b removed unused method 2011-07-04 16:18:15 +08:00
melvin 25ba323f05 simplfied the method calls 2011-07-04 16:17:20 +08:00
melvin c5d5a955a0 enable all modifications to UCT 2011-07-04 16:05:57 +08:00
melvin 9c83c0a8b1 improved readability 2011-07-04 15:49:57 +08:00
melvin 657679aebb added ideas from MC-LOA 2011-07-04 15:49:42 +08:00
melvin 590cbf5db5 added notes from consisteny modifications paper 2011-07-04 15:25:46 +08:00
melvin b372bc5320 store parent reference in node 2011-07-04 12:09:02 +08:00
melvin d9340c7c02 incLose keep track of max steps incrementally 2011-07-04 11:49:39 +08:00
melvin 39fe0b80a1 renamed constants 2011-07-04 11:07:07 +08:00
melvin b9b76c18f1 moved method for scoring nodes into MCTAGameTree class 2011-07-04 11:04:10 +08:00
melvin 045f10ae04 disabled robust max backup 2011-07-03 20:20:42 +08:00
melvin 6ee2c73638 modify selection score with solver result, reward according to length of playout 2011-07-03 20:19:15 +08:00
melvin e37bd1fc64 disable robust max, enabled reward based on length of playout 2011-07-02 14:53:34 +08:00
melvin 910eaa2d90 use robost max for backup 2011-07-02 10:58:14 +08:00
melvin 4d7234ef27 clear workers after processing is complete 2011-07-02 10:50:49 +08:00
melvin f2a0577ca0 removed DEFAULT from MagicAIImpl 2011-07-01 17:34:10 +08:00
melvin 270d0020d3 list of workers was not cleared between invokations 2011-07-01 17:33:30 +08:00
melvin 65775350f5 implement a more efficient backup 2011-07-01 16:39:02 +08:00
melvin 0f38288d17 increased size of cache for minimax to 100000 2011-07-01 15:57:11 +08:00
melvin acd114bd6e limit the size of the cache used in ArtificialScoreBoad to 10000 entries by using LinkedHashMap 2011-07-01 10:30:42 +08:00
melvin 1ff2a8f476 removed method sign and add parent as a parmeter to getScore 2011-06-30 21:00:00 +08:00
melvin 745c319c62 changed constant C to 1.0 2011-06-30 17:31:15 +08:00
melvin 18f7813f34 removed recording of length of playouts 2011-06-30 17:30:39 +08:00
melvin cce7667277 added MMAB class as a copy of ArtificialWorkerPool to clean up the minimax implementation for possible extensions and improvements 2011-06-30 11:05:24 +08:00
melvin a90b58c4bf removed effect of solved nodes during selection 2011-06-29 15:47:57 +08:00
melvin fcc3e9718b increased maxsim to 10000 to increase chance to catching a synchronization bug, use only 0 or 1 for randomPlay 2011-06-29 12:19:12 +08:00
melvin 9c9bf47abe changed reward to be in the range [0,1] 2011-06-29 09:39:14 +08:00
melvin df6a3c546a using default UCT for MCTSAI 2011-06-28 16:47:25 +08:00
melvin 75cf57dd91 choices are the root are only generated once, later traversals simply map the choices to the new Game object 2011-06-28 15:13:20 +08:00
melvin f5a65c074e added assert if MagicPermanentSet.getPermanent fails 2011-06-28 15:07:33 +08:00
melvin 76e990aec8 provide multiple methods for computing selection score, separate modification of score due to game theoretic value to a separate method 2011-06-28 14:12:17 +08:00
melvin 6fa49f851f moved node related methods to MCTSGameTree class 2011-06-28 12:10:36 +08:00
melvin 7fb54dcb59 changed initial ratio to 10/10, simplified selection score of loss node 2011-06-27 17:18:30 +08:00
melvin dc0368ef60 use Ratio for selection instead of UCT 2011-06-27 14:57:37 +08:00
melvin bd5ca1d29e compute the number of steps to win/lose in the solver 2011-06-25 12:35:41 +08:00
melvin b4b0aaa73a use equals to compare strings 2011-06-24 11:31:30 +08:00
melvin c8d2b67b5e make sure CHEAT is synchronized 2011-06-24 11:28:57 +08:00
melvin 27ccec8657 made capitalization of error messages more consistent 2011-06-24 10:46:35 +08:00
melvin b2162ce6fe fixed some problems indicated by findbugs 2011-06-24 10:42:42 +08:00
melvin a714778fd8 use fact choices during simulations 2011-06-21 15:36:52 +08:00
melvin 62b89cdaff print log message for cache when assertions are enabled 2011-06-21 11:46:20 +08:00
melvin a845cadc86 removed checksum and do not store strings in MCTSGameTree node 2011-06-20 14:24:44 +08:00
melvin 60e2c47f0d set ASSERT in constructor 2011-06-20 14:17:03 +08:00
melvin 4884508485 comment out logging of cache 2011-06-20 13:51:38 +08:00
melvin f39f6dad01 make sure player.getId returns a large number of avoid clashing with id of permanents 2011-06-20 12:18:50 +08:00
melvin d2048e0ee0 changed some methods to non-static so that it can access log method 2011-06-20 11:28:55 +08:00
melvin f7a4d19c6f combined two asserts, moved condition to check in checkNode 2011-06-20 10:42:00 +08:00
melvin 168dd68b07 added toString to game and print it out when assert fails 2011-06-19 21:54:58 +08:00
melvin e45355cc21 print path for each node added 2011-06-19 14:02:06 +08:00
melvin 180b7de4c5 moved checkNode to start of the loop 2011-06-18 23:55:38 +08:00
melvin 1156f07d65 moved print statements in check node to message in assert 2011-06-18 23:48:17 +08:00
melvin 742fd54723 added function to print path leading to corrupt node 2011-06-18 23:43:13 +08:00
melvin 9e5a95183e print debug output when adding nodes to cache 2011-06-18 10:59:05 +08:00
melvin 719d7ba84f in debug mode ignore strength, each round run exactly 500 simulations 2011-06-17 18:16:53 +08:00
melvin dbdf62fc0c reset score to zero each time so that it does not accumulate, accumulation of score may affect some of the choices, especially blocking 2011-06-17 16:35:17 +08:00
melvin 4b82e7e489 wrapped long lines 2011-06-17 14:18:00 +08:00
melvin 3d012964c9 commented out println 2011-06-17 13:53:48 +08:00
melvin 985394457a increased MAX_ACTIONS to 10000, commented out debug output when adding nodes to cache 2011-06-17 13:11:46 +08:00
melvin 21fcb13cba count number of actions performed instead of number of events, more fine grained 2011-06-17 11:48:15 +08:00
melvin efe5f69e11 fixed comments 2011-06-17 10:37:11 +08:00
melvin fa1f2ae0a4 replace getIndex with ordinal 2011-06-16 21:10:13 +08:00
melvin 9711281fc4 enabled checkNode 2011-06-16 17:41:39 +08:00
melvin 31269d9179 changed debug message 2011-06-16 17:25:01 +08:00
melvin 8c29a18188 Added MMABC, the version of MMAB that can see all cards 2011-06-16 15:44:07 +08:00
melvin 310eabfe60 print path leading to node 2011-06-16 15:12:14 +08:00
melvin 1af033ca60 combined log ouput, added isCached to each node to avoid compute gameId and checking the cache 2011-06-16 12:17:26 +08:00
melvin 1d53f3a43c correct some comments 2011-06-15 16:16:41 +08:00
melvin e7c9317174 make sure a node is only cached one, to reduce the number of times we need to compute the hash 2011-06-15 15:59:27 +08:00
melvin 34735c53ef show both simulations carried forward and actual number of simulations ran 2011-06-15 12:52:28 +08:00
melvin 4dfff7e4ce store string of choices in parent for debugging 2011-06-15 11:23:22 +08:00
melvin f7678111cb Added more asserts to catch problems early 2011-06-15 10:40:21 +08:00
melvin bbc514a606 enabled caching again, needs more testing 2011-06-15 09:59:08 +08:00
melvin 74cf2f8755 commented out caching, still broken 2011-06-14 15:59:59 +08:00
melvin 258f236154 error in checkNode fixed 2011-06-14 15:45:34 +08:00
melvin 41c5bda808 clear cache on a miss 2011-06-14 15:43:20 +08:00
melvin 98356b0895 added caching of game tree nodes 2011-06-14 15:24:07 +08:00
melvin 59fdcf86cc added two strength variables so that it will be possible to pit AI of different strengths against each other in the CLI deck strength calculator 2011-06-14 11:41:14 +08:00
melvin fcfc6e165d use getChoice instead of idx to retrieve choice from list 2011-06-14 11:27:42 +08:00
melvin 079e61d122 enabled checking of tree nodes 2011-06-13 16:57:45 +08:00
melvin ddc656f39e do not include time to generate root choices into time spent by MCTS, otherwise loop to generate tree will not run and root will have no children 2011-06-13 16:25:31 +08:00
melvin 354570656e commented out checking code 2011-06-12 17:40:00 +08:00
melvin 9e7ac40c95 only skip node or stop simulation if AI wins, otherwise continue to explore, expand the game tree until the time is up 2011-06-12 13:57:06 +08:00
melvin fc9fc6076c refactor some output code into a separate method 2011-06-12 10:30:08 +08:00
melvin e9650501a8 fixed two NPE in MCTSAI 2011-06-12 09:54:00 +08:00
melvin 78c18efaff print out all the nodes/choices if there is a discrepancy 2011-06-11 22:54:39 +08:00
melvin 4d4c9e1327 added more debugging/checks 2011-06-11 22:12:16 +08:00
melvin 5a15a4e198 removed caching stuff 2011-06-11 17:58:52 +08:00
melvin 3b5c015f8d amount of boosting for win/lose nodes configured by BOOST variable 2011-06-11 16:25:23 +08:00
melvin 9faef86e98 renamed simLengths to LENS as it is a global, added check that path size is at least 2 2011-06-11 15:40:25 +08:00
melvin 3680f20bb9 disable setting of main phases 2011-06-11 15:09:22 +08:00
melvin 6b62a71532 added setMainPhases, part of the AI framework depends on this being set 2011-06-11 14:48:10 +08:00
melvin 2edd9c076e remove handling of out of memory error 2011-06-11 14:19:49 +08:00
melvin 5494f14d11 if debug properly is defined, print logs 2011-06-11 14:02:31 +08:00
melvin ee469dae76 give better name to MCTSD 2011-06-11 13:56:31 +08:00
melvin be97975ba2 print event when out of memory 2011-06-11 13:55:05 +08:00
melvin bb12210c8c renamed some variables for clarity 2011-06-11 12:27:24 +08:00
melvin a4f82d525e display choices without using ArtificialChoiceResults 2011-06-11 11:45:40 +08:00
melvin c25dd9805c added solver capability 2011-06-11 11:10:50 +08:00
melvin 23cec53713 removed invalid, new method to count number of events executed 2011-06-10 22:09:40 +08:00
melvin 48123c83e0 removed printing of single choice 2011-06-10 21:46:59 +08:00
melvin 305cb7d564 added error handling, sometimes root has no children but there are choices 2011-06-10 21:42:45 +08:00
melvin 1237cb1fc9 fixed case where hasChoice but choices has size 0, this should not happen in normal situations 2011-06-10 18:11:33 +08:00
melvin 59833bc889 deal with no artifical choice by doing game.executeNextEvent 2011-06-10 17:13:26 +08:00
melvin 992b4885d7 disable caching of game state 2011-06-10 16:31:35 +08:00
melvin 8e911a9c0f changed C to 1.0, MAXEVENTS to 1000 2011-06-10 15:24:40 +08:00
melvin 0362c826f5 changed getRank to UCT, moved it back into MCTSAI, increased MAXEVENTS to 1000 2011-06-10 14:28:47 +08:00
melvin c16254c12c move calculation of rank into class MCTSGameTree 2011-06-10 14:23:20 +08:00
melvin 627196b2c1 added USE_CACHE variable to determine whether to use the cache 2011-06-10 14:09:02 +08:00
melvin bbc02bd315 remove illegal nodes before selecting best node 2011-06-10 13:36:56 +08:00
melvin 0c945d8fb7 use a separate pass to remove invalid nodes 2011-06-10 13:31:42 +08:00
melvin be5f734842 remove invalid node from game tree 2011-06-10 13:15:48 +08:00
melvin a67d5abb4f added LRU cache to keep track of recently added nodes 2011-06-10 12:03:27 +08:00
melvin 27d96b63fa always add ERROR! to log messages representing impossible situations 2011-06-08 11:47:26 +08:00
melvin 5429f4064b initialize best choice to first child of root 2011-06-08 10:54:04 +08:00
melvin 95e7412c32 removed some empty lines 2011-06-08 10:53:24 +08:00
melvin 1c53425f31 removed some empty lines 2011-06-08 10:53:09 +08:00
melvin 44ea2aabf7 added MCTSNC, non cheating version of MCTS 2011-06-07 20:57:29 +08:00
melvin 102ff9151a illegal idx will generate a null pointer exception instead of array out of bounds, more importantly the possible choices will be printed if logging is enabled 2011-06-07 12:43:37 +08:00
melvin 4eae9a30cc handle choice being null, MAXTIME is ArtificialLevel seconds 2011-06-07 10:32:35 +08:00
melvin 7b2606e6c9 added logging for generating options to MagicEvent to detect bottlenecks 2011-06-07 10:16:09 +08:00
melvin 157ef4c2a8 rewrite to use getSimulationChoiceResults during simulations 2011-06-07 09:53:35 +08:00
melvin bd5fa03e87 changed maxV's type to int 2011-06-06 17:36:16 +08:00
melvin 28127b6f37 changed formula for reward 2011-06-06 17:05:09 +08:00
melvin 7665bbde08 added logging of length of each simulation 2011-06-06 12:29:44 +08:00
melvin 503a5201d5 changed log/debugging messages to use stderr instead of stdout 2011-06-06 10:45:45 +08:00
melvin 4b1fc68412 use MagicRandom to seed the new Random objects for each worker 2011-06-04 16:51:33 +08:00
melvin bd53f4bacf only getArtificalChoiceResults once 2011-06-04 16:50:52 +08:00
melvin a35d78e3cd removed RND from supported AI because it does not make sense to play against a random opponent 2011-06-03 09:59:03 +08:00
melvin d6fef13896 removed default from list of supported ais so it does not appear in the UI 2011-06-03 09:58:22 +08:00
melvin cf536670af MagicRandom now uses seed defined by system property rndSeed if it is given, refactor other programs to use MagicRandom instead of creating their own rng 2011-05-27 15:36:29 +08:00
melvin 012b665b11 fixed some synchronization bugs found by findbugs 2011-05-26 17:16:51 +08:00
melvin 80eb0b3862 added debug version of MCTS called MCTSD 2011-05-23 10:17:07 +08:00
melvin f02252c4a8 removed annotation to suppress warnings when unused 2011-05-23 10:03:11 +08:00
ubeefx eb7cfc4eb4 Vegas AI. 2011-04-10 17:05:51 +00:00
ubeefx 570ed62f81 Improved scoring for equip. 2011-04-10 17:05:22 +00:00
melvinzhang@gmail.com f2a78100b2 reduced exploration and increased exploitation in MCTS AI 2011-04-10 14:35:57 +00:00
melvinzhang@gmail.com 74ad26153b added MCTS to list of supported AIs 2011-04-10 09:45:11 +00:00
melvinzhang@gmail.com f65fe29faf MCTS now can play games with hidden cards by making use of the number of main phases in the random simulation (prefer to win in fewer turns and lose in many turns) 2011-04-10 09:44:39 +00:00
ubeefx 2cfee094c6 Added selection of AI in preferences. 2011-04-09 10:06:08 +00:00
ubeefx 555d836493 Improved setting of known cards for AI. 2011-04-09 08:43:39 +00:00
melvinzhang@gmail.com 350fb91456 made logging configurable via the constructor, default constructor sets logging to false 2011-04-09 03:05:09 +00:00
melvinzhang@gmail.com 4ee43f37f5 treats the situation where the size of the list of choices is zero as a draw, previously tried to continue the game but gets stuck in a infinite loop 2011-04-09 03:00:06 +00:00
melvinzhang@gmail.com 27b5e62d6d accidentally commited version of MagicAIImpl used for testing MCTS, it sets MCTS as the default. Fixed by setting Minimax AI back to being the default 2011-04-09 01:49:56 +00:00
melvinzhang@gmail.com 3aeb7070f8 MCTS now works but it cheats by using the MagicGame constructor that allows it to see all the cards 2011-04-09 01:47:53 +00:00
melvinzhang@gmail.com 3df275480b refactored getNextMultiChoiceEvent to be flatter, reduce nestedness of statements, added condition to terminate AI when MAXTIME or MAXSIM is reached, store game.getScore in MCTSGameTree (not used at the moment) 2011-04-08 06:44:28 +00:00
ubeefx c0f00d6e86 Added card Lightning Greaves. 2011-04-07 20:30:31 +00:00
melvinzhang@gmail.com 11f29b3335 MCTSGameTree now implements iterable, so that we can use for each loop to go over all the children of a node, changed assert format 2011-04-07 09:19:23 +00:00
melvinzhang@gmail.com ee8282e4f7 added some asserts to help debug MCTS 2011-04-07 04:31:41 +00:00
melvinzhang@gmail.com ddf9b0559f fixed crash in MCTS, randomPlay still bugged (almost always returns that scorePlayer wins 2011-04-06 05:27:39 +00:00
ubeefx 1133f98b59 Small changes. 2011-04-05 17:21:32 +00:00
melvinzhang@gmail.com 5e45c342ad MCTS code now uncommented and can be tested, before this MCTS was making random moves 2011-04-05 03:31:42 +00:00
ubeefx e3e6a40176 Increased version to 1.11.
Replaced some card images.
AI code review and formatting.
2011-04-04 17:22:52 +00:00
melvinzhang@gmail.com 76281e3fc0 added initial attempt at implementing a Monte Carlo Tree Search AI, runs but still have bugs to be ironed out, can be selected from the command line as MCTS 2011-04-04 03:07:36 +00:00
melvinzhang@gmail.com e0e280783c AIs stored in MagicTournament, GameController gets the array of AIs from MagicTournament and invokes the appropriate one based on the player's index 2011-04-04 03:01:13 +00:00
ubeefx 57b6bb3e90 Support for infect keyword and poison counters.
6 infect creature cards.
2011-03-20 21:45:42 +00:00
ubeefx 38366a07e1 Configurable number of games and level for deck strength. 2010-12-23 15:20:39 +00:00
ubeefx b28d1895f7 Added support for milling and level up.
Added Student of Warfare, Sword of Body and Mind and Szadek, Lord of Secrets.
2010-12-15 23:29:27 +00:00
ubeefx 7fd13965b2 Initial version. 2010-11-21 18:54:59 +00:00