Skip to main content

AI驱动的物理游戏引擎 - 聚合设计

Project description

NexusFine

Physics engine for 2D/3D game prototyping with optional AI acceleration.

Installation

pip install NexusFine

Quick Start

from nexusfine import NF

api = "sk-xxxxxx"
x = "x_axis"
y = "y_axis"

NF(api)
NF(x)
NF(y)
NF(x, y)
NF("Game.exe")

Modules

Module Description Provides
NF Bullet physics Bullet(), Steam()
NB Ball physics Ball()
NC Cloud physics Cloud()
NS Configuration config(), apply()

Physics Objects

Bullet

from nexusfine import NF

bullet = NF.Bullet(
    x=0, y=10,
    vx=5, vy=0,
    gravity=300
)
bullet.update(0.016)

Ball

from nexusfine import NB

ball = NB.Ball(
    x=0, y=5,
    radius=10,
    gravity=300,
    bounce=0.8,
    ground_y=600
)
ball.update(0.016, width=800, height=600)

Cloud

from nexusfine import NC

cloud = NC.Cloud(
    x=0, y=5,
    vx=0.5, vy=0.1
)
cloud.update(0.016)

Steam

from nexusfine import NF

steam = NF.Steam(
    x=0, y=0, z=0,
    rise_speed=0.5,
    diffusion=0.3
)
steam.update(0.016)

AI Configuration

Enable AI with DeepSeek

from nexusfine import NB, NS

api = "sk-your-deepseek-key"
NS.apply(NB, mode="A", duration=60)
NB(api)
NB("x")
NB("y")
NB("x", "y")

NB.set_ai("deepseek")

ball = NB.Ball(x=400, y=300, radius=20)
ball.engine = NB
ball.update(0.016, 800, 600)

Enable AI with OpenAI

NB.set_ai("openai", model="gpt-3.5-turbo")

Enable AI with Local Ollama (Free)

NB.set_ai("ollama", model="llama3.2", api_base="http://localhost:11434/api/generate")

Mode Reference

Mode Description AI Status
A AI Enhanced Enabled
B Balanced Enabled
C Local Only Disabled
from nexusfine import NF, NS

NS.apply(NF, mode="C", duration=60)

Parameters Reference

Bullet Parameters

Bullet(x, y, vx, vy, gravity)
Parameter Description Default
x Initial X position 0
y Initial Y position 0
vx Initial X velocity 5
vy Initial Y velocity 0
gravity Gravity (pixels/sec²) 300

Ball Parameters

Ball(x, y, radius, gravity, bounce, ground_y)
Parameter Description Default
x Initial X position 0
y Initial Y position 0
radius Ball radius 10
gravity Gravity (pixels/sec²) 300
bounce Bounce coefficient (0-1) 0.8
ground_y Ground position 600

Ball.update(dt, width, height)

  • dt: Time step
  • width: Screen width (enables wall collision)
  • height: Screen height (enables wall collision)

Cloud Parameters

Cloud(x, y, vx, vy)
Parameter Description Default
x Initial X position 0
y Initial Y position 0
vx X velocity 0.5
vy Y velocity 0.1

Steam Parameters

Steam(x, y, z, rise_speed, diffusion)
Parameter Description Default
x Initial X position 0
y Initial Y position 0
z Initial Z position 0
rise_speed Upward speed 0.5
diffusion Spread amount 0.3

AI Providers

Provider Type Key Format Setup
DeepSeek Cloud sk-xxxxxx Get from platform.deepseek.com
OpenAI Cloud sk-xxxxxx Get from platform.openai.com
Ollama Local Not required Install ollama.ai

Fallback Behavior

When AI is enabled but fails (network error, invalid key, timeout):

  • The engine automatically falls back to local physics
  • Your game continues running without interruption
  • No manual error handling required

Requirements

Python >= 3.6
requests >= 2.25.0

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexusfine-1.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexusfine-1.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nexusfine-1.0.3.tar.gz.

File metadata

  • Download URL: nexusfine-1.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusfine-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5d372e8027b02909128e4d2bbe394579ea81054ae6bd1bcf873347e35a223a45
MD5 2570cd41cd9f93bb53ab27b13db183a5
BLAKE2b-256 4c08b3a67dcc635988ab4587052268023d92de9512cb0218f7eb280fed5c9fd5

See more details on using hashes here.

File details

Details for the file nexusfine-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: nexusfine-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusfine-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 75584cb5063c307ebad97366aa7eae12cd0b45b912e5e1c431867175d385be82
MD5 8f0b1da1a3e0b6e84bc92b3ae1c51c22
BLAKE2b-256 2bb321e27ef5eecf7a635801bd0706932c1bfbe6da65969f6a599c571a8ce637

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page