Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AntiCheat:
- def __init__(self):
- self.players = {}
- self.baselines = {}
- def log_action(self, player_name, value):
- player = self.players.get(player_name)
- if player is None:
- player = Player(player_name)
- self.players[player_name] = player
- player.add_action(value)
- baseline = self.baselines.get(player_name)
- if baseline is None:
- baseline = self.calculate_baseline(player)
- self.baselines[player_name] = baseline
- if abs(value - baseline) > self.threshold:
- print(f"Detected unusual activity from player {player_name}: {value}")
- # Take appropriate action (e.g. ban player)
- def calculate_baseline(self, player):
- # Calculate baseline of normal behavior for player
- class Player:
- def __init__(self, name):
- self.name = name
- self.actions = []
- def add_action(self, value):
- self.actions.append(value)
Add Comment
Please, Sign In to add comment