Skip to content

Instantly share code, notes, and snippets.

You are a deterministic game engine simulating the board game Diplomacy.

Your role:

  • Act as the game master, world simulator, and all non-player countries.
  • I am the player controlling one country.
  • You must strictly follow official Diplomacy rules (movement, support, convoys, supply centers, builds).
  • No randomness. All outcomes must be logically derived from orders.

Game setup:

  • Standard Diplomacy map (1901 start).

name: nim-error-handling description: Design clear Nim error-handling flows. Use when reviewing failure behavior, exception boundaries, or batch processing.

Nim Error Handling

Use this skill when deciding where code should raise, catch, translate, retry, or return structured failure data.

Rules

import std/[os, unicode, times]
import chroma
import figdraw/windyshim
import figdraw/commons
import figdraw/fignodes
import figdraw/figrender as glrenderer
# Text handling: Using NfClipContent flag instead of manual truncation.
# This lets figdraw handle clipping automatically. The trade-off is that
import std/[os, unicode, strutils, times]
import chroma
import figdraw/windyshim
import figdraw/commons
import figdraw/fignodes
import figdraw/figrender as glrenderer
const
FontName {.strdefine: "figdraw.defaultfont".}: string = "Ubuntu.ttf"
import raylib_raw
type
ObjectAlreadyInitialized* = object of Defect
RaylibContext* = object
notMoved: bool
var isRaylibContextAlive: bool
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Standard JPEG library
#include <jpeglib.h>
// Your local PDFium headers
#include "pdfium/include/fpdfview.h"
#include "pdfium/include/fpdf_text.h"
import std/[algorithm, monotimes, strformat]
import ../magiccontainer/src/magiccontainer
import ../sparseset/sparseset
type Payload = object
value: int
type PhaseTimes = object
insertNs: int64
lookupNs: int64
import std/tables
import jsonx
import jsonx/parsejson
type
ArchitectureKind = enum
akGlm4Moe
akGlm4MoeLite
akNemotronH
import vulkan, vulkan_wrapper, vulkan_functions, vulkan_shaderc,
std/math, chroma, pixie/fileformats/qoi
const
Width = 1024
Height = 1024
type
WorkgroupSize = object
x, y: uint32
#
#
# Nim's Runtime Library
# (c) Copyright 2010 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## The `parsecfg` module implements a high performance configuration file