game.players[r] - 1) full_profile[r][s] += 1 else: full_profile[r] = FullGameProfile(reduced_profile[\ r], game.players[r]) profiles.append(Profile(full_profile)) return profiles from GameIO import readGame, toJSON, io_parser def parse_args(): parser = io_parser() parser.add_argument("type", choices=["DPR", "HR", "TR"], help="Type " + \ "of reduction to perform.") parser.add_argument("players", type=int, default=[], nargs="*", help= \ "Number of players in each reduced-game role.") return parser.parse_args() if __name__ == "__main__": args = parse_args() game = readGame(args.input) players = dict(zip(game.roles, args.players)) if args.type == "DPR": print toJSON(DeviationPreservingReduction(game, players)) elif args.type == "HR": print toJSON(HierarchicalReduction(game, players)) elif args.type == "TR": print toJSON(TwinsReduction(game))
maximal=False if new_sg in subgames or new_sg in maximal_subgames: continue if any([IsSubgame(new_sg, g) for g in \ subgames.union(maximal_subgames)]): continue subgames.add(new_sg) if maximal: sg = Subgame(full_game, sg.strategies) if len(sg) > 0: maximal_subgames.add(sg) return sorted(maximal_subgames, key=len) from GameIO import readGame, toJSON, io_parser from json import dumps def parse_args(): parser = io_parser() parser.add_argument("-known", type=str, default="[]", help= \ "File with known complete subgames. Improves runtime.") return parser.parse_args() if __name__ == "__main__": args = parse_args() game = readGame(args.input) subgames = readGame(args.known) print dumps(toJSON(*Cliques(game, subgames)))