Lerrrtaste
Lerrrtaste

Reputation: 35

WPM formula doesn't work

I'm using the following code to calculate WPM (words/minute), CPM (chars/minute), CPS (chars/second) and Accuracy in a typing software.

//wpm
global.wpm = global.total_words / runtime_min;

//cpm
global.cpm = global.total_chars / runtime_min;

//cps
global.cps = global.total_chars / (runtime_min/60);

//accuracy
global.accuracy = 100 -((global.total_wrongChars*100)/global.total_chars);

Accuracy works, but the other spit out too high numbers, like 2843.1565 when it should be 1

Upvotes: 0

Views: 75

Answers (1)

Pabilo8
Pabilo8

Reputation: 16

You can make a custom variable at the create event

global.step_counter=0;

And increase it every step

global.step_counter+=1;

Then you can use in your code like this

//Steps / steps per second / seconds
var duration = global.step_counter / room_speed / 60

//wpm
global.wpm = global.total_words / duration;

//cpm
global.cpm = global.total_chars / duration;

//cps
global.cps = global.total_chars / (duration/60);

//accuracy
global.accuracy = 100 -((global.total_wrongChars*100)/global.total_chars);

Upvotes: 0

Related Questions