Skip to content

Commit

Permalink
MATH: ag has separate subgraphs for carry and borrow
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindeland committed Sep 12, 2018
1 parent e9488bc commit 7795bba
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 18 deletions.
212 changes: 197 additions & 15 deletions app/src/main/assets/tutors/bigmath/animator_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,25 @@
"preenter": [],
"preexit": [],
"edges": [
{
"constraint": "",
"edge": "NEXT_DIGIT"
}
{"constraint": "", "edge": "BEGIN_PROBLEM_REGULAR"},
{"constraint": "FTR_IS_CARRY", "edge": "BEGIN_PROBLEM_CARRY"},
{"constraint": "FTR_IS_BORROW", "edge": "BEGIN_PROBLEM_BORROW"}
]
},

"BEGIN_PROBLEM_REGULAR": {
"type": "NODE",
"COMMENT": "Regular problem with no carry or borrow.",
"maptype":"moduleMap",
"mapname": "EMPTY",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "NEXT_DIGIT_R"}
]
},

"NEXT_DIGIT":{
"NEXT_DIGIT_R":{
"COMMENT":"This node moves to the next digit in the problem.",
"type":"node",
"maptype":"moduleMap",
Expand All @@ -53,49 +64,211 @@
"preexit" :[],
"edges":
[
{"constraint":"","edge":"USER_INPUT"}
{"constraint":"","edge":"USER_INPUT_R"}
]
},

"USER_INPUT": {
"USER_INPUT_R": {
"COMMENT":"Preps the tutor for user input, then waits for user input.",
"type": "node",
"maptype":"moduleMap",
"mapname": "USERINPUT",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK"},
{"constraint": "", "edge": "WRONG_FEEDBACK"}
{"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_R"},
{"constraint": "", "edge": "WRONG_FEEDBACK_R"}
]
},

"CORRECT_FEEDBACK": {
"CORRECT_FEEDBACK_R": {
"COMMENT": "Provides feedback for correct response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "CORRECTFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT"}, // if done with problem, continue to next problem
{"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT"} // if not done, progress to next digit
{"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_R"}, // if done with problem, continue to next problem
{"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_R"} // if not done, progress to next digit
]
},

"WRONG_FEEDBACK": {
"WRONG_FEEDBACK_R": {
"COMMENT": "Provides feedback for wrong response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "WRONGFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "USER_INPUT"} // go back to wait for user input
{"constraint": "", "edge": "USER_INPUT_R"} // go back to wait for user input
]
},

"PROBLEM_CORRECT": {
"PROBLEM_CORRECT_R": {
"COMMENT": "When user has completed a problem.",
"type": "node",
"maptype": "moduleMap",
"mapname": "PROBLEMCORRECT",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_MORE_PROBLEMS", "edge": "NEXT_PROBLEM"}, // if more problems, go to next problem
{"constraint": "FTR_PROBLEMS_DONE", "edge": "NEXT_SCENE"} // if problems done, go to next scene (aka finish)
]
},

// ==========================
// ====== BEGIN CARRY ======
// ==========================

"BEGIN_PROBLEM_CARRY": {
"type": "NODE",
"COMMENT": "Regular problem with no carry or borrow.",
"maptype":"moduleMap",
"mapname": "EMPTY",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "NEXT_DIGIT_C"}
]
},

// MATH_AG (c)
// MATH_AG ONE_DIGIT_C
// MATH_AG (c) TAP_THINGIES...
// MATH_AG (c) "Write a one HERE... "
// MATH_AG (s) sound files are here
// MATH_AG (s) https://drive.google.com/drive/u/0/folders/1_ZaJmkW7rioIz7gIovIfdH6OQhgXyvQw
"NEXT_DIGIT_C":{
"COMMENT":"This node moves to the next digit in the problem.",
"type":"node",
"maptype":"moduleMap",
"mapname": "NEXTDIGIT",
"preenter":[],
"preexit" :[],
"edges":
[
{"constraint":"","edge":"USER_INPUT_C"}
]
},

"USER_INPUT_C": {
"COMMENT":"Preps the tutor for user input, then waits for user input.",
"type": "node",
"maptype":"moduleMap",
"mapname": "USERINPUT",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_C"},
{"constraint": "", "edge": "WRONG_FEEDBACK_C"}
]
},

