// Note: We keep the data and the states in this component class BasicStopExplain extends React.Component { constructor(props) { super(props); this.state = { // Check whether all nodes are clicked isClicked: [ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true ], // Save continuation decision in percent continuation: [ 100, 100, 100, 100, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, // 1, 1, 1, 1, 1, 1, 1 // 1, 1, 1, 1, 1, 1, 1, 1 ], stopPath: [100], // Save stop along the path, necessary for bonus ball // Save outcome path drawn: [0], currentRound: 0, currentNode: -1, // Keep track of currently clicked node imagePath: '/static/img/coin_questionmark.png', imagePathGuess: '/static/img/coin.png', winningSide: "", nextCoin: false, szenario: 1, paths: { "1": [0,1,3,7, 11, 17], // Path for szenario 1 "2": [0,2,4, 7, 11, 17] // Path for szenario 2 }, showRepetitions: true, }, this.simulateCoinToss = this.simulateCoinToss.bind(this); this.winningSideUpdate = this.winningSideUpdate.bind(this); this.startAnewBtn = this.startAnewBtn.bind(this); this.nextCoin = this.nextCoin.bind(this); } winningSideUpdate(chosenSide) { // Disable winning side buttons var ele = document.getElementsByName("winningSideInput"); for(var i=0;i this.simulateCoinToss(), 500 ); } simulateCoinToss(){ const {paths} = this.state; let {szenario, drawn, currentRound, showRepetitions, stopPath} = this.state; if (!showRepetitions){ document.getElementById("repetitionExplain").classList.add("d-none") return; } currentRound = currentRound + 1; let relPaths = paths[szenario] drawn[currentRound] = relPaths[currentRound] stopPath[currentRound] = this.state.continuation[drawn[currentRound]] // Grey background for selection section document.getElementById("pickWinningSide").classList.remove("alert-warning"); document.getElementById("pickWinningSide").classList.add("alert-secondary"); // Disable winning side buttons var ele = document.getElementsByName("winningSideInput"); for(var i=0;iblack. A black ball instructs the computer to stop risk-taking.
If this was the result of your bonus task, your bonus would be the accumulated earnings at this ball plus the endowment. ` stopPath[currentRound] = "Stop" } else if (currentRound == 5) { document.getElementById("currentNode").innerHTML = ` This ball is black.
You are in the last column of the ball triangle and no more single risks can be taken.
If this was the result of your bonus task, your bonus would be the accumulated earnings at this ball plus the endowment. Thus, the ball is colored gold and contains a "B" for bonus.
Please click "Start anew" to practice another path through the ball triangle. ` document.getElementById("explanationCol").scrollIntoViewIfNeeded({ block: "end", inline: "nearest", behaviour: "smooth", }) stopPath[currentRound] = "Stop" } else if (szenario == 1 && currentRound == 1) { document.getElementById("currentNode").innerHTML = ` This ball is white. White balls instruct the computer to continue risk-taking.
Please resolve the next single risk. ` document.getElementById("explanationCol").scrollIntoViewIfNeeded({ block: "end", inline: "nearest", behaviour: "smooth", }) } else { document.getElementById("currentNode").innerHTML = ` This ball is white. ` } this.setState({ drawn: drawn, currentRound: currentRound, szenario: szenario, showRepetitions : showRepetitions, stopPath: stopPath, }) } nextCoin() { document.getElementById("pickWinningSide").classList.add("alert-warning"); document.getElementById("pickWinningSide").classList.remove("alert-secondary"); document.getElementById("coinTossWon").classList.add("d-none") document.getElementById("coinTossLost").classList.add("d-none") document.getElementById("moveUp").classList.add("d-none") document.getElementById("moveDown").classList.add("d-none") document.getElementById("placeholderFooter").classList.remove("d-none") var ele = document.getElementsByName("winningSideInput"); for(var i=0;iwhite. ` var ele = document.getElementsByName("winningSideInput"); for(var i=0;i
Coin toss: Win or lose?
Coin toss outcome The winning side
 
Heads Tails
this.winningSideUpdate("H")} className="largerRadio"/> this.winningSideUpdate("T")} className="largerRadio"/>
You won this single risk.
You lost this single risk.
The repeated risk
You moved up.
{!(this.state.currentRound == 2 && this.state.szenario == 2) ?
: <>}
You moved down.
{!(this.state.currentRound == 2 && this.state.szenario == 2) ?
: <> }
) } }