23 Commits

Author SHA1 Message Date
Vladyslav Doloman
c4a8501635 Fix: indent await send(full, peer) inside STATE_FULL if block to resolve SyntaxError 2025-10-08 01:05:47 +03:00
Vladyslav Doloman
56ac74e916 Mode: implement MODE=net to run both WebTransport (HTTP/3) and QUIC datagram servers concurrently via MultiTransport; add port envs WT_PORT/QUIC_PORT 2025-10-08 01:00:47 +03:00
Vladyslav Doloman
b94aac71f8 Mode: add scaffolding for combined network mode name (net) in help; introduce MultiTransport 2025-10-08 00:53:14 +03:00
Vladyslav Doloman
7337c27898 Transport: add MultiTransport to run WT and QUIC concurrently and route sends 2025-10-08 00:51:35 +03:00
Vladyslav Doloman
921cc42fd4 CLI: add --help to print usage and env-based configuration hints 2025-10-08 00:33:07 +03:00
Vladyslav Doloman
99e818e0fd Fix: define _run_tasks_with_optional_timeout before use; tidy run_webtransport block 2025-10-08 00:29:18 +03:00
Vladyslav Doloman
1bd4d9eac7 Fix: clean up run.py newlines and indentation; add optional RUN_SECONDS timeout helper for server tasks 2025-10-08 00:27:10 +03:00
Vladyslav Doloman
eeabda725e Logging: add informative console logs for startup, ports, connections, JOIN/deny, input, and periodic events
- Configure logging via LOG_LEVEL env (default INFO)
- Log when servers start listening (WT/QUIC/InMemory/HTTPS static)
- Log WT CONNECT accept, QUIC peer connect, datagram traffic at DEBUG
- Log GameServer creation, tick loop start, JOIN accept/deny, config_update broadcasts, and input reception
2025-10-08 00:01:05 +03:00
Vladyslav Doloman
c97c5c4723 Dev: add simple HTTPS static server (serves client/). Enabled in WT mode by default via STATIC=1; uses same cert/key as QUIC/WT 2025-10-07 23:23:29 +03:00
Vladyslav Doloman
0ceea925cd Client: minimal browser WebTransport client (HTML/JS)
- index.html with connect UI, canvas renderer, overlay
- protocol.js with header, QUIC varint, JOIN/INPUT builders, STATE_FULL parser
- client.js to connect, send JOIN, read datagrams, render snakes/apples; basic input handling
2025-10-07 22:49:51 +03:00
Vladyslav Doloman
088c36396b WebTransport: add HTTP/3 WebTransport datagram server using aioquic; run mode switch via MODE=wt|quic|mem 2025-10-07 22:36:06 +03:00
Vladyslav Doloman
1f5ca02ca4 Repo hygiene: restore IDEAS.md; add .gitignore for __pycache__ and pyc; untrack cached bytecode 2025-10-07 20:54:56 +03:00
Vladyslav Doloman
e79c523034 Transport: integrate aioquic QUIC datagram server skeleton (QuicWebTransportServer) and QUIC mode in run.py
- New server/quic_transport.py using aioquic to accept QUIC connections and datagrams
- run.py: QUIC mode when QUIC_CERT/QUIC_KEY provided; else in-memory
- requirements.txt: aioquic + cryptography
2025-10-07 20:53:24 +03:00
Vladyslav Doloman
352da0ef54 Plan: refine networking — hybrid per-snake TLV selection, PART framing details, apples only in first part, and 1200-byte safety budget
- Clarify TLV selection between 2-bit and RLE per snake
- Define PART inner_type for STATE_FULL/STATE_DELTA and merging by update_id
- Apples included only in the first part (full and delta)
- Recommend ~1200-byte post-compression budget (<=1280 hard cap)
2025-10-07 20:46:16 +03:00
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