VedalAI / neuro-amongus

Among Us Plugin for Neuro-sama
GNU General Public License v3.0
531 stars 50 forks source link

"LGTM!" #34

Closed Alexejhero closed 1 year ago

Alexejhero commented 1 year ago

Vedal let me out please it's cold down here


Changes made in this pull request


❗ Neural network broken, pls fix


Co-authored by @alekso56

Closes #14 Closes #29 Closes #36

alekso56 commented 1 year ago

When socket is not connected on startup, the player is forced to walk down forever.

Alexejhero commented 1 year ago

When socket is not connected on startup, the player is forced to walk down forever.

That was on purpose to test the movement handler, but it's been removed since.

The python side has not been updated to integrate with the new socket serialization system anyway.

alekso56 commented 1 year ago

Im curious, if you are going to send partial strings anyways, why not make a data class and then send that as json then decode as json on python side?

Alexejhero commented 1 year ago

Im curious, if you are going to send partial strings anyways, why not make a data class and then send that as json then decode as json on python side?

JSON has a lot of fluff (for example the name of the keys is repeated in every object) so it's very inefficient for socket purposes. Additionally, since we want to be saving this data to a file, we want the file to be as small as possible.

alekso56 commented 1 year ago

maybe can do something like this on python side, com protocol is currently sending zero data from the client, so might want to fix that first.


from dataclasses import dataclass

from numpy import byte

from bytechomp import Reader

@dataclass
class PositionData:
    TotalDistance: float
    NextNodePositionX: float
    NextNodePositionY: float

@dataclass
class DeadBodyData:
    ParentId: byte
    LastSeenPositionX: float
    LastSeenPositionY: float
    FirstSeenTime: float
    NearbyPlayersCount: byte
    NearbyPlayers: list[byte]

@dataclass
class DoorData:
    position: PositionData
    IsOpen: bool

@dataclass
class VentData:
    position: PositionData
    ConnectingVentsCount: byte
    ConnectingVents: list[PositionData]

@dataclass
class OtherPlayerData:
    id: byte
    LastSeenPositionX: float
    LastSeenPositionY: float
    LastSeenTime: float
    TimesSawVent: byte
    RoundTimeVisible: float
    GameTimeVisible: float

@dataclass
class Frame:
    seenBodiesCount: byte
    seenBodies: list[DeadBodyData]
    DidKill: bool
    SabotageUsed: byte
    DoorsUsed: byte
    DidReport: bool
    DidVent: bool
    NearbyDoorsCount: byte
    NearbyDoors: list[DoorData]
    NearbyVentsCount: byte
    NearbyVents: list[VentData]
    LastSeenCount: byte
    LastSeen: list[OtherPlayerData]

def read(stream):
    print("Creating frame from byte array")
    reader = Reader[Frame]().allocate()
    if reader << stream.read(512):
        # construct dataclass
        my_struct = reader.build()
        reader.clear()
        return my_struct
Alexejhero commented 1 year ago

This PR will be ready for a re-review once I've added deserialization on the python side

Vedal987 commented 1 year ago

idk probably fine