Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deepen model, interpreter and resolver component #7

Closed
maldins46 opened this issue Dec 23, 2020 · 4 comments · Fixed by #33
Closed

Deepen model, interpreter and resolver component #7

maldins46 opened this issue Dec 23, 2020 · 4 comments · Fixed by #33
Assignees
Labels
base structure Build/edit a base feature of the project

Comments

@maldins46
Copy link
Contributor

The model component is the essential data foundation of the project. It must be studied and founded.

@maldins46 maldins46 created this issue from a note in ScalaQuest Project (Backlog (current Sprint)) Dec 23, 2020
@maldins46 maldins46 moved this from Backlog (current Sprint) to In progress (current Sprint) in ScalaQuest Project Dec 23, 2020
@maldins46 maldins46 changed the title Deepening model component Deepen model component Dec 23, 2020
@maldins46
Copy link
Contributor Author

maldins46 commented Dec 27, 2020

Summarizing today's work with @corinz97 and @ThomasAngeliniUnibo:

In 8672611 we experimented some solutions for the Item basic implementation.

What we need is a structure that makes it possible to execute an Update, when a Statement is detected, only if some conditions are satisfied. We are deepening particularly the case of the TransitiveStatement, concerning an Action and an Item.

The solution uses a PartialFunction as a trigger for the condition, which returns an Update only if the condition is satisfied. The Interpreter is the component that triggers this mechanism, started for the transitive action the Item::use method.

Very important is the manner used to engage a ready-to-use Behavior, a sort of plugin that can be attached to the Item (ex. Takeable, Openable, ecc.), that comprehends the logic, a partial function, and eventually the resulting update.

Today we experimented with the engage with a mixin. This is of course an elegant solution, but has the important problem of not being configurable: it is not possible, for example, passing parameters into a mixin in Scala (how do I specify, for example, what Room to go into passing a door with a Traversable behavior?). An alternative solution, to be tested, could be engaging a behavior as an object into the Item with a factory. Constructing the Item with a specific factory, we can introduce the possibility to add pre-configured Behaviors to the Item.

An additional comment: d574d97 was just a test, not a definitive version.

@maldins46 maldins46 added enhancement New feature or request base structure Build/edit a base feature of the project and removed enhancement New feature or request labels Dec 28, 2020
@maldins46
Copy link
Contributor Author

What we've done today with with @corinz97 and @ThomasAngeliniUnibo (commits c2787cd and 35354bf):

  • We have deepened the behavioural model with a more solid structure
  • We have experimented on how to modify the State with Lens

We have some doubts about how to organize code, as the type system used for circular dependencies makes it very difficult; we should discuss together in the next general meeting about this.

@maldins46
Copy link
Contributor Author

What on days 30th and 31th of December, we made some experiments for model refactoring in common meeting the entire group. The experiments can be consulted in fe7e37f, but they are only scratches, for future modification: they will not flow into the main branch.

The reason for this experiment is that the model has a subtle problem regarding a circular dependency between Item and State. This is a problem because, on many occasions, the concrete implementation of State should access the concrete implementation of Item, and vice versa, without losing the original references. We initially tried to solve the problem using the concept of type projection, but the initial solution had some problems when passing the state in the Interpreter component. We know that for specific cases, using type projection could be unsound (so much so that they have been removed in Scala 3), but for our specific case, it was an elegant solution; except for the fact that the aforementioned problem arose during model development.

The experimented solution, in contrast, exploits the concept of type classes, in combination with type projection for some specific steps. The solution should be perfected and applied to an official solution, but it is a good starting point for its implementation.

PS: please correct me if I said anything wrong in this meeting smmary

@maldins46 maldins46 changed the title Deepen model component Deepen model, interpreter and resolver component Jan 1, 2021
@maldins46
Copy link
Contributor Author

What has been done in the latest two weeks, for this task, by the team @maldins46 / @corinz97 / @ThomasAngeliniUnibo:

  • We finished and cleaned implementations for the BehavioralModel;
  • We finished and cleaned Pipeline implementations and interface, for what belongs to us (Reducer,Interpreter and Resolver);
  • On that basis, we have unified the "builder" style used in Pipeline and into the ItemRetriver;
  • We set up the remaining unit tests.

In the end, revisioning the code, we encountered an unexpected major problem, regarding the item references: as we basically re-create the State for each Pipeline round, we are going to lose all the matches between ItemRefand Item. In other words, the initial Map[ItemRef, Item] used from the Interpreter in the first Pipeline round, can not be used in the next ones.
The solution we have come up with (together with @francescogorini) involves the insertion of the corresponding ItemRef directly inside the Item, and a new method State::extractRef() inside the State: at the end of the pipeline execution, the method is invoked, from the updated State, to recreate the Map[ItemRef, Item]. Then, the new map is passed to the next implementation of the Interpreter.

@maldins46 maldins46 linked a pull request Jan 20, 2021 that will close this issue
ScalaQuest Project automation moved this from In progress (current Sprint) to Done tasks (current sprint) Jan 20, 2021
@maldins46 maldins46 moved this from Done tasks (current sprint) to Done tasks (post Sprint) in ScalaQuest Project Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base structure Build/edit a base feature of the project
Projects
ScalaQuest Project
Done tasks (post Sprint)
Development

Successfully merging a pull request may close this issue.

3 participants