async def on(self, ctx, member: discord.Member): """<member>::::admin:Removes member from bot.blacklist""" if not member.id == ctx.author.id: if member.id in self.bot.blacklist: self.bot.blacklist.remove(member.id) save(self.bot) else: await ctx.send(f"You cannot **`{self.bot.command_prefix}on`** yourself!")
async def off(self, ctx, member: discord.Member): """<member>::::admin:Appends member to bot.blacklist""" if not member.id == ctx.author.id: if not member.id in self.bot.blacklist: self.bot.blacklist.append(member.id) save(self.bot) else: await ctx.send(f"You cannot **`{self.bot.command_prefix}off`** yourself!")
async def reject(self, ctx, member: discord.Member): """<@user>::::admin:Rejects all eval directives from given user. This is enabled by default.""" if ctx.author.id != member.id: if member.id in self.bot.whitelist: try: self.bot.whitelist.remove(member.id) save(self.bot) except Exception as e: print(e) await ctx.send(f'Acknowledged. Overridden permissions for user `{member.display_name}`.') else: async with ctx.channel.typing(): await ctx.send('Acknowledged. Initiating recursion sequence...') await asyncio.sleep(10)
async def help(ctx, command: str=None): """<command>:::::Seriously?""" command = command or None if not command: embeds = await utility.generator(ctx.author, bot) del embeds[-1] await ctx.message.delete() for embed in embeds: embed.set_footer(text=f'Page {embeds.index(embed) + 1}/{len(embeds)}') message = await ctx.send(embed=embeds[0]) for emoji in ['\N{LEFTWARDS BLACK ARROW}', '\N{BLACK RIGHTWARDS ARROW}', '\N{CROSS MARK}']: await message.add_reaction(emoji) bot.help_data[message.id] = {} bot.help_data[message.id]["embed_list"], bot.help_data[message.id]["index"], bot.help_data[message.id]["author_id"] = embeds, 0, ctx.author.id utility.save(bot) else: await utility.search(bot, ctx, command)
async def reutils(self, ctx): """::::admin:Resets `bot.help_data`, `bot.blacklist`, and `bot.whitelist`.""" self.bot.utils["blacklist"] = [] save(self.bot)
self.Q[visit] += alpha * (reward - self.Q[visit]) def get_value_function(self, dealer, player): V = np.zeros((len(player), len(dealer))) for d in dealer: for p in player: visit_hit = "%d:%d:%d" % (d, p, CONST.HIT) visit_stick = "%d:%d:%d" % (d, p, CONST.STICK) if self.Q[visit_hit] > self.Q[visit_stick]: V[p - 1, d - 1] = self.Q[visit_hit] else: V[p - 1, d - 1] = self.Q[visit_stick] return V def __str__(self): return 'MC' if __name__ == '__main__': mc = MonteCarlo() run(mc) write(CONST.OUTPUT_PATH + "checkQ", mc.Q) print("\nPlotting Value Function") plot(mc, r'Optimal Value $V^*$', CONST.OUTPUT_PATH + "MC_Optimal") print("\nSaving Monte Carlo Q Value") save(CONST.MCQ, mc.Q)
async def clear_help_data(self): self.bot.help_data = {} save(self.bot)