mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Type hints added
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -1,27 +1,28 @@
|
|||||||
import pwnagotchi.mesh.wifi as wifi
|
import pwnagotchi.mesh.wifi as wifi
|
||||||
|
|
||||||
range = (-.7, 1.02)
|
range: tuple[float, float] = (-.7, 1.02)
|
||||||
fuck_zero = 1e-20
|
fuck_zero: float = 1e-20
|
||||||
|
|
||||||
|
|
||||||
class RewardFunction(object):
|
class RewardFunction(object):
|
||||||
def __call__(self, epoch_n, state):
|
def __call__(self, epoch_n: float, state: dict[str, float]) -> float:
|
||||||
tot_epochs = epoch_n + fuck_zero
|
|
||||||
tot_interactions = max(state['num_deauths'] + state['num_associations'], state['num_handshakes']) + fuck_zero
|
|
||||||
tot_channels = wifi.NumChannels
|
|
||||||
|
|
||||||
h = state['num_handshakes'] / tot_interactions
|
tot_epochs: float = epoch_n + fuck_zero
|
||||||
a = .2 * (state['active_for_epochs'] / tot_epochs)
|
tot_interactions: float = max(state['num_deauths'] + state['num_associations'], state['num_handshakes']) + fuck_zero
|
||||||
c = .1 * (state['num_hops'] / tot_channels)
|
tot_channels: int = wifi.NumChannels
|
||||||
|
|
||||||
b = -.3 * (state['blind_for_epochs'] / tot_epochs)
|
h: float = state['num_handshakes'] / tot_interactions
|
||||||
m = -.3 * (state['missed_interactions'] / tot_interactions)
|
a: float = .2 * (state['active_for_epochs'] / tot_epochs)
|
||||||
i = -.2 * (state['inactive_for_epochs'] / tot_epochs)
|
c: float = .1 * (state['num_hops'] / tot_channels)
|
||||||
|
|
||||||
|
b: float = -.3 * (state['blind_for_epochs'] / tot_epochs)
|
||||||
|
m: float = -.3 * (state['missed_interactions'] / tot_interactions)
|
||||||
|
i: float = -.2 * (state['inactive_for_epochs'] / tot_epochs)
|
||||||
|
|
||||||
# include emotions if state >= 5 epochs
|
# include emotions if state >= 5 epochs
|
||||||
_sad = state['sad_for_epochs'] if state['sad_for_epochs'] >= 5 else 0
|
_sad: float = state['sad_for_epochs'] if state['sad_for_epochs'] >= 5 else 0
|
||||||
_bored = state['bored_for_epochs'] if state['bored_for_epochs'] >= 5 else 0
|
_bored: float = state['bored_for_epochs'] if state['bored_for_epochs'] >= 5 else 0
|
||||||
s = -.2 * (_sad / tot_epochs)
|
s: float = -.2 * (_sad / tot_epochs)
|
||||||
l = -.1 * (_bored / tot_epochs)
|
l: float = -.1 * (_bored / tot_epochs)
|
||||||
|
|
||||||
return h + a + c + b + i + m + s + l
|
return h + a + c + b + i + m + s + l
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
NumChannels = 233
|
|
||||||
|
|
||||||
def freq_to_channel(freq):
|
NumChannels: int = 233
|
||||||
|
|
||||||
|
def freq_to_channel(freq: int) -> int:
|
||||||
if 2412 <= freq <= 2472: # 2.4ghz wifi
|
if 2412 <= freq <= 2472: # 2.4ghz wifi
|
||||||
return int(((freq - 2412) / 5) + 1)
|
return int(((freq - 2412) / 5) + 1)
|
||||||
elif freq == 2484: # channel 14 special
|
elif freq == 2484: # channel 14 special
|
||||||
|
Reference in New Issue
Block a user