Fork me on GitHub
#clojure-uk
<
2018-12-30
>
folcon10:12:03

What was that macro library at clojurex? (If anyone remembers)…

folcon10:12:44

Also @dominicm, the new smash is definitely fun, thinking of getting myself a copy =)…

dominicm10:12:51

What was the macro library, vaguely?

dominicm10:12:27

Macrovich is my guess

folcon10:12:47

I was replying to your first question and you got it in one anyway 😃

dominicm10:12:13

I didn't even attend 😊

dominicm10:12:49

I'll have a look at smash later, added to my list 😊

folcon10:12:39

Have fun :)…

folcon11:12:02

I remember a fair bit of discussion around kafka log based stuff a few weeks back, and I’m wondering if anyone has any good libs for smaller scale use cases? Or are we in roll your own territory? I’ve been doing some game programming over the break and for today I’ve decided to throw away all the bits and start from scratch to see if it gives me anything interesting. I’m just looking at the ECS model and trying to come up with something different and thought it would be good to hear if anyone had any alternatives. I’m looking for an event based approach that’s reasonably performant where I can model a largish number of entities where as much as possible: 1) I want to keep the model as data so I can introspect it and modify it. 2) All the parts can be quite composable, so adding new behaviour is linear, not exponential. 3) You can reason about parts relatively independently… I’m trying to keep an open mind for what would be a good fit, but so far I’ve thought about core.async, protocols as well as some kind of pedestal style interceptors…

👀 4
Rachel Westmacott17:12:52

This sounds super interesting - I’d love to hear how you get on with this.

folcon12:01:07

Sure, no problem :)….

folcon12:01:40

At the moment one of the things I’ve been looking at is how board games et al are taught/instructed? You have some high level concepts like attack or move and then special vs general rules for them as well as how specifically they’re combined together… I’ve also sorta got attacking/defending working how I want at the moment, just trying to work out how it works with other bits…

Rachel Westmacott11:01:47

is this clj or cljs?

alexlynham13:12:16

if all your code is happening in one process (or one one machine, at least) then an evented model wouldn't necessarily mean you needed an explicit queue I think - in my head it seems more like the core async type model for managing the events should be good enough?

alexlynham13:12:41

the use case for most of that stuff is distributed compute mainly

alexlynham13:12:53

(where 'that stuff' means kafka, kinesis etc etc)

folcon13:12:27

It’s basically a clojurescript+clojure client/server setup, though there is a coordination problem for the future, I would like to make it multiplayer if possible. I’ve done some stuff with sente which works separately, so it’s not integrated with this stuff…

folcon13:12:41

I mean there’s no problem making it client only for the moment, I’m still noodling around to see what works

alexlynham14:12:48

I guess you could use websockets for the client/server interface? Then at least on paper you've got a way of moving events back and forth at the cadence they're created? (sorry if I've misunderstood)

folcon14:12:15

Yep websockets is exactly what I’m doing for that =)…

folcon14:12:26

So to give you an idea of some of the things I’ve been trying to do here are some tests. (I’ve called my function foo as I’m not sure exactly what it’s conceptual scope is, so I’m deferring giving it a name…)

folcon15:12:28

Something like this:

(deftest combat-tests
  (testing "a functioning shield component blocks some attack event damage"
    (is (= (foo {:topics #{:attack} :damage 8}
                {:name :basic-shield
                 :description "A simple shield"
                 :topics #{:attack :block}
                 :block {:fn [- 3]}})
           {:topics #{:attack} :damage 5}))
    (is (= (foo {:topics #{:attack} :damage 8}
                {:name :broken-shield
                 :description "A broken shield"
                 :topics #{:attack :block}})
           {:topics #{:attack} :damage 8})))

  (testing "a functioning aura of invulnerability component blocks all attack event damage"
    (is (= (foo {:topics #{:attack} :damage 8}
                {:name :aegis-aura
                 :description "A aura of invulnerability"
                 :topics #{:attack :block :aura}
                 :block {:fn [:min 0]}})
           {:topics #{:attack} :damage 0}))
    (is (= (foo {:topics #{:attack} :damage 8}
                {:name :disrupted-aegis-aura
                 :description "A disrupted aura of invulnerability"
                 :topics #{:attack :block :aura}})
           {:topics #{:attack} :damage 8}))
    (is (= (foo {:topics #{:attack} :damage 8}
                {:name :perfect-aegis-aura
                 :description "An aura of invulnerability that invalidates the attack"
                 :topics #{:attack :block :aura}
                 :block {:warp (fn [_] nil)}})
           nil)))

  (testing "a functioning elemental resistance component blocks some elemental attack event damage"
    (is (= (foo {:topics #{:attack :fire} :damage 8}
                {:name :elemental-fire-resistance
                 :description "Fire elemental resistance"
                 :topics #{:attack :block}
                 :block {:when #(contains? (:topics %) :fire) :fn [- 3]}})
           {:topics #{:attack :fire} :damage 5}))
    (is (= (foo {:topics #{:attack :fire} :damage 8}
                {:name :elemental-ice-resistance
                 :description "Ice elemental resistance"
                 :topics #{:attack :block}
                 :block {:when #(contains? (:topics %) :ice) :fn [- 3]}})
           {:topics #{:attack :fire} :damage 8}))))
(sticking it in a thread so as to not clog up the channel =)…)

folcon15:12:57

@U79NZHC6A Not sure that doing it this way is a good idea, but it’s the best concept I’ve come up with so far… Once these bits all work then I’ll just have to work out how to hang them off entities so that things like entities colliding trigger attack actions etc…

folcon15:12:34

So if this works, I can create new items and functionality with a very small core of primitives =)… Hopefully it’ll also be beginner friendly. One annoyance however is that I can’t introspect the function as it’s already resolved, so telling what fn it is isn’t great, hopefully it won’t be a problem in practice…

folcon15:12:12

huh, slack doesn’t do github style code formatting?

dominicm15:12:37

Zulip does though

folcon15:12:22

yea, looking on twitter it seems to be an ongoing feature request for a few years now…