"CORRECT_FEEDBACK_C": {
"COMMENT": "Provides feedback for correct response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "CORRECTFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_C"}, // if done with problem, continue to next problem
{"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_C"} // if not done, progress to next digit
]
},

"WRONG_FEEDBACK_C": {
"COMMENT": "Provides feedback for wrong response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "WRONGFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "USER_INPUT_C"} // go back to wait for user input
]
},

"PROBLEM_CORRECT_C": {
"COMMENT": "When user has completed a problem.",
"type": "node",
"maptype": "moduleMap",
"mapname": "PROBLEMCORRECT",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_MORE_PROBLEMS", "edge": "NEXT_PROBLEM"}, // if more problems, go to next problem
{"constraint": "FTR_PROBLEMS_DONE", "edge": "NEXT_SCENE"} // if problems done, go to next scene (aka finish)
]
},

"BEGIN_PROBLEM_BORROW": {
"type": "NODE",
"COMMENT": "Regular problem with no carry or borrow.",
"maptype":"moduleMap",
"mapname": "EMPTY",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "NEXT_DIGIT_B"}
]
},

"NEXT_DIGIT_B":{
"COMMENT":"This node moves to the next digit in the problem.",
"type":"node",
"maptype":"moduleMap",
"mapname": "NEXTDIGIT",
"preenter":[],
"preexit" :[],
"edges":
[
{"constraint":"","edge":"USER_INPUT_B"}
]
},

"USER_INPUT_B": {
"COMMENT":"Preps the tutor for user input, then waits for user input.",
"type": "node",
"maptype":"moduleMap",
"mapname": "USERINPUT",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_CORRECT", "edge": "CORRECT_FEEDBACK_B"},
{"constraint": "", "edge": "WRONG_FEEDBACK_B"}
]
},

"CORRECT_FEEDBACK_B": {
"COMMENT": "Provides feedback for correct response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "CORRECTFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "FTR_PROBLEM_DONE", "edge": "PROBLEM_CORRECT_B"}, // if done with problem, continue to next problem
{"constraint": "FTR_PROBLEM_HAS_MORE", "edge": "NEXT_DIGIT_B"} // if not done, progress to next digit
]
},

"WRONG_FEEDBACK_B": {
"COMMENT": "Provides feedback for wrong response.",
"type": "node",
"maptype": "moduleMap",
"mapname": "WRONGFEEDBACK",
"preenter": [],
"preexit": [],
"edges": [
{"constraint": "", "edge": "USER_INPUT_B"} // go back to wait for user input
]
},

"PROBLEM_CORRECT_B": {
"COMMENT": "When user has completed a problem.",
"type": "node",
"maptype": "moduleMap",
Expand Down Expand Up @@ -149,6 +322,15 @@
]
},

"EMPTY": {
"type": "MODULE",
"reuse": true,
"COMMENT": "???",
"tracks": [
{"name": "LOG_EVENT", "type": "QUEUEDCOMMAND", "id": "SBigMath", "method": "logState", "parms": "type#node,value#EMPTY:String", "features":""}
]
},

