How jayson-aron/robot-worlds works
Project type and purpose
• This is a Java-based, Maven multi-module client–server game called “Robot-Worlds.”
• The server hosts an in-memory grid world and listens for TCP connections; the client launches robot instances, sends commands, and renders responses.
File structure
• Top-level POM (pom.xml) aggregates two modules:
• server/ – implements the game world, server protocols, command handlers, world state generators, console interface, and an optional GUI renderer (guiworldstate).
• client/ – implements networked clients, robot classes (Recon, Sniper, Assassin, Soldier), session/instance handlers, and client-side protocols.
• worlds_config and client_config live at the root to configure world parameters (grid size, visibility, respawn times, etc.) and client’s target IP/port.
• A third-party library (java-turtle-1.0-SNAPSHOT.jar) under libs/ provides drawing utilities for rendering the world (used by server’s GUI or client diagnostics).
• Both modules include unit tests for protocols and core logic.
README for additional insights
• The server is started by running server.jar; it reads worlds_config, spins up SimpleServer, and accepts console commands (e.g., dump, purge).
• Clients run client.jar, read client_config, connect over TCP, and instantiate robot threads to interact with the world using a request/response protocol.
a. Main components
• Client Module
– SimpleClient (entry point)
– SessionHandler / InstanceHandler
– AbstractRobot and subclass implementations (Recon, Sniper, etc.)
– RequestProtocol, ResponseProtocol
– Client configuration loader
• Server Module
– SimpleServer (entry point)
– ServerService / MultiServers (manages connections)
– RobotHandler (per-connection robot lifecycle)
– World (in-memory grid), ObstacleGenerator, PitsGenerator, Mines
– Command modules (Command, BackCommand, FireCommand, etc.)
– Protocol classes (RequestProtocol, ResponseProtocol)
– ConfigHandler (loads worlds_config)
– GUIWorldState (optional visual renderer)
• External Dependencies
– TCP/IP network transport
– java-turtle library
– client_config, worlds_config files
b. Relationships and interactions
1. Client reads client_config → initializes SimpleClient → connects to server TCP socket.
2. User or automated robot logic triggers AbstractRobot actions → SessionHandler packages them into RequestProtocol messages → sends over socket.
3. ServerSimple accepts connection → wraps in ServerService → hands off to RobotHandler.
4. RobotHandler parses RequestProtocol → dispatches to Command classes → updates World state (positions, obstacles, mines).
5. ServerService packages world updates into ResponseProtocol → sends back to client.
6. Client SessionHandler parses ResponseProtocol → updates robot’s view → robot logic or UI renders state.
c. Architectural patterns and design principles
• Modular separation: network protocols, command handling, world state, and client logic are cleanly separated into packages.
• Factory/config pattern: ConfigHandler decouples configuration from code.
• Command pattern: each robot/server action is encapsulated in a Command class.
• Single Responsibility: World management, protocol serialization, and rendering are in distinct classes.
• In-memory model: No external database, world state lives in memory.
d. Key technologies, frameworks, libraries
• Java 11, Maven multi-module build
• Java sockets for TCP communication
• JUnit for unit tests
• Custom java-turtle library for rendering
Elements
• Clear component labels (e.g., “Client: SimpleClient,” “Server: SimpleServer”)
• Loading of config files → ConfigHandler
• TCP connections (Client → Server)
• Message flow (RequestProtocol → ResponseProtocol)
• Command dispatch (Protocol → Command classes → World)
• Blue for client-side modules
• Green for server-side modules
• Yellow for shared protocol classes