Giter Site home page Giter Site logo

Comments (6)

helins avatar helins commented on June 1, 2024

Granted the examples in the README are a bit too abstract. I was trying to target an audience that wouldn't be familiar with the concepts (and complexity) of typical simulation examples. But overall, it remains too complex I believe.

In spite of your copy/paste adventures, did you manage to get somewhere?

from dsim.cljc.

Folcon avatar Folcon commented on June 1, 2024

Hi @helins, I got a bit further, but one thing I'm having difficulty with is working out how to manage the sim alongside the main application.

The context I'd like to use it in is game development, most of my existing experiments are based around using quil and I'm basically trying to figure out how to plug them together.

I don't have a ton of time to experiment this weekend, but hopefully the following one =)...

from dsim.cljc.

helins avatar helins commented on June 1, 2024

Yes to me it is rather obvious because this is the kind of things I had in mind when designing this library but I can see that people are struggling to get there. The API is somewhat different from what is usually encountered. Once you get it, I believe it suddenly becomes a lot easier.

For a game, this section is more important, the whole ideas about "flows": https://github.com/helins/dsim.cljc#continuous-and-hybrid-simulation-

Sorry for my late replies, I am on too many front these days but I am interested in knowing how you manage (if you find the time to do it :) ).

from dsim.cljc.

Folcon avatar Folcon commented on June 1, 2024

@helins: I'm working in this area again and reviewing this library with a view to use it and I think part of the problem is that's it's less than clear how it's supposed to be utilised, there's not exactly any example code that outlines how it's supposed to work.

Before I get into any of this, I'm sorry if I'm coming off as a bit of an ass, I'm finding the situation a little frustrating as from what I can tell this lib really does check off a lot of the boxes in terms of what I want a discreet event sim to do, but not being able to know how to work it is really frustrating.

Having said that, I have a game-sim thats using this to track state, I'll have a few very simple forms and questions:

  1. How do I find out when the "next" event is in the sim? Or even advance the sim? For example, if this was collection like, I might for example call peek and get back an event which is the "next" event, with some time value, then essentially ignore the sim in my game until my game's internal clock says I've arrived at that time value, at which point I fire that event and then call peek again to see what's next.
  2. How do I fire an event that is:
    2.a) One off
    2.b) Periodic
    2.c) Dependent on another event
    2.d) Dependent on two different events

The reason I'm asking these is that the examples you're providing aren't quite clear, for example I run this:

(defn feeling-happy
  [ctx]
  (assoc-in ctx
    (conj (dsim/path ctx)
      :mood)
    :happy))

(def lazy-run
  (dsim/historic (dsim/ptime-engine)))

(def ctx
  (run (dsim/e-conj {}
         [42]
         [:me]
         feeling-happy)))

(def history
  (lazy-run ctx))

(identity history)
=> ()

Now I was assuming that history would contain the event, no idea why it doesn't.

This is also really weird:

(dsim/e-conj {}
    [42]
    [:characters :little-prince]
    feeling-happy))
=>
#:dvlopt.dsim{:events {42 {:characters {:little-prince #object[clojure.lang.PersistentQueue
                                                               0x344cfda8
                                                               "clojure.lang.PersistentQueue@73d9b0ab"]}}}}
(->
    (dsim/e-conj {}
        [42]
        [:characters :little-prince]
        feeling-happy)

    (dsim/e-get))
=> nil

I mean in the docs you say:

;; Fetches the current working queue, maybe for modifying it and using 
;; `e-assoc` to put it back.
;;
(dsim/e-get ctx)

But when I use it I get nil? Is this a bug? Is this expected behaviour? I have no idea...

The model I have for Discrete Event Simulation is I have some state which is the current sim and a queue, which can be contained within the state, I can query the state to get a snapshot of the world, then look at the queue to see when the next thing will happen. I'm not even super sure if that's the model you're using or if I should have some subtly different model?

The docs you have are laid out like a reference to someone who already clearly understands how everything works, but doesn't cover the basics of what I'm supposed to do or how I should think about this.

An alternative approach is if you could provide an example or just a list of functions which should be used to do specific things.

from dsim.cljc.

helins avatar helins commented on June 1, 2024

Granted those docs are not for everyone from what I see. I've received both praises and criticisms, both from knowledgeable users as well as newcomers (e.g. web developers). It makes a lot of sense to some, less sense to others. Unfortunately I do not have to the time to write more on the subject. This library is very large in scope and really quite different from what is usually seen, so making the docs beginner-friendly for everyone is a significant task.

from dsim.cljc.

Folcon avatar Folcon commented on June 1, 2024

@helins, that's fair. I'll see what I can do with what's here.

from dsim.cljc.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.