Skip to content

Latest commit

 

History

History
133 lines (91 loc) · 5.06 KB

2019-11.md

File metadata and controls

133 lines (91 loc) · 5.06 KB

November

November 5th

Goal: Placing a raincloud next to a sapling should transform the sapling into a sunflower and remove the raincloud from the board.

Current (Unsuccessful) Approach: Iterate over each tile and check if that tile needs to be removed because of a rule, or if it should change to something else because of a rule. Removal is a true/false result but changes is a list! As checking for changes involves iterating over each rule, with different rules possibly causing a different change.

Resolving changes in this way seems wrong.. and hard to animate. It feels like I need to combine removals and transforms into one change, and generate a list of those changes, to animate one after the other?

Ok, I think the problem is the rules themselves. This is what I'm working with:

{:type :adj
 :base "🌱"
 :adj "🌧️"
 :base-to "🌻"
 :consume-adj true}

What the heck does that even mean? I think I might have just bashed this out as an idea a while back and it just stuck around.

A more flexible rule might be this:

[["🌱" "🌧️"] ["🌻" nil]]

The whole game can be a bunch of replacement effects right? Here's a render of the new rule:

New Approach: Rules are tile replacements, basically string -> string. Generate a list of replacements to apply to the board sequentially. Animate the replacements.

November 11th

Following paths?

{:rule [["🔥" "🌱" "🌧️"] [nil "🌻" nil ]]
 :total-steps 3
 :paths #{
          {:direction [0 1] :tiles [["🔥" -2 0 false ]] :walking? false }
          {:direction [1 0]
           :tiles [["🔥" -2 0 false ]
                   ["🌱" -1 0 true ]
                   ["🌧️" 0 0 true ]]
           :walking? false }
          {:direction [0 -1] :tiles [["🔥" -2 0 false ]] :walking? false }
          {:direction [-1 0] :tiles [["🔥" -2 0 false ]] :walking? false }}}

November 13

It works!

![](/images/Peek 2019-11-13 22-03.gif)

November 17

So now what? The game logic seems to be working. Maybe a quick refactor, pick some slightly better names for things, make things a bit clearer. Then animation!

Main problem to fix with a refactor is that I've made too many sets. I was trying to use them for uniqueness checks but I can use map keys for the same thing! Here's what out 'chain of effects' looks like now:

[#{
   {["🔥" -2 0] nil
    ["🌱" -1 0] "🌻"
    ["🌧️" 0 0] "🌈"}}
 #{
   {["🌈" 0 0] nil
    ["🌱" 0 1] "🍇"}
   {["🌈" 0 0] nil
    ["🌱" 1 0] "🍇"}}]

This is after making waaay too many sets that get passed around by different functions.

The original idea behind the sets was that as we look at each tile looking for a replacement rule to be triggered, we would end up finding duplicates by looking in both directions. That's not the case! We search by looking for the 'root' i.e. the first emoji in the rule. We never flip the rule itself so each path should only be found once. Also, we end up with a duplication somewhere else anyway! In this case, the rainbow is the root of two different paths so it gets listed as needing a deletion twice. Instead we want something like this:

[{["🔥" -2 0] nil
  ["🌱" -1 0] "🌻"
  ["🌧️" 0 0] "🌈"}
 {["🌈" 0 0] nil
  ["🌱" 0 1] "🍇"
  ["🌱" 1 0] "🍇"}]

And.. success! It's probably faster, right?

How do you win at emojinos? Points? Combos?

Hang on, can rules have variables? Does this rule makes sense?

Maybe variables could be colored tiles with no symbol? Something like... this?

November 20

Before we add variables to the rules system let's animate some emojinos!

What effect would we like to achieve? While we want it to look good I think Goal #1 is making it clear what is happening to the board as you place each tile. We essentially want to slow things down so that changes are visible. I think this will also help in rules debugging for complex board states as well!

Here's a first pass:

  1. Place a new tile on the board
  2. Generate a list of 'effects'
  • i.e. groups of tile substitutions
  1. Apply each effect, pausing for a second between each one

But how do I do that?

  1. Add the generated effects to the game-state map
  2. In the reagent component, check for the presence of :effects-to-apply and if it's there:
  3. Start a reanimated timeline (https://github.com/timothypratley/reanimated)
  4. Apply effect, pause apply effect etc.

Some other ideas:

  • Disable board interaction while things are animated
  • Flash all of the emojis affected by the rule
  • Break each effect into subeffects like movements, removals etc.

Well, here's something:

![](/images/Peek 2019-11-20 17-46.gif)

There's a quick flash that I think is the reanimated timeline component setting itself up. I've fiddled around but I'm not sure how to avoid this, I might have to do something more manual. Also it looks like the grapes rule is broken?