Skip to content

Commit 7573af0

Browse files
authored
Merge pull request #413 from code-dot-org/hbergam/bump-npm-version
ml-activities release 0.1.0
2 parents 3ad9c17 + 251c3fd commit 7573af0

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
[![Build Status](https://github.com/code-dot-org/ml-activities/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/code-dot-org/ml-activities/actions/workflows/deploy.yml)
22

3-
43
# **AI for Oceans**
54

65
This is the repo for **AI for Oceans** from Code.org.
76

87
Like the Dance Party repo, it is a standalone repo that is published as an [NPM package](https://www.npmjs.com/package/@code-dot-org/ml-activities), and consumed by the [main repo](https://github.com/code-dot-org/code-dot-org).
98

10-
**AI for Oceans** was produced for the Hour of Code in 2019. This module provides the student experience for the 5 interactive levels in the **AI for Oceans** script at https://studio.code.org/s/oceans.
9+
**AI for Oceans** was produced for the Hour of Code in 2019. This module provides the student experience for the 5 interactive levels in the **AI for Oceans** script at https://studio.code.org/s/oceans.
1110

1211
We have measured over one million unique [completions](https://twitter.com/codeorg/status/1385266661700288513) of the script.
1312

@@ -25,19 +24,19 @@ The user trains the AI to differentiate between fish and trash, and then examine
2524

2625
### `creaturesvtrashdemo`
2726

28-
Next, the concept of non-fish sea creatures is introduced to show that AI is only as good as its training. In this mode, the experience is abbreviated: the user doesn't do training, but rather the mode demonstrates what happens when fish-specific training encounters non-fish.
27+
Next, the concept of non-fish sea creatures is introduced to show that AI is only as good as its training. In this mode, the experience is abbreviated: the user doesn't do training, but rather the mode demonstrates what happens when fish-specific training encounters non-fish.
2928

3029
### `creaturesvtrash`
3130

3231
In this mode, the user trains the AI again, but this time encountering fish, non-fish creatures, and trash.
3332

3433
### `short`
3534

36-
In this mode, the user chooses from one of six adjectives and then categorizes fish based on that. The AI is trained on which fish fit into this arbitrary category or not, and then demonstrates this training.
35+
In this mode, the user chooses from one of six adjectives and then categorizes fish based on that. The AI is trained on which fish fit into this arbitrary category or not, and then demonstrates this training.
3736

3837
### `long`
3938

40-
In this mode, the user chooses from one of fifteen adjectives. With more subjectivity in this list, the user can explore more subtle implications of training and categorization.
39+
In this mode, the user chooses from one of fifteen adjectives. With more subjectivity in this list, the user can explore more subtle implications of training and categorization.
4140

4241
## ML technology
4342

@@ -49,9 +48,9 @@ Adapted from content at https://code.org/oceans:
4948
5049
## Scenes
5150

52-
The **AI for Oceans** script presents a linear narrative structure. This app is designed to deliver the interactive levels for this script, one mode at a time, with no need to persist data to the browser or server between each level.
51+
The **AI for Oceans** script presents a linear narrative structure. This app is designed to deliver the interactive levels for this script, one mode at a time, with no need to persist data to the browser or server between each level.
5352

54-
The app itself presents a variety of "scenes", with each mode using a different subset. The scenes (known as `currentMode` internally) are as follows:
53+
The app itself presents a variety of "scenes", with each mode using a different subset. The scenes (known as `currentMode` internally) are as follows:
5554

5655
### `loading`
5756

@@ -85,7 +84,7 @@ The user watches A.I. (the "bot") categorizing items, one at a time.
8584

8685
<img width="1298" alt="pond-false" src="https://user-images.githubusercontent.com/2205926/165404481-6e36e7d2-c6db-4e69-b84c-afd28f6444ba.png">
8786

88-
The user is shown the result of the predictions. The user can toggle between the matching & non-matching sets.
87+
The user is shown the result of the predictions. The user can toggle between the matching & non-matching sets.
8988

9089
In the `short` and `long` modes, the pond also has a metapanel which can show general information about the ML processing, or, when a fish is selected, specific information about that fish's categorization:
9190

@@ -95,9 +94,9 @@ In the `short` and `long` modes, the pond also has a metapanel which can show ge
9594

9695
## Graphics & UI
9796

98-
The app uses three layers in the DOM. Underneath, one canvas contains the scene's background image, while another canvas contains all the sprites. On top, the app uses React to render HTML elements for the user interface, implemented [here](https://github.com/code-dot-org/ml-activities/blob/c9d24c4b7a20ea12d5dc7a094094c5ef4dfbbde3/src/oceans/ui.jsx).
97+
The app uses three layers in the DOM. Underneath, one canvas contains the scene's background image, while another canvas contains all the sprites. On top, the app uses React to render HTML elements for the user interface, implemented [here](https://github.com/code-dot-org/ml-activities/blob/c9d24c4b7a20ea12d5dc7a094094c5ef4dfbbde3/src/oceans/ui.jsx).
9998

100-
The app is fully responsive by scaling the canvases and also scaling the size of the HTML elements correspondingly. This way, the UI simply shrinks to match the underlying canvases.
99+
The app is fully responsive by scaling the canvases and also scaling the size of the HTML elements correspondingly. This way, the UI simply shrinks to match the underlying canvases.
101100

102101
## Animation
103102

@@ -111,7 +110,7 @@ The fish pause under the scanner using a simple S-curve adjustment to their move
111110

112111
## The Guide
113112

114-
After initial playtests, we identified a need to slow the pacing of the tutorial and tell a clear story. The solution we adopted was text boxes with "typing" text, reminiscent of old-school computer games.
113+
After initial playtests, we identified a need to slow the pacing of the tutorial and tell a clear story. The solution we adopted was text boxes with "typing" text, reminiscent of old-school computer games.
115114

116115
"The Guide" is the implementation of this solution, and was designed to be a simple but flexible system that allowed us to add a variety of text for every step and situation encountered in the tutorial.
117116

@@ -131,11 +130,11 @@ We also use modal popups to give extra information.
131130

132131
## State
133132

134-
The app's runtime state is stored in a very simple module [here](https://github.com/code-dot-org/ml-activities/blob/c9d24c4b7a20ea12d5dc7a094094c5ef4dfbbde3/src/oceans/state.js). Updates to state trigger a React render, unless deliberately skipped.
133+
The app's runtime state is stored in a very simple module [here](https://github.com/code-dot-org/ml-activities/blob/c9d24c4b7a20ea12d5dc7a094094c5ef4dfbbde3/src/oceans/state.js). Updates to state trigger a React render, unless deliberately skipped.
135134

136135
## Host interface
137136

138-
The full functionality of this app is enabled when hosted by https://studio.code.org. The main repo loads this app via code [here](https://github.com/code-dot-org/code-dot-org/tree/c3325655902e82479d0a85d5adc73049810e5b66/apps/src/fish). Specific parameters passed in during initialization, [here](https://github.com/code-dot-org/code-dot-org/blob/c3325655902e82479d0a85d5adc73049810e5b66/apps/src/fish/Fish.js#L127-L136), include a foreground and background canvas, the `appMode`, a callback when the user continues to the next level, callbacks for loading & playing sound effects, and localized strings.
137+
The full functionality of this app is enabled when hosted by https://studio.code.org. The main repo loads this app via code [here](https://github.com/code-dot-org/code-dot-org/tree/c3325655902e82479d0a85d5adc73049810e5b66/apps/src/fish). Specific parameters passed in during initialization, [here](https://github.com/code-dot-org/code-dot-org/blob/c3325655902e82479d0a85d5adc73049810e5b66/apps/src/fish/Fish.js#L127-L136), include a foreground and background canvas, the `appMode`, a callback when the user continues to the next level, callbacks for loading & playing sound effects, and localized strings.
139138

140139
## Analytics
141140

@@ -147,7 +146,6 @@ If Google Analytics is available on the page, the app generates a synthetic page
147146

148147
The documentation for common operations for **AI Lab** is comprehensive and should apply to this project too: https://github.com/code-dot-org/ml-playground#common-operations
149148

150-
151149
## Getting started
152150

153151
Steps to get up and running:
@@ -174,37 +172,44 @@ If you want to make changes locally in ml-activities and have them show up in yo
174172

175173
- In the ml-activities root directory `yarn link`
176174
- In the code-dot-org apps/ directory `yarn link ~/ml-activities`
177-
This will set up a symlink in apps/node_modules/@code-dot-org to point at your local changes. Run `yarn build` in ml-activities, and then the code-dot-org apps build should pick up the changes (generated in ml-activities' `dist/`) next time it occurs (including in already-running `yarn start` build in code-dot-org).
178-
- Note that ml-activities' `yarn start` can be left running when `yarn build` is run. But a new invocation of `yarn start` will intentionally clear the `dist/` directory populated by `yarn build` to ensure we don't have outdated assets left in it.
179-
- If you want to go back to using the published module, in the code-dot-org apps/ directory run `yarn unlink ~/ml-activities`. You'll be given additional instructions on how to force the module to be rebuilt after that.
175+
This will set up a symlink in apps/node_modules/@code-dot-org to point at your local changes. Run `yarn build` in ml-activities, and then the code-dot-org apps build should pick up the changes (generated in ml-activities' `dist/`) next time it occurs (including in already-running `yarn start` build in code-dot-org).
176+
- Note that ml-activities' `yarn start` can be left running when `yarn build` is run. But a new invocation of `yarn start` will intentionally clear the `dist/` directory populated by `yarn build` to ensure we don't have outdated assets left in it.
177+
- If you want to go back to using the published module, in the code-dot-org apps/ directory run `yarn unlink ~/ml-activities`. You'll be given additional instructions on how to force the module to be rebuilt after that.
180178

181179
### Publishing a new version
182180

183181
First, ensure you have the `main` branch checked out locally, and that it's up to date.
184182

185183
To publish a new version, the following command should work:
184+
186185
```
187186
npm version 0.0.29
188187
```
189-
With `0.0.29` replaced by the new version number that should be published.
190188

191-
Note: make sure you are logged into `npm` first. If not, the command may fail with a misleading `E404` error. You can see if you're logged in with `npm whoami`, and if not logged in, can can use `npm login`.
189+
With `0.0.29` replaced by the new version number that should be published. Generally try to follow MAJOR.MINOR.PATCH to determine which number to change (for instance, a bug fix increments the third digit by 1, while a non-backwards compatible major update increments the first).
190+
191+
Note: make sure you are logged into `npm` first. If not, the command may fail with a misleading `E404` error. You can see if you're logged in with `npm whoami`, and if not logged in, can can use `npm login`.
192192

193193
## Adding new fish components
194+
194195
All fish components live in `public/images/fish` in their respective folders (eg bodies live in `body/`). Despite the fact that the fish face right in most of the tutorial, they are built as if they face left in order to simplify the math for the anchor points. This means that all components should be oriented as if the fish is facing left, which might require flopping any new assets. After adding the assets, they will need to be added to `src/utils/fishData.js`. `bin/determineKnnData.js` will output some of the lines that will be needed in `fishData`.
195196

196197
All components can define `exclusions`, which are modes that the component won't be used in. Components appear in all modes by default.
197198

198199
Some components need more configuration:
199200

200201
### Bodies
202+
201203
Bodies need an anchor point for the body then all of the other components, relative to the bounds of the body image. A face anchor point is used for both the eyes and the mouth. The eyes and mouth are arranged with respect to each other and the defined anchor point. The tail Y anchor point is set from where the center of the component should be.
202204

203205
### Dorsal fin
206+
204207
Some dorsal fins define an x-adjustment to shift the anchor point. This is useful for dorsal fins that might look odd is not positioned correctly (eg symmetical).
205208

206209
## I18n
210+
207211
By default, this tutorial is in English. The strings live at i18n/oceans.json and should not be moved without corresponding changes to the I18n pipeline in `code-dot-org`. Translations can be passed into the app using the `i18n` param. If any translations are missing, the English string will be used as a default. This also means that adding a new string is safe and does not require any further steps.
208212

209213
## Machine Learning algorithms
214+
210215
We currently have support for two machine learning algorithms: k nearest neighbor (KNN) and support vector machine (SVM). We also have a mobilenet model that is saved at `src/oceans/model.json` (it's saved here to avoid a call to googleapis.com).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-dot-org/ml-activities",
3-
"version": "0.0.29",
3+
"version": "0.1.1",
44
"description": "",
55
"main": "dist/main.js",
66
"jest": {

0 commit comments

Comments
 (0)