diff --git a/README.md b/README.md index 8ddc178..a06a01f 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ copyright bash-n - bash library for connect-n game clients -Copyright (C) 2019, 2020 Christian Garbs +Copyright (C) 2019, 2020, 2023 Christian Garbs Licensed under GNU GPL v3 or later. bash-n is free software: you can redistribute it and/or modify diff --git a/bash-n-simplebot b/bash-n-simplebot index 119cf21..835b181 100755 --- a/bash-n-simplebot +++ b/bash-n-simplebot @@ -10,7 +10,7 @@ # To connect to a SERVER on PORT via UDP, run this script like this: # $ socat udp:SERVER:PORT exec:bash-n-simplebot # -# Copyright (C) 2019 Christian Garbs +# Copyright (C) 2019, 2023 Christian Garbs # Licensed under GNU GPL v3 or later. # # This file is part of bash-n. @@ -35,8 +35,8 @@ calculate_move() { local column while true; do - column=$(( $RANDOM % 7 )) # this will be biased! - if [ ${field[$column]} -lt 6 ]; then + column=$(( RANDOM % 7 )) # this will be biased! + if [ "${field[column]}" -lt 6 ]; then return $column fi done @@ -44,8 +44,8 @@ calculate_move() record_move() { - local who=$1 column=$2 - field[$column]=$((${field[$column]} + 1)) + local column=$2 # who=$1 (unused) + field[column]=$((${field[$column]} + 1)) echo "${field[*]}" } @@ -53,7 +53,7 @@ game_start() { local column for column in 0 1 2 3 4 5 6; do - field[$column]=0 + field[column]=0 done } diff --git a/bash-n-towerbot b/bash-n-towerbot index f61391e..ff530b6 100755 --- a/bash-n-towerbot +++ b/bash-n-towerbot @@ -12,7 +12,7 @@ # To connect to a SERVER on PORT via UDP, run this script like this: # $ socat udp:SERVER:PORT exec:bash-n-simplebot # -# Copyright (C) 2019 Christian Garbs +# Copyright (C) 2019, 2023 Christian Garbs # Licensed under GNU GPL v3 or later. # # This file is part of bash-n. @@ -35,11 +35,11 @@ source bash-n-client calculate_move() { if column_is_available; then - return $column + return "$column" fi while true; do - column=$(( $RANDOM % 7 )) # this will be biased! + column=$(( RANDOM % 7 )) # this will be biased! if column_is_available; then return $column fi @@ -48,20 +48,20 @@ calculate_move() column_is_available() { - [ ${field[$column]} -lt 6 ] + [ "${field[column]}" -lt 6 ] } record_move() { - local who=$1 column=$2 - field[$column]=$((${field[$column]} + 1)) + local column=$2 # who=$1 (unused) + field[column]=$((${field[$column]} + 1)) echo "${field[*]}" } game_start() { for column in 0 1 2 3 4 5 6; do - field[$column]=0 + field[column]=0 done column=3 }