Skip to content

amp-bind: Turing machine and game examples#7742

Merged
dreamofabear merged 6 commits intoampproject:masterfrom
dreamofabear:bind-turing-ex
Mar 8, 2017
Merged

amp-bind: Turing machine and game examples#7742
dreamofabear merged 6 commits intoampproject:masterfrom
dreamofabear:bind-turing-ex

Conversation

@dreamofabear
Copy link
Copy Markdown

@dreamofabear dreamofabear commented Feb 23, 2017

Fixes #7820. Requires #7797.

  • examples/bind/turing.amp.html is a Turing machine that counts up to 8 bits
  • examples/bind/game.amp.html is a 2x2 clone of game 2048

Note that some expressions in game.amp.html are not simplified for the sake of readability.

/to @kmh287

@dreamofabear dreamofabear changed the title amp-bind: Turing machine example amp-bind: Turing machine and game examples Feb 24, 2017
@dreamofabear dreamofabear requested a review from kmh287 February 24, 2017 23:32
(G.grid[0][0] != G.grid[0][1] && G.grid[1][0] != G.grid[1][1] && G.grid[0][0] != G.grid[1][0] && G.grid[0][1] != G.grid[1][1]) &&
(G.grid[0][0] > 0 && G.grid[0][1] > 0 && G.grid[1][0] > 0 && G.grid[1][1] > 0)
) ? 'lose' : 'hidden'">
You <span [text]="(G.grid[0][0] + G.grid[0][1] + G.grid[1][0] + G.grid[1][1] >= 30) ? 'WON' : 'LOST'"></span>!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, how often can you get to 30?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty easily. The 2x2 size makes the game almost trivial.

Copy link
Copy Markdown
Contributor

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a few comments.

<br>

<!--
cases for RIGHT:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the code for RIGHT to right below this. Maybe consider writing this out for the other three cases as well, just to make this easier to read. Though, I think writing one more just for UP or DOWN would probably be sufficient.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

],
'spawnChance': G.spawnChance
}
})">DOWN</button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about arranging the buttons into a natural UP, RIGHT, DOWN, LEFT shape instead of having them in a line?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, roughly. 😄


<h3 [text]="'Count: ' + (count || 0)">Count: 0</h3>

<!--
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to have this comment block in here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, just some things I noticed when writing this sample. Planning to turn them into an issue after some more thought.

@@ -0,0 +1,154 @@
<!doctype html>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about adding a high-level explanation of what's supposed to happen in this demo in a comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a <p> describing this example below the heading.

Copy link
Copy Markdown
Contributor

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dreamofabear dreamofabear merged commit 4991ed7 into ampproject:master Mar 8, 2017
@dreamofabear dreamofabear deleted the bind-turing-ex branch March 8, 2017 20:55
kmh287 pushed a commit to kmh287/amphtml that referenced this pull request Mar 13, 2017
* initial commit for turing machine example

* initial commit for bind game example

* flip chance conditional, tweak generation logic

* add win/loss message and new game button

* kevin's comments

* prettify games with mdl
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* initial commit for turing machine example

* initial commit for bind game example

* flip chance conditional, tweak generation logic

* add win/loss message and new game button

* kevin's comments

* prettify games with mdl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants