Commit Graph

9 Commits

Author SHA1 Message Date
Vladyslav Doloman
e555762c64 Protocol/Server: hybrid body TLV (2-bit vs RLE), state_full body builder, and partitioned snapshot on join
- Protocol: RLE packing, TLV chooser, body_2bit_chunk helper, state_full_body builder
- Server: on join, build snapshot body and partition across PART packets if over MTU; include apples only in first part; chunk single oversized snake with 2-bit chunking
2025-10-07 20:36:01 +03:00
Vladyslav Doloman
967784542d Protocol/Server: implement STATE_DELTA + PART partitioning and per-tick minimal changes
- Protocol: SnakeDelta structure; build_state_delta(_body); build_part
- Server: compute per-snake changes (move/grow/blocked-shrink), apples diffs
- Partition large deltas by snake changes with apples in first part; use update_id
- Send STATE_DELTA when under MTU; else PART packets referencing STATE_DELTA
2025-10-07 20:30:48 +03:00
Vladyslav Doloman
991b8f3660 Server: per-tick simulation skeleton (inputs, movement, blocking/shrink, apple growth, wrap behavior) and basic state delta broadcast
- Input buffer rules: enqueue+consume with 180° guard (len>1)
- Movement: wrap per config; allow moving into own tail when it vacates
- Blocking: head holds, tail shrinks to min 1
- Apples: eat= grow; ensure target apples after tick
- Broadcast: send current snakes/apples as delta (placeholder for real deltas)
2025-10-07 20:27:43 +03:00
Vladyslav Doloman
7a5f2d8794 Server: implement JOIN/JOIN_ACK/JOIN_DENY handling, input parsing/relay, spawn logic, apples maintenance; fix InMemoryTransport to address specific peer; add state_full encoder
- Protocol: join parser, join_ack/deny builders, input parser, state_full builder
- Server: on_datagram dispatch, spawn per rules (prefer length 3 else 1), join deny if no cell, immediate input_broadcast relay
- Model: occupancy map and helpers
- Transport: deliver to specified peer in in-memory mode
2025-10-07 20:22:22 +03:00
Vladyslav Doloman
9043ba81c0 Server scaffold: protocol + config + transport abstraction + tick loop skeleton
- Protocol: PacketType, TLV Body types, QUIC varint, header, input_broadcast
  and config_update builders, 2-bit body bitpacking helper
- Config/model: live-config ServerConfig, basic GameState/Snake/Session
- Transport: InMemoryTransport placeholder and QUIC server stub
- Server: asyncio tick loop, periodic config_update broadcast, immediate
  input_broadcast relay; main entry and run.py
2025-10-07 20:02:28 +03:00
Vladyslav Doloman
65bf835b8d Plan: adopt live config updates + spawn/edge/compression/browser decisions
- Tick rate default 10 TPS; live config via config_update, periodic resend
- Spawn policy: prefer length 3 if a straight strip fits; else length 1; deny join if no free cell
- Apples per snake: default 1; min 1, max 12; cap 255 total; live config
- Wrap edges: live-configurable; head-only enforcement on transitions
- Compression: DEFLATE is handshake-only (restart + reconnect)
- Browser targets: latest Firefox required; latest Chrome desirable
- Protocol: join_deny; config_update packet; input_broadcast includes base_tick + rel offsets and apply_at_tick
2025-10-07 19:15:50 +03:00
Vladyslav Doloman
5b7c302008 Plan: compact per-snake encoding + QUIC TLV + fragmentation-safe recovery
- Adopt 2-bit-per-section body with head (x,y) and len (u16)
- TLV framing with QUIC varints for body payloads; support RLE alternative
  and chunked variants for oversized snakes
- Periodic recovery and large updates partitioned to keep each compressed
  datagram <1280 bytes; pack whole snakes first, split only when a single
  snake exceeds the limit
- Canonical padding and strict validation rules (zero-pad last byte)

Rationale: minimize bandwidth and avoid IP fragmentation while keeping
decoding simple and robust.
2025-10-07 18:36:47 +03:00
Vladyslav Doloman
06083da592 Plan: input_broadcast + opponent prediction for late updates
- Server relays player inputs immediately as input_broadcast to others
- Clients mirror per-opponent buffers to predict movement when state
  updates are late or dropped; reconcile on next authoritative update
- Add ordering/dedup rules and reconciliation guidance
- Update testing and milestones to include prediction paths

Rationale: reduce perceived latency and jitter under packet loss.
2025-10-07 18:36:47 +03:00
Vladyslav Doloman
03969ebd99 Plan: initial multiplayer Snake design (server, client, protocol)
- Add PROJECT_PLAN.md outlining the core design:
  - Server: Python 3 asyncio, authoritative tick loop
  - Client: WebTransport (datagrams), canvas rendering, spectator overlay
  - Mechanics: blocked head + tail shrink, apples, colors, 60x40 field,
    continuous play, length as score, input buffer rules, 180° policy
  - Networking: datagrams, seq numbers + wraparound, delta/full updates,
    1280-byte budget, up to 32 players, names ≤16 bytes
  - Testing strategy and milestones

Rationale: establish a shared baseline for scope and interfaces.
2025-10-07 18:36:46 +03:00