"NEXTDIGIT": {
"type": "MODULE",
"reuse": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ public class BM_CONST {
public static final String OPB_LOCATION = "opB";
public static final String RESULT_LOCATION = "result";

// class for just features
public static final class FEATURES {

// for choosing which type of problem
public static final String FTR_IS_CARRY = "FTR_IS_CARRY";
public static final String FTR_IS_BORROW = "FTR_IS_BORROW";

// for correct vs wrong answers
public static final String FTR_CORRECT = "FTR_CORRECT";
public static final String FTR_WRONG = "FTR_WRONG";

// for when the problem is finished, or has more to do
public static final String FTR_PROBLEM_DONE = "FTR_PROBLEM_DONE";
public static final String FTR_PROBLEM_HAS_MORE = "FTR_PROBLEM_HAS_MORE";

// for when the data source has more problems or not
public static final String FTR_MORE_PROBLEMS = "FTR_MORE_PROBLEMS";
public static final String FTR_PROBLEMS_DONE = "FTR_PROBLEMS_DONE";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ protected void updateDataSet(CBigMath_Data data) {
// first load dataset into fields
loadDataSet(data);

// features are published inside setData() {... _sal.setData() }
_mechanic.setData(data);
_mechanic.doAllTheThings();

}

/**
Expand All @@ -141,7 +141,6 @@ protected void loadDataSet(CBigMath_Data data) {
task = data.task;
layout = data.layout;
dataset = data.dataset;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import static cmu.xprize.comp_bigmath.BM_CONST.ALL_DIGITS;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_CORRECT;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_IS_BORROW;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_IS_CARRY;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_PROBLEM_DONE;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_PROBLEM_HAS_MORE;
import static cmu.xprize.comp_bigmath.BM_CONST.FEATURES.FTR_WRONG;
Expand Down Expand Up @@ -73,6 +75,9 @@ public void setData(CBigMath_Data data, int numDigits) {
operator = data.operation;
_numDigits = numDigits;

// retract carry and borrow features...
_publisher.retractFeature(FTR_IS_CARRY);
_publisher.retractFeature(FTR_IS_BORROW);
if (operator.equals("+")) setCarryLogic(operandA, operandB);
else setBorrowLogic(operandA, operandB);

Expand All @@ -90,7 +95,11 @@ private void setCarryLogic(int a, int b) {

// if a_one + b_one > 9, we must carry to tens column
_isCarryOne = getOnesDigit(a) + getOnesDigit(b) > 9;
if (_isCarryOne) {
_publisher.publishFeature(FTR_IS_CARRY);
}

if (_numDigits < 3) return; // only works for hundreds...
// if (carried_ten) + a_one + b_one > 9, we must carry to the huns column
_isCarryTen = (_isCarryOne ? 1 : 0) + getTensDigit(a) + getTensDigit(b) > 9;

Expand All @@ -107,7 +116,11 @@ private void setBorrowLogic(int a, int b) {

// if a_one < b_one, we need to borrow a ten from a_ten
_isBorrowTen = getOnesDigit(a) < getOnesDigit(b);
if (_isBorrowTen) {
_publisher.publishFeature(FTR_IS_BORROW);
}

if (_numDigits < 3) return; // save this for later, when we do 3 digits
// if a_ten - (borrowed_ten) < b_ten, we need to borrow a hundred from a_hun
_isBorrowHun = getTensDigit(a) - (_isBorrowTen? 1 : 0) < getTensDigit(b);

Expand Down Expand Up @@ -214,16 +227,21 @@ public void fireAction(String selection, String action, String input) {
_publisher.retractFeature(FTR_PROBLEM_HAS_MORE);
_publisher.publishFeature(FTR_PROBLEM_DONE);
} else {


// ROBO_MATH MATH_AG move this logic to animator graph carry check should be moved here...

_bigMath._currentDigit = TEN_DIGIT;
_publisher.retractFeature(FTR_PROBLEM_DONE);
_publisher.publishFeature(FTR_PROBLEM_HAS_MORE);
}

// ROBO_MATH NEXT NEXT NEXT figure out messy carry stuff
// ROBO_MATH MATH_AG move to go with logic
if(_isCarryOne) {

_hasWrittenOnesResult = true;
// can't go to next digit unless we've written carry
// MATH_AG this should go inside "NEXT_DIGIT"
_bigMath.showCarryTen();
if(!_hasCarriedToTens) {
break;
Expand Down Expand Up @@ -261,13 +279,19 @@ public void fireAction(String selection, String action, String input) {

case "symbol_carry_ten":

// ROBO_MATH NEXT NEXT NEXT, there should be some behavior here
// ROBO_MATH NEXT NEXT NEXT, they should be written in any order (also, this is optional)
expectedInput = _isCarryOne ? 1 : 0; // the zero won't get used...

if(input.equals(String.valueOf(expectedInput))) {

// give some sort of correct feedback???
_bigMath.markDigitCorrect(TEN_CARRY_DIGIT);
// _publisher.retractFeature(FTR_WRONG);
// _publisher.publishFeature(FTR_CORRECT);

_hasCarriedToTens = true;
// ROBO_MATH (xx) both of these must be done
if (_hasWrittenOnesResult) {

// ----------
Expand Down

0 comments on commit 7795bba

Please sign in to comment.