Skip to content

Instantly share code, notes, and snippets.

@ne1uno
Last active May 4, 2022 08:08
Show Gist options
  • Save ne1uno/19f189d7b1526148554326e662ca1707 to your computer and use it in GitHub Desktop.
Save ne1uno/19f189d7b1526148554326e662ca1707 to your computer and use it in GitHub Desktop.
cog test prototype with XN and Stroop
cognitive style tests, games, brain teasers.
see screenshot cog-test-red-lang.gif
https://usercontent.irccloud-cdn.com/file/3FxMnTHm/cog-test-red-lang.gif
download an under 2mb cross platform script interpreter/compiler from red-lang.org
warning, could crash or silent exit at any moment. it's not you it's me.
I knocked this together in a few hours/days, it's at best lightly tested.
will work w/o @GalenIvanov Animation DSL with a few conditionals
may be the default soon in recent red-lang anyway
https://github.com/GalenIvanov += exact download raw link
not a fan of hot linking. to see animations, download into same directory.
will add some interesting transitions to the feedback words
not sure I want to re-write rich-text ATM, draw can work there too.
not sure how to detect Animation DSL builtin and build date not reliable
the XN test will briefly show various combinations of characters. 8HKX7
you try to remember the color of only X or N and report the 2 outer digits.
sounds simple, till you reduce the response time, zoom or move around.
hint: unless you have a photographic memory, think/say the color & digits
is not designed to be a research ready tool,
more like a game to sharpen your focus and improve cognitive abilities.
is not going to be the most fun game you've ever played.
could make it more fun by showing full words or icons instead of characters.
it's mostly a proof of concept for similar timed response games.
I'm not a psych researcher, but I have participated as a respondent...
that's how I found this test I'm calling XN, a variation on a theme.
how quick is too quick to maintain accuracy? how quickly can you focus?
if an app is to be used to conduct research, you would need to collect data,
safely transfer or email the data, have stable millisecond timing,
good instructions and practice runs to make sure you understand. etc, etc.
you can find any number of apps/programs doing similar things out there.
there are numerous ways to implement similar tests! html, inquisit, java.
often, the behavior being tested has nothing to do with the game itself
beyond demonstrating a basic comprehension of instruction and perception.
maybe just a break between other tests or simple reaction time test.
maybe the arrangement of colors vrs other arrangements vrs demographics.
or was a suggestion in the instructions crafted to elicit a response?
next to implement, the Stroop effect of WORDS in color.
https://wikimili.com/en/Stroop_effect
https://psychology.fandom.com/wiki/Stroop_Colour_Word_Test
https://en.wikipedia.org/wiki/Numerical_Stroop_effect
https://en.wikipedia.org/wiki/Emotional_Stroop_test
others on the table
back 2 memory capacity test. this one will overheat your brain.
https://en.wikipedia.org/wiki/N-back
person man woman camera tv. short list recall can be difficult as you age.
warnings not to write down or screen shot the words run the gamut.
see my sets game, an unfinished implementation of an old card game with mp4 demo
various sets games are used in research of the brain and is how I found it.
https://github.com/ne1uno/util-games unzip and run interpreted or windows executable
http://en.wikipedia.org/wiki/SET_(game)
http://smart-games.org/en/main/rules/
Red [
Title: "cognitive tests"
Author: "ne1"
Date: "2022-4"
; icon: %test.png ;
; rights: ""
; productname: "built with Full Stack Tech from red-lang.org"
Needs: 'View ;
]
dev+: on ; on off for extra print debugging
random/seed now/time/precise
system/view/auto-sync?: no ;do I need this?
;may need ordinal and shorter list linux colors. for the upteanth time
;not easy search term. surely someone has a top 64 or 48 colors
; https://superuser.com/questions/tagged/colors+linux?sort=newest&page=5&pagesize=15
; https://www.infoplease.com/arts-entertainment/crayola-crayon-colors
; Big list of color names
; https://gist.github.com/yudhasetiawan/0ddb342ec470b7a0fa29fc5902371937#file-misc-json
; https://ux.stackexchange.com/questions/85088/ideal-color-palette-for-24-colors
; https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors
; Crayola 64 name list hex sorted
; http://www.jennyscrayoncollection.com/2017/10/complete-list-of-current-crayola-crayon.html
; https://www.w3schools.com/colors/colors_crayola.asp
;get Animate.red from GalenIvanov-Animation-tests
;also need greater than 2019/11 red-lang for some effects
;2019/11 is a few months before fast lexer
; is just a convenient windows test version.
; linux or mac may well need a more recent red-lang
;
; so check what? last, sum, average added prior
; unless you include compatibility libs
; ? enhex, added around 2020/9 does d2d, early 2020 matter?
; test case Animation-tests-15dc0c9\Tests\parameter.red has countdown
;only spot checked 2019/11 2020/12 2021/7 2022/4 so far
; not an exhaustive test, just drawing a line.
; I still want it to work ok if Animate.red not available
use-animate: all [
no ; no = skip
either unset? get/any 'enhex [probe "skipping Animate" none][yes]
;either unset? get/any 'animate ;not sure how to detect builtin
exists? %./Animate.red
do %./Animate.red
probe "using Animate" yes
]
probe use-animate ;yes or none , set directly Animate DSL if builtin
; halt
; if all [object? :system/view system/platform = 'Windows]
bg-color: 255.255.240 ;"ivory"
fg-color: 178.34.34 ;"brick"
;define 8 easy to recognize colors, later enable light/dark/other theme
;idealy, anyone could scrollwheel on color bars to pick another hue or label
; need red green yellow blue, whatever in first four for stroop
; make color array and string array, not sure needed to be zipped
; why did I need colors_1..8 anyway? in view, paths are problematic?
;also turn into map with inverse keys so can get color or label directly
; avoid some ugly find/extract later on
;need a find that can work deep unextracted
;gold & orange, gray & black still pretty close if you need to decide fast
; primary color wheel clockwise
; red magenta blue cyan green yellow
colors: reduce [
color_1: 255.0.0 "red"
color_2: 0.255.0 "green" ;teal or mint too dark, need more distinct
color_3: 255.165.0 "orange" ;bright yellow not great, mustard too goldish
color_4: 0.0.255 "blue"
color_5: 238.130.238 "violet"
color_6: 128.128.128 "gray" ;silver looks gray
color_7: 255.215.0 "gold" ;gold nicer than yellow, can't be both
color_8: 0.0.0 "black"
]
colors-map: make map! [] ;loses order if init w/colors
cnt: 1
foreach [k v] colors [; add inverted keys
colors-map/:k: v
colors-map/:v: k
colors-map/:cnt: v ;index to color name
cnt: cnt + 1
]
; print [mold colors-map]
; halt
sm-font: make font! [ ;indicator text
name: "Consolas"
size: 9
color: fg-color
]
med-font: make font! [ ;most text, help
name: "Consolas"
size: 11 style: 'bold
color: fg-color
]
big-font: make font! [ ;display
name: "Consolas"
size: 15 style: 'bold
color: fg-color
]
huge-font: make font! [ ;target string
name: "Consolas"
size: 25
color: fg-color
]
choices: make object! [
xn: make object! [
difficulty: 50 ;controls how long can see and how fast to choose
see-timer: none ;how much time to see target w/difficulty
pick-timer: none ;how much time to choose w/difficulty
time-word: none ;none triggers score to start timers first time
text: none ;target string, can compare digits easy enough
colors: copy [] ; makes sense to store all 3 colors so can recreate
current-color: none ;user choices, as they are made score checks timer
current-digits: none
hist: copy [] ;track game stats
]
; stroop: make object! [
; ]
]
; choices/xn/see-timer: choices/xn/difficulty * 15 ;15 = ~750ms for 50% difficulty
; choices/xn/pick-timer: choices/xn/difficulty * 30 ; 40 * 50 is 2000 milliseconds
;2 seconds can be an eternity
;initial calc of difficulty for XN, FIXME when enable slider
;why are timers not milliseconds? 00:00:00:0750 no ms?
choices/xn/see-timer: either dev+ [00:00:04][00:00:02]
choices/xn/pick-timer: either dev+ [00:00:11][00:00:18]
;; ********** probably nothing above is configurable **********
;; you may need to edit some UI elements depending on window manager
;research deal-breaker if can't control see-timer ms
;also unplanned delay unavoidable w/multitasking
;the time string appears and time to respond will not be linear to difficulty
; guessing lower than 300ms probably anyone over 20 won't be able to resolve
; there will be individual differences in how fast buttons can be clicked
; size of ui, distance to monitor, quality of hardware & skill
; will need several algorithm to choose from to control difficulty slider math
; not sure how reliable timers are given computers are doing other things
; this makes for a poor research environment which demands repeatable results.
; software tools like inquisit take steps to isolate from the OS
; I have no idea yet what is the lowest amount of time I can display text
if unset? get/any 'explode! [ ;breakup target to chars
; Request split accept none to allow for "exploding" series! #2655
explode!: func [{like split "" returns block of chars} str [series!] /local c]
[ collect [foreach c str [keep c]]
]
] ;explode!: :explode ;still no split s none or join/with
;thought extract s 1 worked, but was something else
;may need few things for rolling average graph? std-dev?
; may just plot time and scroll it
; do %../../libs/statistical.rd
reset-timers: func ["optionally, reset everything current user"
/won
/lost
][
if any [won lost] [
;need to know if timer was what percent faster than timeout
;need to redo win/lost check? need to keep just last few
;book-keep choices & history
probe append/only choices/xn/hist reduce [
choices/xn/text
choices/xn/colors
choices/xn/current-color
choices/xn/current-digits
choices/xn/time-word
]
choices/xn/current-color: none
choices/xn/current-digits: none
choices/xn/colors: copy [] ;clear or leak/gc?
choices/xn/text: none
print ["do another " choices/xn/time-word]
rt: copy [{^/^/^/^-^-}] ;need clear data?
gen-xn
repend rt draw-xn ;needs to fade in xn/see-time
rt: rtd-layout rt
rt-xn/data: rt/data
rt-xn/text: rt/text
rt-xn/rate: choices/xn/see-timer
c-xn/rate: 0:0:5 ;cls canvas too
;face/text: form choices/xn/time-word: 0:00:00 ;off we go
]
;others will show win/lose and pick next target
;think only called now win/lose
fc-xn/text: ""
fd-xn/text: ""
choices/xn/time-word: choices/xn/pick-timer
cd-xn/rate: 0:0:1 ;start countdown
]
#define___score__
feedback: func ["show some text in canvas, possibly animated"
/welcome
/won
/lost
/local txt
][
;pick random phrases of type later
txt: case [
welcome [" Welcome to a COG Test "]
won ["is correct!"]
lost ["not correct"]
'else ["Bye!"] ;
]
c-xn/rate: 0:0:18 ;need rate for animate? cls too
either use-animate [
;how from function?
c-xn/draw: reduce ['animate compose/deep [ ;from animate dsl test demos
'start 1.0 'duration 2.0 'ease to-get-word 'ease-in-out-quad
'font big-font
'parameter big-font/color 'from
255.255.255.255 'to 255.50.20.0
; try red + 0.0.0.255 to yellow + 0.0.0.0
'text 'from 290x20 'to 90x20 txt
'start 3.0 'duration 2.0 'ease to-get-word 'ease-in-cubic
'fill-pen 'from (transparent) 'to bg-color ;on-exit [quit]
'box 0x0 350x55
] c-xn ;/face
]
][
;2019/9 exits w/big-font 2019/11 ok
;face/draw: [font big-font text 75x30 "welcome to cog test"]
c-xn/draw: reduce ['text 105x20 txt]
; goea away in a few seconds
]
]
;xarea: #(none none)
score: func ["evaluate choices and decide if round over, show results"
/local i
][
if dev+ [print ["score" mold/all choices choices/xn/time-word]]
;why isn't this appending unless primed?
xarea/text: rejoin ["score " mold/all choices newline copy/part xarea/text 1500]
if none? choices/xn/time-word [ ;only at fresh start game
;think one of the controls will have rate
;then that will timeout and run code from then on
;xyz/rate: choices/xn/pick-timer
play-xn/enabled?: true
play-xn/text: "pause"
choices/xn/time-word: choices/xn/pick-timer
;reset-timers ;reset everything, not good
cd-xn/rate: 0:0:1 ;start countdown
rt-xn/rate: choices/xn/see-timer ;clear target
return none
]
if i: find choices/xn/text "X" [i: index? i]
if not i [i: index? find choices/xn/text "N"] ;one or the other
if dev+ [print ["score 'i" i]]
;checking all really not efficient if need to check again for partial
if all [
choices/xn/current-digits ;might be none or 1 or 2 digits
2 = length? choices/xn/current-digits
choices/xn/current-digits/1 = first choices/xn/text
choices/xn/current-digits/2 = last choices/xn/text
choices/xn/current-color
choices/xn/current-color = choices/xn/colors/(i - 1) ;XN math
] [
if dev+ [print ["score all correct!"]]
;show feedback & pause for a moment
feedback/won
reset-timers/won
return none
]
;screwed till figure out milliseconds
if choices/xn/time-word > 0:0:0 [ ;round not done
if dev+ [print ["score time left..." choices/xn/time-word]]
return none ;complained about bare return because of clicked?
]
if dev+ [
print ["score all not correct! XN was "
choices/xn/text choices/xn/colors/(i - 1) "you picked"
choices/xn/current-color choices/xn/current-digits]
]
feedback/lost
reset-timers/lost
print [" lost "]
;won or lost, nothing else to deal with, it's all timers all the way down
;set hist, clear color & digit fields, reset timers
return none
]
clicked: func ["update choices from color or digit buttons"
ftext
/c
/d
][
case [
c [choices/xn/current-color: copy ftext]
d [choices/xn/current-digits: copy ftext]
]
;little weird passing control to score like a dead end
score ;this should be called by whomever called clicked?
]
;likely need to refactor a few things to reuse clicked for stroop
;need rich-text here to show words in color
; modal not ideal but otherwise help window can get lost
show-help: function ["popup instruction reminder"
which "xn stroop default"
;/extern bg-color med-font fg-color
][
fs: med-font/size ;not sure why can't use font more directly
;last font style becomes default?
help-y: 320 ;fs * nlines
;keeps complaining about nesting bold in font?
;
utext: case [
which = "stroop" [
help-y: 420
[<font> fs fg-color {
measuring the Stroop effect is a standard psychological test.
possibly randomly you will see a } </font> ;sticky font settings
<b> "COLOR" </b> { word,
like }
<font> fs RED <b> "RED" </b> </font>
<font> fs fg-color ", " </font>
<font> fs ORANGE <b> "BLUE" </b> </font>
<font> fs fg-color ", " </font>
<font> fs BLUE <b> "ORANGE" </b> </font>
<font> fs fg-color " or " </font>
<font> fs GREEN <b> "GREEN" </b> </font>
;wtf, need size & color every time?
; fails outer bold if set color?
<font> fs fg-color {
colorized in maybe that color or one of the other colors
you will read cues and report either the actual word or the color.
you will click one of the colors if asked for colors
or if asked for spelling, again, which is the correct COLOR.
using your [keyboard or] mouse to decide as fast as possible.
this is not difficult but requires concentration!
score of correct and rolling average of a few will be shown.
eventually more options to set times and adjust colors.
a slider is provided to adjust the speed and difficulty.
there are a variety of places the Stroop effect is noticed.
psychologists probably rather nobody played mind games
for fear any effect will be more difficult to measure.
this however, is just a game based on that noticeable effect.
have fun!}
</font>]]
;too long, rich-text can't scroll. need 2nd page
;seems not to like nested font bold?
; difficulty might be more letters, red might be something else
;turn X red also rest of strings
; which = "xn" [[<font> fs fg-color {
; you are shown 5 characters, very briefly.
; an outer digit, 3 letters and another digit. like: } </font>
; <b> "8 " </b> <font> fs red "X" </font> <b> " V Y 3" </b> {
; remember the color on letters } <b> "X or N" </b> { only
; and report both of the outer digits.
; a slider is provided to adjust the speed and difficulty
; }]]
;try nesting again, no diff
which = "xn" [
help-y: 300
[<font> fs fg-color
{you are shown 5 characters, very briefly.
an outer digit, 3 letters and another digit. like: }
<b> "8 " </b> </font>
<font> fs colors-map/("RED") <b> "X" </b> </font> <font> fs fg-color
<b> " V Y 3" </b> {
remember the color on letters } <b> "X or N" </b> { only
and report both of the outer digits.
a slider is provided to adjust the speed and difficulty
} </font>]]
'else [
help-y: 300
[<font> fs fg-color {
no option available
TBD RSN
} </font>]]
]
forall utext [ ; strip indent
;2019 crash at parse?
;if string! = type? utext/1 [utext/1: replace/all utext/1 "^-^-^-" " "]
case [
string! = type? utext/1 [replace/all utext/1 "^-^-^-" " "]
;tag! = type? utext/1 [utext/1: to-lit-word utext/1]
;word! = type? utext/1 [utext/1: to-lit-word utext/1]
]
]
rtd: rtd-layout reduce utext ; probe
view/flags v: layout compose/deep [
title {help cognitive tests}
backdrop bg-color
rt: rich-text (as-pair 420 help-y) bg-color ; no scroll
with [text: rtd/text data: rtd/data]
; default rich-text size very narrow?
;may be better ways to deal with this? rtd-layout/into?
;reduce utext errors??
return
;no center shortcut?
pad (as-pair to-integer (help-y / 2) - 10 0)
uvb: button font med-font "Ok" [unview self]
;react
;on-resizing [uvb/offset/x: self/window/offset/x // 2]
]['popup 'modal] ; 'resize
; modal focus wonky on exit 2019 win10, loses focus
; modal seems fixed by 2021+, slight flash
v
]
#define___show_help__
;FIXME chg print to func to tee msgs
draw-xn: func ["make rich-text of text target"
/local blk huge rc tx c
][
tx: either choices/xn/text [explode! choices/xn/text][print "mmf draw-xn" halt]
rc: copy/part random extract colors 2 3 ;extract copies too?
huge: huge-font/size
;old way w/o map
;t: index? find extract colors 2 rc/3
;append choices/xn/colors form colors/(((t - 1) * 2) + 2)
;digits
insert rc fg-color
append rc fg-color
if dev+ [print [mold tx mold rc huge]]
blk: copy [<b>]
repeat c 5 [ ;may expand letters for more difficulty
if all [c > 1 c < 5] [
append choices/xn/colors form colors-map/(rc/:c)
]
repend blk [<font> huge rc/:c to-string tx/:c </font>]
]
repend blk [</b>]
;use color word vrs inscrutable tuple means extra overhead
blk ;repend reduces
]
gen-xn: func [
/local s xn
][
; need to pick random 3 not sure need to be unique or avoid XN center
; real research may well want specific letter position & color
; in this case, the color choice to be decided later
; need to restrict to one X or N in random position
; leading zero ok? maybe not for civilians
xn: rejoin [
copy/part random "ZYWVUTSRQPOMLKJIHGFEDCBA" 2
random/only "XN"
]
s: rejoin [
random/only "123456789"
random xn
random/only "0123456789"
]
;assert [5 = length? s]
choices/xn/text: copy s
]
if no [ ;have a look at some output
blk: copy []
;loop print color_n color name nl so can paste from inclib
; n: 1
; foreach [c name ] colors [
; print [mold to-set-word rejoin ['color_ n] c ";" mold name]
; append/only blk reduce [to-set-word rejoin ['color_ n] space name]
; n: n + 1
; ]
; t: index? find extract colors 2 255.0.0.0
; tl: index? find extract colors 2 0.0.0.0
t: index? find colors 255.0.0.0 ;finds even with alpha?
tl: index? find colors 0.0.0.0
print [
mold colors
newline
; 'red= t form colors/(((t - 1) * 2) + 2) ; + 1
; 'black= tl form colors/(((tl - 1) * 2) + 2)
'red= t form colors/(t + 1)
'black= tl form colors/(tl + 1)
'redm= form colors-map/(255.0.0) form colors-map/("red")
'blackm= form colors-map/(0.0.0) form colors-map/("black")
;'m= "0.0.0.0" form colors-map/(0.0.0.0) ;none
mold/all explode! "0ABC2"
newline
mold/all blk
newline
blk
;mold to-set-word to-lit-word bg-color mold bg-color
"bg-color:" mold bg-color
"fg-color:" mold fg-color
gen-xn
gen-xn
gen-xn
newline
gen-xn ;sets choices
mold/all draw-xn ;need a reset choices after used
choices/xn/colors: copy []
newline
gen-xn
mold/all draw-xn
mold/all choices
]
halt
]
#define__gview__
gview: [ ;[compose/deep make better guess 600x or 30% screen
title " cog tests "
size 510x500
backdrop fg-color ;behind panel
style canvas: base 350x60 bg-color ; welcome correct wrong goodbye
; has border?
style b?: button 28 bold font big-font "?" ; pair not needed for size
style rtext: rich-text 350x160 bg-color
style tn: text font sm-font
style bn: button 23 bold font med-font
[
fd-xn/text: take/part/last rejoin [fd-xn/text face/text] 2 2
;if 2 = length? face/text [clicked/d face/text] ;limit to last 2
clicked/d fd-xn/text ;let clicked set whatever clicked
]
on-over [
either event/away? [
face/size: face/size - 2x2
][
face/size: face/size + 2x2
]
]
;style fn: field font med-font 80 ;no need to be editable
style fn: text font med-font bg-color 80
style cn: base 35x35 fg-color ; can declare other colors
[
;fc/text: form face/color ;find in named choices
;make combined find-extract to return 2nd or turn into map
;t: index? find extract colors 2 face/color
;fc-xn/text: form colors/(((t - 1) * 2) + 2)
fc-xn/text: form colors-map/(face/color)
clicked/c fc-xn/text
]
on-over [
either event/away? [
face/size: face/size - 2x2
][
face/size: face/size + 2x2
]
]
pad -2x-2
tpanel: tab-panel [
"XN-test" [
backdrop bg-color
;need rich-text can show for set milliseconds
;then ask for digits, show keypad or script it for testing
;then show bars of colors can click to select and start next test
;show correct or wrong each test
; or allow changing choices till timeout then score response can work
;generate string dllld where one l either X or N of a color
; generate color list for digits and need to be able to colorize
;across ;default
;origin 100x10 ;has some side-effects
pad 110x5
;make rich-text current timing range and scores, optional
;need to use pen or gets color from font color
rt-xn: rtext bg-color
on-time [
;continuous print can make it impossible to exit.
rt-xn/rate: none
;need hint button for 2nd look on easy difficulty
;animate fade might be nicer
rt: copy [{^/^/^/^-^- }] ;need clear data?
rt: rtd-layout rt
rt-xn/data: rt/data
rt-xn/text: rt/text
]
return
pad 90x-10
c-xn: canvas
on-time [
c-xn/draw: [pen bg-color box 0x0 355x55] ;cls
face/rate: none
]
pad -80x0
return
fc-xn: fn 81 "" ;keep last 2
pad 0x-4
;make c1..c8 click which color in style
c1: cn color_1
c2: cn color_2
c3: cn color_3
c4: cn color_4
c5: cn color_5
c6: cn color_6
c7: cn color_7
c8: cn color_8
return
across
pad 10x0
tn 200 "click digits in order "
;~4seconds trigger next
;rate ignored? float errors, 4 slower than 400?
; rate 0 errors?
cd-xn: tn 80x40 "0:00:00"
on-time [
;2019/9 won't error but doesn't count?
face/text: form choices/xn/time-word
case [
choices/xn/time-word > 0:0:0 [
choices/xn/time-word: choices/xn/time-word - 0:00:01
;break ;?
;'done? ;? 'stop?
]
'else [
; score catches time-word <= 0 will win/loss
;but score only called on clicks
;face/rate: none ;may as well stop timer?
score
]
]
]
return
fd-xn: fn 81 ""
pad 0x-4
;make b0..b9 digits to click what's shown.
b0: bn "0"
b1: bn "1"
b2: bn "2"
b3: bn "3"
b4: bn "4"
b5: bn "5"
b6: bn "6"
b7: bn "7"
b8: bn "8"
b9: bn "9"
return
return
; pad -100x0
play-xn: bn 75 "pause" [ ;pause/play might be confusing
either face/text = "play" [ ; stop timer when clicked
face/text: "play"
rt-xn/rate: choices/xn/see-timer
; choices/xn/pick-timer ; trigger out of time changes
;start/restart countdown, not actually play/pause
cd-xn/rate: 0:0:01 ;is always one,
][
;actually would push time left & restore it but cheating
face/text: "play"
rt-xn/rate: none ; 0.0 doesn't stop on-time?
cd-xn/rate: none ;silent exit maker?
]
]
pad 20x0
;make slider for timer & difficulty later
tn 58 "slower" pad -15x0
sld-xn: slider 175x35 50% pad -5x0
tn 58 "quicker"
pad 20x0
; right ;pulls prev text right too?
b? [show-help "xn"]
; return
; graph-xn: base 400x75
; on-time [
; choices/xn/hist...
; ]
; bn 85 "show debug" [] ;make window taller
] "Stroop" [
;c: canvas
return
text center "Stroop effect COLOR WORD test not yet implemented"
return
b? [show-help "stroop"]
] "" [ ; mystery 3rd game
b? "?" center [show-help ""]
]] ;e panel
; across
;below
return
;make debug feedback area
xarea: area font-color fg-color 300x70 []
;need status bar? count down progress bar
do [
;generate a sample string, choose colors & display
;somewhat duplicates a begin button,
; maybe ask to choose color and digits to start timer
;tried various things, just getting garbage out
;do can't set rt-xn/data yet?
;rt-xn/data: draw-xn
;rt-xn/face: rtd-layout draw-xn
;rt-xn/draw draw-xn
fs: med-font/size
rt: copy []
repend rt [ ;still need start/stop button? pause/play
; doesn't like 'med-font or make font!
<font> fs { To start a game, pick the color only of X or N^/}
{ And the 2 outer numeric digits.^/}
{You'll have a few seconds to choose for each round^/}
{The slider will eventually control how much time^/} </font>
<font> (fs + 2) { Good Luck!^/}
{ } </font>
]
;this works as expected, not sure why rtd-layout not needed in repl
gen-xn
repend rt draw-xn
rt: rtd-layout rt
rt-xn/data: rt/data
rt-xn/text: rt/text
feedback/welcome
if no [
rt: copy []
repeat n 8 [
repend rt [<b><font> (fs * 2)
;colors/((n * 2) - 1)
colors-map/(colors-map/:n) ;the color name is index to color
"X " </font></b>]
]
rt: rtd-layout rt
rt-xn/data: rt/data
rt-xn/text: rt/text
]
;prime seems to be needed to use xarea in score? weird
xarea/text: "debug messages"
;if dev+ [print [mold choices] ]
play-xn/enabled?: false
sld-xn/enabled?: false ;FIXME difficulty timer
]
]
;; tb: rich-text data [i b "Hello" /b font 24 red " Red " /font blue "World!" /i]
;; on-create [
;; tb/face: rtd-layout [<i> <b> "Hello" </b> <font> 24 red " Red " </font> blue "World!" </i>]
;; ]
; view [rich-text 200x50 "Little example of rich-text" with [
; data: [1x6 italic 8x10 bold 16x2 168.168.168 19x9 255.0.0 18]]
; ]
;this works as expected
; view [rt: rich-text 200x50
; data [<b> <font> 20 0.0.255.0 "J" </font> <font> 20 178.34.34 "5" </font> </b>]
; ]
;from docs, works
; rt: rtd-layout [<i> <b> "Hello" </b> <font> 24 red " Red " </font> blue "World!" </i>]
; view [rich-text with [text: rt/text data: rt/data]]
; sets
; lsf-text/draw: compose [text 10x10 (rtd)
; line-width 3 pen gold ;from rt doc, underline or box middle set eventually
; line ; Let's draw line under words using a pair of above helper functions
; (as-pair 25 h: 15 + rich-text/line-height? rtd 1) ; Starting-point y -> 10 + line-height
; (as-pair 25 + pick size-text rtd 1 h) ; End-point x -> 10 + length-of-text-size
; ]
; ;lack of scrollbars currently
; lsf-text: rich-text left font cfg/bfont color-bg 500x140 draw [] ;data [] last set found
; ;with [ flags: [scrollable all-over] 'resize ] ;force scrollbars
; on-created [face/data: copy []]
#define_endview__ ;for geany bookmark sidebar c-lexer
insert-event-func [ ;2022 recent doesn't like resize panel this way?
if all [event/window = gview event/type = 'resize] [
if dev+ [
print [ ;should be an easier way to dump face stats
"offset size window" event/window/offset event/window/size
"tpanel offset size" tpanel/offset tpanel/size
"xarea" xarea/offset xarea/size
newline
about
]]
;triggers react in sub widgets, otherwise nothing happens
; on-resizing vrs react?
;should also allow a bigger/smaller window button or resize
;want deb+ to control if xarea is even seen
;recent ignores this section?
; tpanel/size/x: event/window/size/x - 20
; tpanel/size/y: event/window/size/y - 110 ; - tpanel/offset/y
;tpanel/size/y: 610 ;nothing is working in recent
; xarea/size/x: tpanel/size/x - 12 - (/offset/x / 2)
; xarea/size/y: tpanel/size/y - 42 - /offset/y
;xarea/offset/y: (tpanel/offset/y + tpanel/size/y) + 10 ;follow tpanel
;need to increase y if tpanel/y >500 maybe never go below 80
;more smarts than I want to add right now
; xarea/size/x: to-integer (tpanel/size/x * 75%) + 12
; xarea/size/y: to-integer (tpanel/size/y * 20%) + 22
'done
]
;catch exit if saving position
]
; Red 0.6.4 for Windows built 16-Sep-2019/16:32:03-04:00 commit #d704d4f
; offset size window 108x46 700x600 tpanel offset size 10x10 742x596 xarea 10x616 308x67
; Red 0.6.4 for Windows built 21-Jul-2021/13:41:07
; offset size window 100x15 700x600 tpanel offset size 10x10 742x596 xarea 10x616 308x67
; Red 0.6.4 for Windows built 15-Apr-2022/20:44:27
; offset size window 100x15 700x600 tpanel offset size 10x10 742x596 xarea 10x616 308x67
; probe gview
; repend quit button at bottom based on interpreted/compiled
; old console doesn't like quit?
;no-wait in recent doesn't work like it used to
either any [not dev+ not system/state/interpreted?] [
repend gview [
'pad 20x0
'button 70 'font med-font "Exit" [unview] ;could be just quit compiled?
]
view/flags/options layout gview ['resize][offset: 110x15]
][ ;-e too,
repend gview [
'pad 10x0
; button 80 font med-font "Debug halt" [halt] ;same as quit compiled
'button 80 'font med-font "Exit View" [unview] ;could be just quit compiled?
;old console ignores?
'button 70 'font med-font "Quit All" [quit] ;same as unview & halt compiled
]
view/no-wait/flags/options layout gview ['resize][offset: 110x15]
]
;if need to use compiled -e or maybe console
;; view/flags/options gview ['resize][offset: 80x15]
if dev+ [print ["nowait broke? recent needs halt or it exits interpreted"]
]
;need do events now? but is still not giving repl control
;do-events ;wrong, on-over stops working
;halt
comment {
todo
copyright on XN? maybe should use ZW or WM
make it more like a game somehow
popup attention test at random time and give feedback in text or smily faces
make slider for text size
make color sets/ui colors selectable theme. color blind friendly, light, dark
solorized might be difficult not sure there are 8 distinct colors
but could do muted/pastel theme w/solorized UI
more colors for stroop might be difficult, also harder if keyboarding
recent resizing doesn't work & 2019 resizing works? wtf
should digits always be fg-color?
make stroop also work DFJK keys, with extra 2 colors/keys at 3/4 difficulty
Remember the exact 3D orientation of an object or a color
from a brief view. multiple choice or pick from hue wheel or rotate object
immersive effect, full screen no title bars
sounds
wordle or boogle like game, but simplified for cog
could have a list of words to choose from click & point
done/in process
other comments elided
fixed missing digit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment