Message Boards Message Boards

Make a interactive Biology game to teach taxonomic classification?

GROUPS:

Generally speaking, I can usually overcome any programming snags with some persistence and by delving into documentation and the Internet. But this time I'm stuck.

I'm making a simple game to get students used to taxonomic classification. In the game, the player sees an organism's picture and/or common name. Beneath that it says "Kingdom: " followed by an ActionMenu[]. When the player chooses correctly from the menu, a new line is added that says "Phylum: " followed by another ActionMenu[], etc. This all works, but when it continues to class, order, family, genus, and species it does not replace the ActionMenu[] with the correct answer and it does not update the score. I suspect the issue is related to Dynamic, but I'm not sure.

Can anyone help me get unstuck? Please?

By the way, the game's not done. I intend to speed up the organism selection, add behavior for wrong answers, and give it a meaningful scoring system. I'll finish it when I get unstuck and post the complete code here.

Here is what I've got so far...

taxa = {"Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"};
spec = Entity["Species", "Class"];
qCt = 1;
score = 0;
Print[Dynamic[spec]];
While[
  Not[spec["TaxonomicLevel"][[2]] == "Species" \[And] (StringQ[spec["CommonName"]] \[Or] ImageQ[spec["Image"]])],
  spec = RandomEntity["Species"]];
stats = EntityValue[spec, Join[{"CommonName", "Image"}, taxa]];
alts = Prepend[Table[Prepend[RandomSample[EntityValue[stats[[n]], "Siblings"], UpTo[6]],stats[[n]]], {n, 4, 9}],EntityList[EntityClass["Species","Kingdom"]]];
ansRt[lvl_, ent_] := (
   Print[{lvl, ent}];
   ques[[lvl, 1, 3]] = ent;
   game[[1, 1]] = Insert[game[[1, 1]], ques[[lvl + 1]], -2];
   score += 100;
   qCt += 1);
ansWr[] := score -= 33;
menu = Table[ActionMenu["choose",RandomSample[Table[If[Length[alts[[n]]] >= m, If[m == 1, alts[[n, m]] :> ansRt[h2, alts[[h2, 1]]] /. {h1 -> m,h2 -> n}, alts[[n, m]] :> ansWr[]], Nothing], {m, 1,7}]]], {n, 1, 7}];
ques = Table[Row[{taxa[[q]], ": ", menu[[q]]}], {q, 1, 7}];
game = Dynamic[Column[{stats[[2]], Style[stats[[1]], 36], ques[[1]],StringForm["Score: `1`", score]}]];
TraditionalForm[Style[Dynamic[game], 24]]

Thank you in advance,

Mark

POSTED BY: Mark Greenberg
Answer
4 months ago

Hello Mark,

You were correct in thinking that your problem had something to do with Dynamic. Essentially your issue was that although the displayed form of game was being updated, the displayed forms of the symbols in the Column were not being displayed dynamically, with the exception of the first element of ques. To fix this, I altered the definitions for both game and ansRt so that both score and the inserted elements from ques will be updated.

Note that I also removed the outer Dynamic in the definition of game. Because you used Dynamic in the last line of your code, it wasn't really necessary and was basically just forcing you to use extra indices.

ansRt[lvl_, ent_] := (
   Print[{lvl, ent}];
   ques[[lvl, 1, 3]] = ent;
   game[[1]] = Insert[game[[1]], Dynamic[ques[[lvl + 1]]], -2];
   score += 100;
   qCt += 1);

game = Column[{
    stats[[2]],
    Style[stats[[1]], 36],
    Dynamic[ques[[1]]],
    Dynamic[StringForm["Score: `1`", score]]
}];

As you can see, I really only had to add Dynamic to the occurrences of score and ques that appeared in game (including the ones that are inserted during the evaluation of ansRt) so that they will be appropriately updated when the ActionMenu evaluates ansRt. Now everything works just fine and your students can classify creatures to their heart's content. I've included a screenshot in case anyone was curious:

enter image description here

POSTED BY: Matt Woodbury
Answer
1 month ago

Thank you, Matt. Dynamic is a tricky concept. I've yet to wrap my head around it.

I did end up with a working version of the game through a similar solution to yours, though I still have the Dynamic in the last line. Your solution is cleaner, so I won't post mine. I'll go back and see whether I can clean my version up.

Thanks again,

Mark

POSTED BY: Mark Greenberg
Answer
1 month ago

A biological, not Mathematical, comment: I hope you're no longer teaching that there are just the 2 kingdoms of animals and plants. See,. e.g., [this Wikipedia article]( https://en.wikipedia.org/wiki/Kingdom_(biology)#Modern_view).

POSTED BY: Murray Eisenberg
Answer
1 month ago

Thanks, Murray, for the comment. The game pulls its taxonomic data from the Wolfram curated data. That way if classifications change, the game changes too. Currently the kingdoms that the player has to choose from are animals, chromistans, bacteria, viruses, archaeans, fungi, and protozoans.

POSTED BY: Mark Greenberg
Answer
1 month ago

Group Abstract Group Abstract