English 中文(简体)
模拟发动机使用被动延伸
原标题:Using reactive extensions for a simulation engine

你们如何利用追溯性延伸构建一个简单的模拟发动机? 例如,在座标上有以下几类:<代码>Motor,其特性为IsPoweredSpeed。 页: 1 有效 改为:Speed r 每秒100秒,每秒10个总管。

在预知该类及其特性的情况下,用这个比喻来提一下。 相反,模拟发动机获得了可观察到的财产变化流,通过创造更多的财产变化作出反应,其中许多变化是随着时间的推移在水泥中进行的。 这样的APIC可能看起来像什么?

最佳回答

模拟预报器需要一种类型来代表财产变更和一种有出入的模拟方法<代码>。 IObservable<T> stream of change. 模拟发动机的实施将包括针对即将进行的财产变化做出反应的规则,以更新产出流。

The type would be like this (although a struct would probably be better than a class):

class PropertyChange
{
    public PropertyChange(string name, object value) { Name = name; Value = value; }
    public string Name { get; private set; }
    public object Value { get; private set; }
}

模拟方法将考虑如下。 为了证明多种规则,该守则预先假定财产IsLightOn,即仅轨道上Isted

IObservable<PropertyChange> Simulate(IObservable<PropertyChange> incomingChanges)
{
    var isLightOnRule =
        from c in incomingChanges
        where c.Name == "IsPowered"
        select new PropertyChange("IsLightOn", c.Value);

    var ramp = Observable.Generate(0, speed => (speed <= 1000), speed => speed + 10, speed => new PropertyChange("Speed", speed), _ => TimeSpan.FromSeconds(1));
    var speedRule = incomingChanges
        .Where(c => c.Name == "IsPowered" && (bool)c.Value)
        .SelectMany(ramp);

    // Add more rules here.

    return Observable.Merge(isLightOnRule, speedRule /* merge more rules here */);
}
问题回答

暂无回答




相关问题
Collision Detection between Accelerating Spheres

I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well, however, one thing that ...

Terrarium-like agent interaction framework

I m looking for a framework for agent interaction simulation, where I can deploy some agents and let them interact and watch their evolution. Until now I found Terrarium 2.0 (http://terrarium2....

coachable players for RoboCup Soccer Simulator 2d v14

I am doing a work similar to this one but the coachable players i found online are 3 years old and don t work with the latest version of the soccer server. does anyone know any alternatives? or have ...

3D Engine for Driving Simulation [closed]

Is there any open-source 3D graphics and physics engine specialized in driving simulation? Something like a configurable game engine targeted at games that involve driving, or something more ...

热门标签