arkinox
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ![](https://hackmd.io/_uploads/HJ3Wsq65h.jpg) Thermo is the Domain Specific Language (DSL) for [cyberspace](https://github.com/arkin0x/cyberspace/) that enables the creation of interactive 3D experiences. Thermo is interpreted by a cyberspace client via a language-specific binding such that Thermo is executed consistently regardless of the underlying execution environment that the client is operating on. STATUS: DRAFT --- A Shard is a kind 33332 [nostr events](https://github.com/nostr-protocol/nostr) that contains Thermo code in the `content` property. Shards exist within _Constructs_. A Shard MUST include exactly one `e` tag of a _Construct_ ID to indicate which Construct it exists within. A _Construct_ is an owned cubic region of cyberspace. The Construct serves as a 3D boundary and sandboxed global codespace for all shards and Thermo code within it. A Construct is a Kind 332 event. A Shard MAY also define its own boundary in the form of a 3D box that exists within the bounding box of its encapsulating Construct. The Shard boundary is distinct from the shard's _geometry_; the shard's geometry can be acted on by Thermo code to manipulate it within its boundary. Thermo code may be scoped to the shard (local) or construct (global). ## Thermodynamics All actions in cyberspace require proof-of-work. When creating experiences, properly structured proof-of-work requirements can replace the need for permissions in certain contexts. Thermo allows you to define Actions, which are functions that can be triggered by Avatars within shards, and set the [NIP-13 proof-of-work](https://github.com/nostr-protocol/nips/blob/master/13.md) requirements of those actions. The minimum unit of proof-of-work for any action is 1. There is no default maximum proof-of-work for an action but a maximum may be set. Actions may be available to participants based on conditions, such as the participant's current coordinate location, or some other value within the construct. Actions are triggered by publishing a Shard Action kind 332 event to one's action chain that contains the necessary proof-of-work and action parameters. By including shard actions in your cyberspace action chain, your honesty about the timing of your events within a construct is tied to your honesty about your presence in cyberspace. This means that the [consequence for cheating](https://github.com/arkin0x/cyberspace/blob/master/readme.md#aggression) in a Construct are the same as cheating elsewhere in cyberspace. ## Abstracted Experiences Any experience composed of shards in a construct is essentially an abstraction to the reality of cyberspace. Just as a board game that you play with your friends is an abstraction within reality, construct-based experiences do not have consequences outside of them. In terms of the base mechanics of cyberspace, shards have no effect on one's Avatar. Shards can't push or pull or Derezz you. However, shards may represent proxy presences for avatars, and Thermo will provide tools so that an Operator may temporarily embody a shard instead of their avatar for the sake of participating in a construct experience. For example, Thermo will allow you to transmit your camera view into a shard that represents your playable character in an experience; this will disconnect your camera view from your avatar temporarily as you play the game. Your avatar is always present in cyberspace even if you are disconnect from it, and it is still vulnerable. However, there are other cyberspace mechanics and client features that can help protect avatars while they are dormant during experiences. It is actually better for a Construct experience to utilize these aformentioned proxy shards as playable characters rather than avatars, because shards cannot influence avatars. If the experience has special rules about how a player must interact with an object or move within a space, those rules cannot be enforced on an avatar because the avatar is only subject to the physical rules of cyberspace, but a shard may be completely subject to the local rules. These rules that govern shards are expressed in Thermo. Shards may represent non-player entities that still require proof-of-work to operate. In this case, the proof-of-work may be supplied by the construct owner, a defined set of participants, or anyone, and there may be consequences for not contributing the necessary proof-of-work to power the entity, such as a lose condition on a game. An analogy for this would be two players competing in an online game but also supplying power to the online game's server in equal amounts; if one player does not supply their share, they lose the game automatically. ### RNG When an experience needs random entropy, the event id on supplied proof-of-work can be used for this purpose. ## Actions Actions are like functions that may be triggered by any avatar that meets the action's conditions. Here is some simple example Thermo code you could find within a Shard that allows an operator to execute a kick action on a ball. ``` name ball construct bounds action kick 1: ball.geometry.vel3 = unit(ball.geometry.vec3 - op.vec3) * pow ``` Let's break this down: `name ball` assigns the name `ball` to the current Shard. Recall that all Thermo code is written within a Shard event's `content` tag. If this statement was missing, the Shard could not be referenced in its own code nor in other Shards' code. `construct bounds` means that this action may be activated by any operator within the construct bounds. `action kick` simply means we are defining an action named `kick`. `1:` is the proof-of-work requirement to call the action. The format is minimum:maximum. In this case, the minimum is 1 and the maximum is unbounded. A proof-of-work requirement could be written as simply `:` to mean `1:unbounded`, as 1 unit is always the minimum. Note the Python-like indentation syntax for action definitions. In the action body, we are setting the velocity of the ball's geometry equal to the unit vector of the displacement vector between the operator (`op`) and the ball, and this unit vector is multiplied by the proof-of-work. `op` and `pow`, `powmin`, and `powmax` are reserved words that are available in every action. ## Reactions Reactions are methods that run based on a condition and not in direct response to an avatar's shard action. We will add to our example code above and make our ball bounce off its bounding box walls: ``` name ball construct bounds action kick 1: ball.geometry.vel3 = unit(ball.geometry.vec3 - op.vec3) * pow ball.geometrybounds |> ball.bounds as hit react bounce ball.geometry.vel3 = ball.geometry.vel3 * ones(-hit) ``` Let's break this down. `ball.geometrybounds` is a reference to the bounding box calculated based on the geometry of the ball shard. `|>` is the collision exit operator. More on this in a second. `ball.bounds` is the shard's bounding box. The collision exit operator returns a vec3 indicating the dimension where the lefthand operand has exited the righthand operand. If the ball is fully within the shard bounds, `|>` will not react (method is not triggered). But for example if the ball exits the right side of the shard bounds, `|>` will trigger a reaction and assign the vec3 `(1.5,0,0)` to `hit`, if the ball has gone 1.5 units beyond the right boundary (left/right means x axis). `as hit` puts the result of the collision exit operator into a variable called `hit`. `react bounce` gives the name `bounce` to the reaction. Next the code of the reaction will be executed. `ball.geometry.vel3` velocity is set to a new value via `=`. `ball.geometry.vel3 * ones(-hit)` is doing a few things: - `hit` is a vec3 whose value comes from the collision exit operator. It will be all zeroes except for the axes on which the first operand exited the second; the nonzero values are in cyberspace units. - `-hit` will multiply each value in the vec3 by `-1`. Zeroes are unaffected, naturally. - `ones(-hit)` The `ones` function will change any 0s to 1s. - The `ball.geometry.vel3` velocity is multiplied by the resulting vec3. The effect is that the velocity is reversed in the direction that collided with the bounding box wall, creating a bounce effect. ### Interactions Between Shards Goal shard ``` name goal ball.geometrybounds <| goal.bounds react score player1.score += 1 ``` Player shard ``` name player1 alloc score: Uint8 = 0 ``` Game shard ``` name soccergame alloc playing: boolean = true ``` ## Code Complexity Because the predominant context for Thermo is operating on 3D space, there is a lot of convenience and abstraction around making 3D calculations. This is great because the complexity of your Thermo code imposes a cost on its publication based on the number of tokens it contains. Thermo code can be broken into tokens using the following function: ``` # js export function tokenize(str) { let tokens = []; let currentToken = ''; // Track indentation level let indent = 0; const separators = ['(', ')', ':', '\n']; const operators = ['+', '-', '*', '/', '%', '<|', '|>', '&&', '||', '==', '!=', 'is', 'and', 'or']; for (let char = 0; char < str.length; char++) { const c = str[char]; // Handle whitespace and indentation // if the previous character was a newline and the current character is one or more spaces, treat it as an indentation. if (c === ' ') { if (currentToken) { tokens.push(currentToken); currentToken = ''; } } else if( c === '\t') { indent++; } else if (c === '\n') { if (currentToken) { tokens.push(currentToken); currentToken = ''; } // check if whitespace is following a newline if ( str[char+1] === ' ' ) { console.log(char, 'looking for indentation') // use the number of spaces to determine the indentation level indent = 0; let lookahead = 0 while ( str[char+lookahead+1] === ' ' ) { console.log('+1') indent++; lookahead++; } indent = Math.ceil(indent/4) } tokens.push({type: 'NEWLINE', indent: indent}); indent = 0; } // Handle separators else if (separators.includes(c)) { if (currentToken) { tokens.push(currentToken); currentToken = ''; } tokens.push(c); } // Handle operators else if (operators.includes(c)) { if (currentToken) { tokens.push(currentToken); currentToken = ''; } tokens.push(c); } // Accumulate alphanumerics into tokens else { currentToken += c; } } if (currentToken) { tokens.push(currentToken); } return tokens; } ``` The ceiling of the square root of the number of tokens in a Thermo script is the amount of proof-of-work the shard requires to be considered valid. Shards also require separate proof-of-work proportional to their mesh data (vertices and materials) but these have not yet been defined. # License https://creativecommons.org/licenses/by-sa/4.0/legalcode

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully