More Tinkering with Concentration

I’ve been tinkering again with my Concentration game.

It started the day after Thanksgiving. I was stuck at the car dealership, waiting while they fixed my car, and decided to scratch a couple of long standing itches, and then, as I’ve been playing with it, I’ve been noticing things and fixing them.

There are now styles for larger screens. On my laptop, the default puzzle size was starting to feel small. When I created the Angular version, I added responsive styles directed at mobile devices; I’ve now added another size class for bigger devices — the puzzle is larger, while the prizes stay the same size.

I had a dickens of a time adding this, partly because there are a lot of off-by-one (or two) issues due to the gaps between trilons, and partly because I’d forgotten how the trick of laying out trilons worked. I got it working, and then a couple of days later, reworked it again, setting up a couple of Sass mixins to handle it.

Next, I improved the game end transitions. One sore point — it’s even been pointed out to my by an end user (Hi Glenn!) — was that when the board was resetting itself from the puzzle state to the number state, it passed through the prize state. This was a consequence of the way the trick worked.

The number face has a rotation of 0°, the prizes a rotation of -120°, and the prizes are -240°. The turning of the trilons is accomplished via a Cascading Style Sheet (CSS) transition — you specify the property that will be changing, and tell the browser how long you want the transition to last. The browser then animates the change, gradually changing the value of the property over the specified time from the starting value to the ending value.

This works fine when moving in normal game order; when a number is clicked, it animates changing the rotation from zero to -120°, making it look like the trilon is rotating clockwise. And in the case of a non-match, there is no intermediate state as it rotates counterclockwise back.

Unfortunately, at the end of the game, we would prefer to continue going clockwise from the prize state to the puzzle state, but the transition from -240° to 0° is a counterclockwise one, taking us through the prize state.

I tried fixing this before, by temporarily making the number state -360°, which is visually the same as 0°. Unfortunately, the transitions made the trilons spin like whirling dervishes.

This time, it occurred to me that what I needed to do, in addition, was turn off the transitions first, pause for part of a second, and then make the number state be -360°. I then pause for another fraction of a second, re-enable the transitions, and then set the trilon state to number. The transition from -240° to -360° is the desired clockwise motion. I then wait for the transition to complete, turn off transitions again, restore the number state to 0°, wait a fraction of a second and re-enable transitions. This gives a smooth reset to start the new game.

I’ve been tinkering with puzzles and prizes. I’ve added a couple more puzzles — there are now 12 — and added more prizes, both good prizes and bad prizes. I’ve been playing the game a lot myself lately, and the same prizes do repeat. There’s not much to be done about that except to add more.

I’ve been tinkering with the innards of the style system — repetitive code has been replaced by Sass mixins. I’ve also been playing with the speed of the rotation. Previously, the animation was linear, running at a constant speed. I’ve added “easing”, so that the rotation starts slow(ish), speeds up, then slows down again; this better reproduces how the physical trilons worked. This necessitated changes to the overall trilon speed — for a while, it was too fast, then it was too slow. Now it feels about right… just about the speed of the Jack Narz board.

Speaking of the Jack Narz board, I’ve more closely matched the colors. It’s hard to match the colors exactly, since I’ve been picking up the colors from YouTube videos that are full of compression artifacts, but it is closer, It will never be an exact match since the font is different, but it’s closer.

Finally, I noticed that there had been a regression between the jQuery and Angular versions of the board. I was idly playing with the old version, and noticed a pronounced perspective effect on the turning trilons that wasn’t present in the Angular version. It was supposed to be there; I’d copied the perspective and transform-style properties over. But it wasn’t.

It turned out that the problem was an artifact of how Angular renders components. Unlike React, which only renders the HTML elements within the React Component, an Angular component will render a custom HTML element representing itself. So, the rendered Angular source for a trilon looks something like this:

<ca-trilon _ngcontent-ndj-c21="" _nghost-ndj-c19="" class="ng-tns-c21-0 ng-star-inserted" style="">
   <div _ngcontent-ndj-c19="" class="trilon state-number row1 col2">
      <div _ngcontent-ndj-c19="" class="face num">
         <div _ngcontent-ndj-c19="" class="inner">
      <div _ngcontent-ndj-c19="" class="face prize"><!---->
       <!----><div _ngcontent-ndj-c19="" class="inner ng-star-inserted">
        Green House
       <div _ngcontent-ndj-c19="" class="face pzl" style="background-image: url(&quot;/assets/puzzles/pzzl-005-2x.gif&quot;); background-position: -302px -98.5px;">

What this means in terms of the style system was that there was an intervening element — the <ca-trilon> element — between the element that had the perspective on it, and the <div class="trilon> that had the preserve-3d style on it.

This required massive changes to fix. I had to apply styles to the <ca-trilon> element — height, width, and the preserve-3d property, as well as make it display: block. This threw the layout of the board totally out of whack. Previously, each trilon had been placed absolutely with a fixed top and left position; I removed this, and changed it to a simpler flex-box arrangement. I then had to fudge all the measurements until there was the proper amount of space around each trilon, and the puzzle as a whole… and then repeat that for the other two sizes. Happily, in the end, I think I’ve wound up with simpler code in the end.

Although I did successfully get perspective working, I found that the effect as implemented in the jQuery version was too strong. It was especially noticeable at number 30 — the corners of the rotating trilon appeared to be moving through its neighbors. You control the perspective effect by specifying a number — think of it as specifying how far away the vanishing point of a perspective drawing is. The smaller the number, the stronger the effect. The jQuery original used 700px; I’m using 2800px for this. Number 30 doesn’t seem to clip, but there is still a bit of a perspective effect as the trilon rotates, making it look more like the back edge is receding.

Finally, a couple of housekeeping items. I used ng new to create the original shell of the Angular application, giving me an Angular favicon. I’d also set the document title to “Concentration/Angular” as my original intention was to also create a React version. I’m not so sure anymore that I want to do that. So it’s now just “Concentration”, with the classic “Mystery Logo” as the favicon.

Flooding on the Charles

We’ve had a ton of stormy weather over the past few weeks, and a lot of water has fallen, so it was not a surprise to see a river flood warning on my phone the other day. When I took a closer look at it, though, even though it was tagged for this town, it was in reality for Norfolk county, specifically the Dover-Medifield area.

I’ve become familiar with that area, first from rides on the motorcycle, and also from a number of kayak trips. My first drone flights were from the grounds of the old Medfield State Hospital. So I decided to head down and take a look. The alert mentioned some road flooding, but I figured I could always stop short and turn around.

My first destination was the Charles River Gateway at the old State Hospital. It overlooks a bend in the river where the state has restored wetlands. The wetlands were completely flooded.

Here is a view from the same spot in November of 2015:

Wetlands like these are an important part of flood control, as they allow the water to spread out horizontally, and be discharged gradually.

From there, I took a short walk along the footpath, then returned to the car and drove over to Route 27, about from the far end of the river in the picture above. By that point, the clouds had started to return; some parts of the sky were clouded over, while other parts were open, spotlighting the trees below.

I ended the day with a cup of tea at a nearby Dunkin Donuts. As I came out, it started to pour briefly, and then I noticed a fantastic rainbow.

Hindsight, Regrets, Recriminations and Wistful Wishes

It was a long four years between my mother’s first set of strokes, and her death. While I do feel that overall, we did our best to take care of her, I would not be human if there weren’t things that I regret, or would do differently if I could.

She spent the first couple of years back here at home. She returned after four months of rehab in January of 2020, right before the pandemic started. Overall, she did well for the first year, though it was unfortunate that she lost some outpatient rehab time due to COVID shutting down the rehab hospital.

Things went downhill after her May 2021 stroke. It impacted her majorly, and after it, she could not be left unattended. We tried keeping her home for several months, in the hope that she would recover some, but it never happened, and we had to put her into assisted living in February of 2022 at Cornerstone in Canton.

Overall, I feel comfortable with the quality of care she got there. They realized fairly quickly that she wasn’t doing well in the main population, and moved her into the Compass memory unit. She never did fully cotton to being in assisted living, but she did enjoy the activities and the music there. The individual aides were kind of up and down — some not so wonderful, some were very attentive and helpful, but I always felt that the people in charge were paying attention.

My first regret is kind of on Mum herself. I would have liked to have had her back home for Christmas of 2022, but we had taken her to the Cape that summer. She’d greatly enjoyed herself, but was super upset when we brought her back to Cornerstone, which made it obvious that we could not bring her home for visits.

She was becoming increasingly disabled at the start of 2023, having increasing difficulty swallowing, with a couple of choking episodes. At the beginning of the year, we met with the folks at Cornerstone, who told us Mum was becoming unsuitable for Cornerstone. Unfortunately, the way elder care facilities are regulated, at least in Massachusetts, assisted living facilities are organized around a “social” model. They can provide help with the activities of daily living, but they are not set up to provide medical care. They were concerned about the choking, and Mum was also requiring more care than they could provide.

They had two recommendations. The first was to move her to a nursing home, which is set up around a medical model. There would be more assistance, and the medical staff there would be better equipped to deal with issues like her increasing inability to swallow.

The second recommendation was to hire a private duty aide, dedicated to her care, who would supplement the care the Cornerstone staff would give her. They suggested we could do this either on an ongoing basis, or temporarily, until we could find a nursing home with an open slot.

A big consideration was frankly cost. On the private duty aide side, they were recommending a twelve hour shift for the private duty aide, and the cost was around $32 an hour, with a shift differential on the weekend. On the nursing home side, there were two considerations — first, that it was more expensive than Cornerstone, though less expensive than Cornerstone plus an aide, and second, there would be less choice once Mum’s money ran out. The folks at Cornerstone suggested we might have a better choice of facilities if we got her in before she was reliant on Medicaid.

So we decided to go the private duty aide route temporarily, until we could settle on a facility. Given what we knew then, it was the best decision, but it is the one thing I would like a do-over on, for a couple of reasons.

First, the private duty aides were good, and Mum did well with them. We went through an agency, Celtic Homecare by Catherine, and the aides they sent were good. They were there from 8 to 8, and took care of getting Mum to the bathroom whenever she needed, keeping her entertained, and helping her eat. We did have a little trouble with the Cornerstone staff — some of them thought they were completely off the hook for helping with Mum, whereas the reason we hired the aides was that she was becoming a two-person assist case.

Secondly, as it turned out, Mum’s finances were in better shape than we appreciated, and we could have afforded the private duty aides, at least for a while. Whether Mum would have lived longer enough that finances would have become a problem is impossible to say. But I think she would have done better and been happier.

Thirdly, the nursing home we ended up with was not particularly wonderful.

Cornerstone gave us a list of facilities to look at, and one of them was The Ellis Rehabilitation and Nursing Center in Norwood. They had an immediate opening available, Mum’s primary care physician had also said good things about them previously, and several other people had had good experiences. My brother and sister checked them out separately, and I went over as well. Overall, we felt thankful that we were able to get her in there so quickly.

That feeling dissipated as soon as we got her in there. I’d had reservations beforehand, as I’d seen a woman calling and calling for help while I did my tour. I allowed myself to think that that kind of thing was normal in a nursing home.

When we first got her there, a nurse came by to check her over for wounds, but then we were on our own. They kept her isolated for a couple of days (COVID precautions) just stuck in her room with nothing to do, and nothing to interact with.

While there were some good staff there — the speech therapist who worked with her on eating was helpful, and Marie and Fiona were great, but overall, the feeling one got was that institutionally, they just didn’t give much of a damn for the residents. They tended to keep all 20 or so of the unit’s residents jammed together in one not-so-large room, with nothing to do but watch TV. When I spoke to the staff, they would yes me to death, but I never had the sense that my requests, observations or questions were followed up on. It never felt like the aides were checking up on residents in their rooms.

I remember visiting one afternoon, and Mum asked if we could get her to the bathroom. I’d been able to do this by myself at Cornerstone, as there was a grab bar in her bathroom on her strong side, but it was on the wrong side at Ellis, so I needed the help of an aide. I could handle getting her out of the wheelchair and on to the toilet, but I needed another set of hands to get her pants down. The aide on duty had a nasty attitude and informed me that they had taken her to the bathroom once already, and that she was incontinent anyway. Nevermind the fact that my mother wanted to go on the toilet, and just needed help.

The capper for us came in November. Brian and Pam had gone over there, and ended up spending the day there, as we were considering hospice, and they wanted to see the hospice nurse. They were there for hours, not one aide came by, despite the fact that she had a severe bedsore, to turn or move her.

If anyone is reading this, and wondering if they should send their loved one to The Ellis, don’t.

My final wistful wish is the manner of her death. The nurse on duty checked her around 9:30 on Monday, and noticed her condition had changed since the weekend. He did call my sister, but didn’t realize how bad the situation was, and told her there was no reason to come right away. He was wrong, and Mum died alone.

That bothers me. It bothers me that she died alone with no one to comfort her. On the other hand, if I’m being honest with myself, could I have held myself together if I had been there? I don’t know.

I was talking about it yesterday with my sister-in-law, and she pointed out that Mum may have wanted it that way. Up to the end, she was protective of us — she acknowledged to others that she was dying, but refused to talk about it with us. She did hang on long enough for all of us to come and say goodbye. Even until the end, there was some part of her that was Mum.