Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgol: ngen $-([game @ud] game) where game is modified @ud steps #3

Open
rabsef-bicrym opened this issue Dec 16, 2022 · 1 comment
Open
Assignees
Milestone

Comments

@rabsef-bicrym
Copy link
Member

rabsef-bicrym commented Dec 16, 2022

++  ngen
  |%
  +$  stat  [ole=board nel=(list ?) [x=@ud y=@ud]]
  ++  play
    ^-  $-([game @ud] game)
    |=  [gam=game n=@ud]
    |^  ^-  game
      |-  ?:  =(0 n)  [%0 size.gam step.gam bord.gam]
      $(bord.gam (next bord.gam), n (dec n), step.gam +(step.gam))
    ++  next
      |=  bord=board
      =;  [neu=board sta=stat]
        neu
      %^    spin
          bord
        [ole=bord nel=*(list ?) [x=*@ud y=*@ud]]
      |=  [cur=(list ?) stat]
      |-
      ?~  cur  [`(list ?)`(flop nel) [ole ~ [0 +(y)]]]
      =+  fren=(friends x y ole)
      ?:  ?=(%.y i.cur)
        ?:  (lth fren 2)  $(cur t.cur, x +(x), nel [%| nel])                    ::  overexposed
        ?:  (gth fren 3)  $(cur t.cur, x +(x), nel [%| nel])                    ::  overcrowded
        $(cur t.cur, x +(x), nel [%& nel])                                      ::  goldilocks!
      ?:  =(3 fren)  $(cur t.cur, x +(x), nel [%& nel])                         ::  necromancy!
      $(cur t.cur, x +(x), nel [%| nel])
    ++  friends
      |=  [x=@ud y=@ud ole=board]
      =+  max-y=(dec y.size.gam)
      =+  max-x=(dec x.size.gam)
      ;:  add
        ?:(|(=(0 x) =(0 y)) 0 !(snag (dec x) (snag (dec y) ole)))               ::  up-left
        ?:(=(0 y) 0 !(snag x (snag (dec y) ole)))                               ::  up
        ?:(|(=(0 y) =(max-x x)) 0 !(snag +(x) (snag (dec y) ole)))              ::  up-right
        ?:(=(0 x) 0 !(snag (dec x) (snag y ole)))                               ::  left
        :: 0                                                                    ::  me
        ?:(=(max-x x) 0 !(snag +(x) (snag y ole)))                              ::  right
        ?:(|(=(0 x) =(max-y y)) 0 !(snag (dec x) (snag +(y) ole)))              ::  down-left
        ?:(=(max-y y) 0 !(snag x (snag +(y) ole)))                              ::  down
        ?:(|(=(max-y y) =(max-x x)) 0 !(snag +(x) (snag +(y) ole)))             ::  down-bad
      ==
    --
  --
@rabsef-bicrym rabsef-bicrym converted this from a draft issue Dec 16, 2022
@rabsef-bicrym rabsef-bicrym self-assigned this Dec 16, 2022
@rabsef-bicrym rabsef-bicrym added this to the mvp readiness milestone Dec 16, 2022
@rabsef-bicrym
Copy link
Member Author

TODO:

  • finish webp logic loop
  • write parser to take all possible cells, construct board
  • profit?

rabsef-bicrym pushed a commit that referenced this issue Dec 17, 2022
cgol: big update - parsing, game engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant