[Tux4kids-tuxtype-dev] Reporting the result of Phrase Typing in Tuxtype

David Bruce davidstuartbruce at gmail.com
Mon Jul 19 20:08:42 UTC 2010


Hi Vikas,

> In the current game, there is no implementation for the paragraph as a
> whole.
> Since reporting data per phrase in a paragraph does not make sense for me at
> least,
> so shall I go forward and implement the calcuation for cpm,wpm etc. for
> whole of the paragraph ?

The phrase typing activity could use some overhaul.  As it stands now,
each "phrase" is a string that is limited to 256 chars
("MAX_PHRASE_LENGTH" in practice.c), which is enough for most
sentences but not enough for paragraphs.  We now have an array of
256x256 bytes to store the phrases, as the program can have up to 256
phrases loaded at a time.  That's 64K memory just for this array,
which maybe isn't much by modern standards, but is still probably 95%
empty.

The activity splits each phrase into displayable sections based on
pixel width of the rendered text, not based on a number of characters.
 The relevant wrapping code is something I wrote a couple of years
ago.  Subsequently, we have incorporated part of the GNU Linebreak
library into tuxmath to do something similar, and this function should
get shifted into libt4kcommon.

The typing stats get erased on the screen if there is a wrap, but they
are still carried cumulatively until the end of the phrase.  They get
reset at that point and aren't saved anywhere.

So, as a rough first start we could increase MAX_PHRASE_LENGTH to
however long it needs to be to contain the desired paragraphs.
However, this would be a very inefficient use of memory, so we
eventually should do something "smarter" (perhaps dynamic allocation).
We could also add some code to write the stats to a log file when each
string (phrase/sentence/paragraph) is completed.

Then, as a second step, let's revamp how we store the
phrases/paragraphs, switch to liblinebreak, get rid of my handwritten
wrapping code, and change the display to show a few lines at a time
rather than just one line.

Best,

David Bruce



More information about the Tux4kids-tuxtype-dev mailing list