Present HN: Fully Automatic Snakes and Ladders

56
Present HN: Fully Automatic Snakes and Ladders

snakes and ladders screen on phone


TL;DR

Factual play and gaze:
https://alex028502.github.io/snakes-and-ladders/

All of the source maps are on hand in the event it’s likely you’ll perchance must know the device in which it works.
It works offline even as you refresh a couple cases. Add it to you home mask mask
for a paunchy mask mask abilities.

Tech

This project is primarily about tooling. Properly, is is mainy about automation, and
saving time, however it is also about tooling, and studying somewhat of clojure.

Snakes and Ladders Engine

The engine is written in clojurescript. I tried to
sustain the total purposeful stuff in clojurescript, and the total messy stuff in js.

The engine could perchance well furthermore furthermore be developed in a clojure repl because it has nothing clojurescript
speak.

It was impressed by this episode:
https://clojuredesign.club/episode/002-tic-tac-toe-mumble-in-a-row/
or perchance the episode after.

Snakes and Ladders Engine Assessments

I on the total strive and take a look at all the pieces discontinue to discontinue when likely. Nonetheless, in this
project, it was vital to discontinue my highest to guarantee that the customers are
playing the sport they specialise in they are playing, so I tested the engine like
this. This take a look at could perchance well furthermore furthermore be dawdle in clojure or
clojurescript. In pattern, I found it a lot more straightforward to dawdle it with clojure,
however CI runs it each ways to portray that it’s like minded.

Javascript Glue

The total glueing together, mutating, producing random numbers.. messy stuff..
is carried out right here in javascript.

These capabilities convert arrays, objects, and
mills into clojurescript kinds so that the core program would not must
know anything else about where it’s running.

Board

The board is configured using a
DSL that I made up. The transpiler
is written in Flex and Bison, however then javascript is frail
to extract the source device facts.

I actually appealing wanted to imagine a ogle at out what I learn in this book:

Lex and Yacc O'Reilly Book

The chilly fragment is being in a situation to step thru your dangle language with browser
dev tools like this:
Chrome dev tools debugging my own language

Selenium Assessments

The Selenium Assessments are written in Java. I looked into
writing them in Clojure, however no one in my high few duckduckgo results seemed too
tantalizing about that.

I could perchance in total assume to jot down selenium checks in Python or customarily JS, and
any time I’ve frail Java ones earlier than, they were fragment of a extensive junit maven
project. I wanted to discontinue something extra light weight, so I appealing frail shadow
cljs to safe the selenium library, and compiled a java class with a straightforward
take a look at in static systems. The take a look at handiest is advantageous with this
wrapper script.

The selenium take a look at could perchance well furthermore furthermore make sure that quite a lot of stuff is curved up accurately, like
buttons, and local storage. It also tells me that the provider employee is caching.
For the reason that wrapper script begins the server, I appealing made it shut off after 10
seconds, when the checks remaining about 20 seconds, so if the provider employee caching
is never any longer working, the take a look at fails when it tries to reload the page.

The Selenium checks handiest work after the app is compiled.

Integration Assessments

For the reason that selenium checks can not actually portray us if the sport is being performed
fairly, and the snakes and ladders engine checks don’t take a look at the particular board,
there is an additional assign of abode of checks that assume the compiled engine,
the compiled board, and a rigged die, and make sure that that quite a lot of stuff works as
anticipated. This is able to perchance seem like overkill, however since the customers are blindly
trusting us to present them a appealing sport, we now must transfer that additional mile.

Bundling

I am using esbuild to bundle together the
javascript glue code, the random quantity generator, after which board. The board
desires to be transpiled first. I tried using webpack, however it perceived to have
distress combining the unfriendly source maps for the board. I would possibly not assign of abode
breakpoints. esbuild labored the first time.

The engine is never any longer bundled in with the rest, so that I’m able to imagine
good thing about extra shadow cljs parts. Also, if I am engaged on the ui, the
engine would not actually must alternate, and I’m able to recompile afterthing else in
below a second. The two have fully varied “liberate cycles”, so this works
huge.

Test Protection

Near to all my projects have 100% take a look at coverage. In this project, I didn’t know
the helpful device to measure take a look at coverage for clojure. Nonetheless, I accumulated made a degree of
covering every likely branch, and deleted the branches I would possibly not take a look at.

Join the pack! Join 8000+ others registered customers, and safe chat, safe groups, put up updates and safe chums across the realm!
www.knowasiak.com/register/

Charlie Layers
WRITTEN BY

Charlie Layers

Fill your life with experiences so you always have a great story to tell