Search Results
Searched for posts by vasiliy in all forums

Showing results 1 - 10 out of 431 total
Modify your search
Posted by vasiliy, Today at 9:33 am
by the way, that's how the LISP code meant to look like:
SPOILER ALERT. Click here to see text.
define vector-median(vec)
  ;; main quick-select algorithm
  define quick-select(vec l r k)
    define partition(vec l r pivot)
      ;; swap elements
      define swap(vec i1 i2)
        define l vector-ref(vec i1)
        vector-set! vec i1 vector-ref(vec i2)
        vector-set! vec i2 l
      ;; main partition code
      define value vector-ref(vec pivot)
      define sidx l
      swap(vec pivot r)
      while {l < r}
        if {vector-ref(vec l) < value}
          then
            swap vec l sidx
            inc! sidx
        inc! l
      swap vec sidx r
      sidx
    ;; main quickselect code
    if {l = r}
      then
        vector-ref(vec k)
      else
        let*  ;; Miho avoids creating lambda for this
          \\
            pivot {{r + 1 + l} div 2}
            new-pivot partition(vec l r pivot)
            diff {new-pivot - l}
          cond
            {k = diff}
              vector-ref(vec new-pivot)
            {k < diff}
              quick-select(vec l {new-pivot - 1} k)
            else
              quick-select(vec {new-pivot + 1} r {k - diff - 1})
  ;; we don't need fully sorted vector, so perform partition sort only
  let <* vlen vector-length(vec) *>  ;; still no lambda
    if {odd? vlen}
      then
        quick-select(vec 0 {vlen - 1} {vlen div 2})
      else
        (div (+ quick-select(vec 0 {vlen - 1} {{vlen div 2} - 1})
                quick-select(vec 0 {vlen - 1} {vlen div 2}))
             2)

nope, that's not Python. this is Scheme. not that intimidating anymore?

p.s.: edited to make the code even simplier-looking. it still works, yeah.
Posted by vasiliy, Aug 20 at 11:35 am
i just thought… should the death be as immediate as it is now?

what if we have the literal Grim Reaper to spawn, and the player is converted to an invincible ghost? initially the ghost is quite fast, so it is easy to outrun the Reaper, but as time passes, the gost becames slower and slower. the Reaper can go through walls too, of course. the idea is that the player can reach an altar of some diety he has good relations with, and pray for the new body. resurrection should have quite a huge cooldown, i think, but it might be fun.

of course, the players will immediately start dying just to explore the level in their new shiny etherial invincible form… which i see as a good advantage of this new mechanic.

outrunning Grim Reaper — what could be more silly than this? so i believe that it definitely fits into IVAN.
Posted by vasiliy, Aug 7 at 7:11 pm
why not? nothing special used in the code, and i am not using winapi directly. so if the compiler, sdl2 and other libs aren't doing something special too — it should work.

tbh, i don't even need sdl. the only thing i am using sdl for is to init OpenGL, and to have the unified event loop across platforms. i could easily switch to OpenAL+libopus for sound, so sdl2_mixer is not reqlly required too. for my Oberon/Ur system (which i am using to code my small 2d games) i did exactly that: wrote simple lib to init OpenGL on win32 and X11, and OpenAL wrapper. works like a charm.

i am simply too lazy to rip out sdl and rewrite my Oberon code to C++. i'd better waste my time rewriting IVAN to Scheme: it would be useless too, but way, way more fun. (no, i'm not going to do that. at least not right now.)
Posted by vasiliy, Aug 3 at 4:01 pm
wrote second version of Scheme. the third is coming. still 0 lines of IVAN code. i am starting to think that i made a mistake somewhere…
Posted by vasiliy, Jul 21 at 8:38 am
it is absolutely impossible to stop improving Scheme compiler once you made it work. somehow i feel that in a year i will have self-hosted Scheme system which compiles to optimised machine code. and, of course, 0 lines written for IVAN scripting.
Posted by vasiliy, Jul 20 at 12:22 am
so, i created minimalistic Scheme implementation. it took ~5 days (i procrastinated a lot, it should've been done in 2 days or so). of course, it supports lexical closures, tail call optimisation and call/cc. now i have to invent some way to automate bindings creation — that's the real challenge. the engine uses bytecode compiler with closure optimisation, and it is quite fast. actually, much faster than i need it to be.

the idea is to create "scriptable entity" as a separate entity class, and then gradually convert other entities to scriptables. this way i won't need to convert the whole codebase in one go. the grand goal is to move all entities to Scheme, but this may take decades to complete. yet i need to start somewhere.
Posted by vasiliy, Jul 19 at 11:00 am
btw, 64-bit support is officially dropped from k8IVAN. i see 0 reasons to support it.
Posted by vasiliy, Jul 16 at 5:24 pm
i decided to use LISP as the scripting language. of coruse, to keep the good old tradition, it will be fully undocumented, and incompatible with any other LISP out there. no, i am not joking here, i already created first implementation of it. internally it even compiles LISP code to VM bytecode. but don't expect it to be fast.
Posted by vasiliy, Jul 2 at 7:17 pm
…but we have time to play 20+ y.o. game at least!
Posted by vasiliy, May 24 at 4:31 pm
still here. got distracted by other things, though. do not worry, estimated hiatus time is only 4 years now.

tbh, i don't know. need to finish several unrelated things first. sadly, i cannot work 20 hours a day and switching tasks all the time, like i could in my teen years. i'd like to, but. anyway, do not adjust your sets. or at least not permanently.