Git Product home page Git Product logo

pikov's Introduction

Archived This project is not being actively monitored for issues and PRs. If I (tswast@) do revisit this project, it'll be at my personal fork: https://github.com/tswast/pikov

Pikov

personal

Contributing

Contributions to this tool are always welcome and highly encouraged.

See the CONTRIBUTING doc for more information on how to get started.

License

Apache 2.0 - See the LICENSE for more information.

Disclaimer

This is not an officially supported Google product.

pikov's People

Contributors

tswast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pikov's Issues

GIF preview for Pikov

What is a GIF preview? Rather than being dynamic, render a sequence of frames that follow some specific transitions, chosen randomly.

Parameters:

  • min_length (default to 10 seconds) - How long should the animation be?
  • max_length (default to 30 seconds) - What is the maximum length for the animation?
  • starting_frame - Where should the animation start?

The renderer will randomly choose transitions to follow. Once the animation is at least min_length long (use the duration property of frames to calculate), stop once the animation would render the starting_frame again. This makes the preview animation into a looping animation.

If the animation gets to max_length long without looping, stop there.

Non-Jupyter renderer for Pikov files

Show how to create a game using pyglet or kivy that loads images for sprites from Pikov.

Not a 0.1 blocker, since I’m more concerned about the editor for now.

JSON version: Pikov transitions should be more imperative

In the JSON version, transitions are defined separately, with the properties

  • source [Frame]
  • target [Frame]
  • probability_weight [float]]

This is quite similar to the SQLite version but suffers a couple problems:

  1. The source graph would need to be transformed in order to implement any kind of interpreter. At a minimum there needs to be a index of Transition.source so that we can find transitions associated with a Frame.
  2. It's a little hard to mentally model which transition will be followed, especially when we add in the idea of events and filters for interactions between sprites.

I propose updating Frame to include a transitions [List of expressions] property. Each expression outputs a true probability (0 to 1, inclusive), a new frame, and a list of state updates to make to the sprite (e.g. Add this vector to the position.). Note: this actually a little harder to model as a Markov chain since the probability that a transition will be followed depends on the probabilities of the transitions above it.

For the first iteration, each expression should be a constant but eventually it could be neat to declare the kinds of events the expression is listening for (probably registered as subscription queues on the Sprite).

We might want to have a similar list of transitions on Clip and check those first. This would be useful for sprites where fast action is more important than an especially smooth transition (jump / punch NOW).

Add transitions between clips

A transition has the following properties:

  • source frame (includes clip ID)
  • target frame (includes clip ID)

Eventually I’d like the ability to do transitions with variable weights, but that’s post-0.1. Likewise, I’d like the ability to use transitions to respond to events, but that’s definitely post-0.1.

bag of files version of Pikov

Using a bag of files format (as a sister format to the SQLite version) would make it easier to make tweaks to the images with my usual pixel art apps without having to code up special connections to swap out an image in all frames.

This also means dropping the need for images to be content addressable. One way may be to use the spritesheet and have frame specify the bounding box to crop out.

IPython preview for a collection of clips

It's difficult to browse all the clips available in a Pikov file. I wish entering mypikov.clips in a Jupyter notebook would show all the clips that are available.

DOC: example pikov animation without x/y movement

Version 0.1 does not need to be able to handle x/y movement. The prototype only needs to animate with random transitions between clips.

Idea: A flower or mushroom. Something that is rooted in place. Maybe a boat tied to a post.

Flower: It grows, it might get eaten, it could get pollinated, it could freeze in winter, it could dry up in a drought, it could drown in a flood, it could get stomped by an animal, and then next spring a new flower grows.

Clarify computation model for Pikov animations

We should document the intended computation model for Pikov animations.

Thoughts:

  • It's a state machine (with stochastic transitions instead of based on deterministic rules).
  • Except it has extra state like the animation's current position, in addition to the current state.

Question: Is there always 1 image per state? (For now, yes.) Maybe it makes sense to track direction separately, for example?

Friendly ID property for clips

I'm finding it useful to create helper variables to keep track of which clip is which.

"sitting = gamekitty.get_clip(1)\n",

Such a feature could be built-in to the clip table, where perhaps clips could be accessed by name in addition to by numeric ID. It could work something like:

gamekitty = pikov.Pikov.open('gamekitty.pikov')
clips = gamekitty.clips
stand_up = clips['stand_up']

Random weights for frame transitions

The current Pikov preview spends a bit too much time on transitioning between states. It sits, but only for a frame or two before crouching or standing up.

I think transitions should have a random_weight (maybe a different name) that is proportional to the transition property. If the property is not present, the weight defaults to 1.0. The reason I don't suggest naming it "probability" is that I want to be able to add or remove transitions without having to renormalized all the other transitions.

Add helper method to find absorbing frames

A dead-end frame is one where there is no next frame in the clip and there are no transitions from that frame.

It is undefined what to do when reaching a dead-end-frame. Does the animation get stuck? Does it disappear?

Method to delete a Frame

Similar to #16, there is no way to "undo" a Frame creation if you change your mind. A Frame should be able to delete itself (and any referenced Transitions).

This would require modifying the Frame.next property to account for the fact that there may be gaps in clip_order due to deleted items. Using a MIN aggregation function should work for that purpose.

  • Ensure Frame.next can account for gaps in clip_order.
  • Add Frame.delete() method.

Register classes based on ctor

When I get a node from a graph, the graph should return a nice object (custom class) when one exists for it.

I think a class decorator could be used to register classes globally and associate them with a specific value for ctor.

@pikov.register_class(ctor=bytes.fromhex("8b057dd7a9c84b7180cb2d8d6015b833"))
class Frame(SemanticGraphNode):
    def __init__(self, guid_map, guid=None):
        super().__init__(names["frame"], guid_map, guid=guid)

    duration_microseconds = Int64Property(names["frame.duration_microseconds"])
    bitmap = BitmapProperty(names["frame.bitmap"])

    def _to_img(self):
        image_url = self.bitmap._to_data_url()
        if not image_url:
            return None

        return (
            f'<img alt="clip preview" '
            f'src="{image_url}" '
            f'style="width: 5em; {PIXEL_ART_CSS}">'
        )

IPython HTML renderer for Clip

Since 0.1 clips won’t have additional properties like x/y velocity, a looping GIF should be sufficient for an HTML renderer.

Method to delete a Transition

I am finding it frustrating that I can't "undo" a transition if I accidentally create one that I didn't mean to or if I create the same transition twice. I propose a Transition.delete() method, where a Transition deletes itself from the database and then deactivates the object from further operations.

IPython / JupyterLab renderer for Pikov

Pikov will need dynamic transitions even for 0.1. We should have:

  • HTML renderer that picks a random sequence of (looping?) transitions and renders a GIF.
  • JavaScript / mimetype renderer that randomly chooses transitions to follow. (Use SQL.js and the canvas API for this?)

Blocked by:

  • #6 Add transition property

Support comparison across Pikov objects

Right now Frame and other objects only compare IDs to determine they are equal. This leads to false positives if two Frames are compared from different Pikov files but they happen to have the same frame IDs.

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.