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 stepwidth: 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
Release history Release notifications | RSS feed
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.4.tar.gz
(8.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexusfine-1.0.4.tar.gz.
File metadata
- Download URL: nexusfine-1.0.4.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f983a3f92fc6f0d28995bee65a8736755516333a2f314214ca9c792a1d6aa19
|
|
| MD5 |
30751e427fa46748baa19379163bddc8
|
|
| BLAKE2b-256 |
bacb5ba348063b8c97382dbeaea3792b3ceb8596c9ab04a5d698e2e7c4f79755
|
File details
Details for the file nexusfine-1.0.4-py3-none-any.whl.
File metadata
- Download URL: nexusfine-1.0.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15dcf8fcb0ba00f9f32e45d4c84f53a8c633a2f120729e2b35c1adc0082da1b
|
|
| MD5 |
895148bace898e342d4d816566c050e7
|
|
| BLAKE2b-256 |
c2e393d677c336d69b642f03638432e8dc7ce83b652a9f38ec2f2e2348c3341d
|