Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38705

Re: Allowed moves database chessboard, knight to many entries....

Newsgroups comp.lang.javascript
Subject Re: Allowed moves database chessboard, knight to many entries....
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References (3 earlier) <XnsAC11C18F2E942eejj99@194.109.6.166> <0965b2e8-47ec-42b7-a294-a874d5f176abo@googlegroups.com> <42350bec-28d0-4b85-89db-1aed763e1026o@googlegroups.com> <XnsAC1396146B2C1eejj99@194.109.6.166> <b5f52c14-ed6e-4b0a-852d-dca3393d5889o@googlegroups.com>
Date 2020-08-10 12:48 +0200
Message-ID <XnsAC1582524E3CAeejj99@194.109.6.166> (permalink)

Show all headers | View raw


=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 10 Aug 
2020 in comp.lang.javascript:

> Try it out, if not for my programming skills for my artistic rendition ;)
> https://jonasth.github.io/chess/chess.html

Artistic okay!

Programmatic, 
you are doing multiple testing, 3 times here, where there is no need, 
example:

function random(){
	holder = Math.random() < 0.5;
	if (holder==true){uplayer="white";} 
    else if (holder==false){uplayer="black";}
}

Why not:

function random(){
	holder = Math.random() < 0.5;
	if (holder)
       uplayer = 'white'
    else 
       uplayer = 'black';
};

Or even more consize:

function random(){
	uplayer = (Math.random() < 0.5)
    ? 'white'
    : 'black';
};

or:

function getRandom(){
	return (Math.random() < 0.5)
    ? 'white'
    : 'black';
};

getRandom() = getRandom();

========

However, I would prefer to use a binary global value:

let uplayerIsWhite = true; // default
...
uplayerIsWhite = Math.random() < 0.5;



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-07-28 14:31 -0700
  Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-07-28 14:53 -0700
  Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-07-29 00:55 +0200
    Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-06 09:31 -0700
      Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-06 19:01 +0200
        Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-08 04:43 -0700
          Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-08 04:53 -0700
            Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-08 14:45 +0200
              Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-10 02:11 -0700
                Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-10 12:48 +0200
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-11 11:24 -0700
                Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-11 23:33 +0200
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-11 14:40 -0700
                Re: Allowed moves database chessboard, knight to many entries.... luserdroog <luser.droog@gmail.com> - 2020-08-11 15:57 -0700
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 00:40 -0700
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 00:42 -0700
                Re: Allowed moves database chessboard, knight to many entries.... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-08-12 12:12 +0100
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 05:13 -0700
                Re: Allowed moves database chessboard, knight to many entries.... luserdroog <luser.droog@gmail.com> - 2020-08-12 10:23 -0700
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 00:50 -0700
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 01:00 -0700
                Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-12 11:58 +0200
                Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-12 05:14 -0700
          Re: Allowed moves database chessboard, knight to many entries.... "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-08 14:44 +0200
          Re: Allowed moves database chessboard, knight to many entries.... Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-08-22 08:10 -0700
          Re: Allowed moves database chessboard, knight to many entries.... Scott Sauyet <scott@sauyet.com> - 2020-08-25 16:03 -0700
  Re: Allowed moves database chessboard, knight to many entries.... Scott Sauyet <scott@sauyet.com> - 2020-08-25 15:06 -0700

csiph-web