dkornishev / dherkin

Cucumber gherkin runtime for dart
BSD 2-Clause "Simplified" License
8 stars 5 forks source link

Big merge #11

Closed Goutte closed 10 years ago

Goutte commented 10 years ago

I needed access to the GherkinParser from the browser, so I did some refactoring.

I merged all your recent changes, too.

Just throwing it out there, if you don't pull it's okay ;)


See PR #12.

Goutte commented 10 years ago

I'm learning to squash commits, but it looks like it's gonna be for next time ! :)

Goutte commented 10 years ago

See PR #12

dkornishev commented 10 years ago

I am merging your pull request.

One question: why/how do you run this in browser? Where is gherkin coming from?

2014-06-20 9:34 GMT-04:00 Antoine Goutenoir notifications@github.com:

Closed #11 https://github.com/dkornishev/dherkin/pull/11.

— Reply to this email directly or view it on GitHub https://github.com/dkornishev/dherkin/pull/11#event-133505890.

Goutte commented 10 years ago

Why

I'm using Gherkin to provide a (BIG, and later on non-developer-provided) set of trials through which my fresh population of AIs will pass. Those who survive (pass) the trials enter the tournaments, which are much more computationnally intensive. (hence the trials to eliminate the "rabble")

Making a sane AI for a Go game through genetic programming will take horsepower. A LOT.

I want all this logic (the whole flow) to run in the browser so I can distribute it through my friends and have only a server that collects the results for a while. SETI@HOME like, if you will.

Of course, I could run the trials and generate the populations from CLI scripts and only run the tournaments distributed ; I still consider doing that if I can't figure out how to use dherkin without dart:io.

But that would make things less simple. And I like how badass the final webpage might look if it's doing the whole flow, allowing users to tweak manually the parameters of the AI's genes, and see how it passes trials.

How

Actually, right now, it does not work. Even when I only import 'package:dherkin/dherkin_core.dart';, it complains about dart:io. I checked the dependency tree, I do not see anything that depends on dart:io. I looked at worker, too. Ideas ?

As for the features' content, I cheated and loaded features as multiline strings :

library jungle_killer_instinct;

String trial = """
Feature: Capturing stone(s)
  In order to make territory
  As a computer player
  I can capture enemy stones

  Background:
    Given I am black in a game of size 3
      And it is my turn
      And the symbol for a black stone is █
      And the symbol for a white stone is ▒

  Scenario: Immediately capture foe on otherwise blank board
    Given the game looks like this :

  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- --- ---█--- --- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- ---█---▒---█--- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- --- --- --- --- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |

    Then I should want to play on the X :

  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- --- ---█--- --- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- ---█---▒---█--- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --- --- ---X--- --- --- --- --- --- --
  |   |   |   |   |   |   |   |   |   |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |
-- --- --- --
  |   |   |

""";

Then, I can simply :

import 'jungle/killer_instinct.dart' as JungleKillerInstinct;

List<String> registeredJungleTrials = [
  JungleKillerInstinct.trial,
];

// for each registered jungle trial
// explode into lines and feed to GherkinParserTask

This is just for testing. Eventually, the features will be back in files and be served by the server. That will mean looking into Feature concatenation and gzip.


It's all moot if I don't get out of this dependency hell anyways.

dkornishev commented 10 years ago

Very interesting! AI is something of great interest to me, but sadly my understanding of it quite rudimentary.

I haven't considered the angle you propose, but given the mad dash to the web we are experiencing, it makes sense. Maybe I will move away from assuming gherkin comes from file-system and allow for pluggable sources (i.e. http, ajax, websockets) Would need that HttpResultBuffer

2014-06-20 10:55 GMT-04:00 Antoine Goutenoir notifications@github.com:

Why

I'm using Gherkin to provide a (BIG, and later on non-developer-provided) set of trials through which my fresh population of AIs will pass. Those who survive (pass) the trials enter the tournaments, which are much more computationnally intensive. (hence the trials to eliminate the "rabble")

Making a sane AI for a Go game through genetic programming will take horsepower. A LOT.

I want all this logic (the whole flow) to run in the browser so I can distribute it through my friends and have only a server that collects the results for a while. SETI@HOME like, if you will.

Of course, I could run the trials and generate the populations from CLI scripts and only run the tournaments distributed ; I still consider doing that if I can't figure out how to use dherkin without dart:io.

But that would make things less simple. And I like how badass the final webpage might look if it's doing the whole flow, allowing users to tweak manually the parameters of the AI's genes, and see how it passes trials. How

Actually, right now, it does not work. Even when I only import 'package:dherkin/dherkin_core.dart';, it complains about dart:io. I checked the dependency tree, I do see anything that depends on dart:io. I looked at worker, too. Ideas ?

As for the features' content, I cheated and loaded features as multiline strings :

library jungle_killer_instinct; String trial = """Feature: Capturing stone(s) In order to make territory As a computer player I can capture enemy stones Background: Given I am black in a game of size 3 And it is my turn And the symbol for a black stone is █ And the symbol for a white stone is ▒

Scenario: Immediately capture foe on otherwise blank board Given the game looks like this : | | |-- --- --- -- | | |-- --- --- -- | | |-- --- --- -- | | | | | | | | | | | |-- --- --- --- --- ---█--- --- --- --- --- --- -- | | | | | | | | | | | |-- --- --- --- ---█---▒---█--- --- --- --- --- -- | | | | | | | | | | | |-- --- --- --- --- --- --- --- --- --- --- --- -- | | | | | | | | | | | |-- --- --- -- | | |-- --- --- -- | | |-- --- --- -- | | | Then I should want to play on the X : | | |-- --- --- -- | | |-- --- --- -- | | |-- --- --- -- | | | | | | | | | | | |-- --- --- --- --- ---█--- --- --- --- --- --- -- | | | | | | | | | | | |-- --- --- --- ---█---▒---█--- --- --- --- --- -- | | | | | | | | | | | |-- --- --- --- --- ---X--- --- --- --- --- --- -- | | | | | | | | | | | |-- --- --- -- | | |-- --- --- -- | | |-- --- --- -- | | | """;

Then, I can simply :

import 'jungle/killer_instinct.dart' as JungleKillerInstinct; List registeredJungleTrials = [ JungleKillerInstinct.trial,]; // for each registered jungle trial// explode into lines and feed to GherkinParserTask

This is just for testing. Eventually, the features will be back in files and be served by the server.

That will mean looking into Feature concatenation and gzip.

It's all moot if I don't get out of this dependency hell anyways.

— Reply to this email directly or view it on GitHub https://github.com/dkornishev/dherkin/pull/11#issuecomment-46687344.

Goutte commented 10 years ago

The dependency to dart:io stems from worker. Dartium has webworkers, so in theory worker could wrap both worlds.

I'll look into it.

Goutte commented 10 years ago

Turns out the dependency was only for Platform.numberOfProcessors. Easy fix.

Hopefully, Dart will come up with some way to allow optional imports someday.