sevivon

[DORMANT] multiplayer dreidel game for mobile devices w/ godot
git clone git://git.figbert.com/sevivon.git
Log | Files | Refs | README | LICENSE

log.md (10428B)


      1 # Ruleset
      2 ## Game Setup
      3 - Each player receives a set amount of gelt
      4   - Initially this is set to 10, but in the final game players will choose
      5   between a number of options.
      6 - The pot starts with 5 gelt
      7 ## Each Spin
      8 - The spin order is the order clients joined the lobby
      9 - Each player takes/gives gelt to the pot based on spin
     10   - Gimel - take all
     11   - Hey - take half (rounded up)
     12   - Nun - take nothing
     13   - Shin - put one in
     14 - Everybody antes up (puts a piece of gelt into the pot)
     15   - If a player cannot put in a piece, they are out
     16 ## Win Condition
     17 - A winner is determined once everybody else is out
     18 
     19 # Multiplayer Documentation
     20 ## Networking
     21 1. [High-Level Multiplayer](https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html)
     22 2. [Making HTTP Requests](https://docs.godotengine.org/en/stable/tutorials/networking/http_request_class.html)
     23 3. [SSL Certificates](https://docs.godotengine.org/en/stable/tutorials/networking/ssl_certificates.html)
     24 4. [Coroutines with yield](https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#coroutines-with-yield)
     25 ## Server Exports
     26 1. [Exporting for Dedicated Servers](https://docs.godotengine.org/en/stable/getting_started/workflow/export/exporting_for_dedicated_servers.html)
     27 2. [Compiling a Server Build for macOS](https://docs.godotengine.org/en/stable/development/compiling/compiling_for_osx.html#compiling-a-headless-server-build)
     28 3. [Compiling a Server build for Linux](https://docs.godotengine.org/en/stable/development/compiling/compiling_for_x11.html#compiling-a-headless-server-build)
     29 ## GDScript
     30 1.  [GDScript Style Guide](https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_styleguide.html)
     31 
     32 # Daily Journaling
     33 ## 2021-01-30 Sat
     34 
     35 Today I took the time to read through the Godot multiplayer
     36 documentation and implement the basic lobby structure. Each client
     37 initializes itself, checking whether or not it's a server or client,
     38 and connect to a hard-coded IP address `SERVER_IP` currently pointing to
     39 my laptop on the local network. It probably isn't considered a security
     40 issue to have that in a public repo, but I'm not sure.
     41 
     42 The code is a little rough right now, but it's supposed to be. The
     43 current version is just there to do the basics (literally text-based)
     44 and then I can spend as much time as I want refining and adding graphics
     45 and such.
     46 
     47 At the end of the day today, the game can:
     48 
     49 - Run as a headless server
     50 - Connect to the server, and alert the user of a successfull or failed
     51 connection
     52 - Alert the user when another client joins or leaves the lobby, and output
     53 their `id`.
     54 
     55 Tommorrow I am going to work on:
     56 
     57 - Defining a dreidel rule set
     58 - Outlining how the data is passed around over the network
     59   - How is the game data structured?
     60   - Does the client take actions and the server validate them, or does the
     61   server request actions from the client?
     62 - Starting the game when the lobby is full
     63 
     64 ## 2021-01-31 Sun
     65 
     66 I spent the first part of today's work writing a ruleset for dreidel,
     67 outlined above. It's based on the rules found on Wikipedia, Chabad.org,
     68 and my personal experience. It also should be fairly easy to implement!
     69 
     70 I also butted heads with the multiplayer code a bit - it's hard to make
     71 a game - but I've got a bit of a general strategy defined now. The
     72 client should do as little thinking of its own as possible: it's
     73 primary function should be to respond to calls from the server.
     74 Additionally, the code for client and server should be kept as separate
     75 as possible. I considered having functions for each section always begin
     76 with a prefix of some sort (i.e. `client_*` or `server_*`). I have
     77 passed on this for now, but may change that decision later if I can make
     78 certain that all names retain their clarity.
     79 
     80 Tomorrow, I have to start implementing the actual game - working on the
     81 lobby code is not the goal of this project! Mastering `rpc` calls will
     82 be difficult, but I am confident that I can get a strong start on the
     83 gameplay if I focus.
     84 
     85 ## 2021-02-01 Mon
     86 
     87 This project is moving at the speed of light. Today, I basically
     88 finished the backend code. Players now take turns spinning the dreidel,
     89 gaining and losing gelt, and everything works flawlessly. It's really
     90 exciting.
     91 
     92 The main change I implemented today was inserting a step between roll
     93 decection (`client_spun`) and moving on to the next player
     94 (`_iterate_turn`) which chooses a random side of the dreidel and
     95 performs actions on the pot and players' gelt (`_spin_dreidel`).
     96 
     97 One of the more interesting problems I encountered in making this
     98 functions was how to implement the randomness. At first, I defined it as
     99 such:
    100 
    101 ``` gdscript
    102 round(rand_range(0, 3))
    103 ```
    104 
    105 This block generates a random float (decimal) between 0 and 3 and rounds
    106 it to the nearest integer, which I use to select a dreidel face from an
    107 array. Do you see the problem? The problem lies in the function I used -
    108 `round`. The numbers at the end of the range have only have the change
    109 of getting selected as those in the middle! With that implementation, 0
    110 would only be selected if the number generated was between 0 and 0.5.
    111 The same applies for 3: it would only be selected if the number
    112 generated was between 2.5 and 3. These both are less than the chance of
    113 getting a 1 or a 2, which have a range of 1 each - double the range of 0
    114 and 3!
    115 
    116 So how did I fix it? Like this:
    117 
    118 ``` gdscript
    119 floor(rand_range(0, 4))
    120 ```
    121 
    122 This new version ensure that each number has an equal change of being
    123 selected, instead of being biased toward the center.
    124 
    125 Tomorrow, I'm going to focus on polishing the text output. The
    126 operations on the pot need to be more clear, and I am considering
    127 splitting the processes of spinning and anteing up. Most importantly,
    128 however, I must add a win condition!
    129 
    130 ## 2021-02-02 Tue
    131 
    132 Well, three cheers for unexpected challenges. Adding a win/lose system
    133 was incredibly difficult. I expected it to be a breeze. I actually had
    134 to implement it twice, because my first attempt was unsalvagable. The
    135 second time around, I walked through the whole codebase piece by piece
    136 with my dad, and we worked it out together. The most interesting thing
    137 he suggested was a cool trick in boolean math: to figure out if there is
    138 only one true value in an array of booleans, convert them all to binary,
    139 and if the sum is 1 then there's only one `true`. Pretty useful.
    140 
    141 With that final system implemented, it's time to polish off the textual
    142 interface before moving on to add some real graphics. By Friday, I need
    143 to:
    144 
    145 - Increase the font size
    146 - Get running on Android
    147 - Split and request the ante
    148   - It's currently lumped in with the rest of the spin, which makes the math a
    149   little confusing.
    150 - Add usernames
    151   - Judah
    152   - Yochanan
    153   - Shimon
    154   - Elazar
    155   - Yonatan
    156 - Add auditory or haptic feedback to dreidel spins
    157 - Increase lobby max size and add start/restart mechanisms
    158 
    159 ## 2021-02-06 Sat
    160 
    161 When I said Friday I meant the 12th... I promise. I've been hard at
    162 work implementing the features I discussed above. I knocked out the font
    163 size patch on the first day - that one was a freebie - and then spent
    164 the rest of the day and half of the next trying to get the game running
    165 on a Pixel 4a. Now it does! Turns out, the only real problem I
    166 encountered was myself. I had enabled Kill Switch with my VPN app, and
    167 thus when I disabled it to access the local network it prevented me from
    168 connecting to my laptop - tad of a facepalm there.
    169 
    170 The next while I spent implementing, failing, and reimplementing the
    171 ante and usernames. I've noticed that when designing new features, I
    172 tend to get 85% of the way there and then decide that I want to start
    173 over and do it another way. Both the ante and username systems are
    174 currently almost complete, but not quite there yet. With antes, I
    175 initially struggled to figure out how to implement some sort of waiting
    176 system - how to get the spin function to pause until everybody has
    177 confirmed the ante. The current design ignores that, but will allow me
    178 to extend the current implementation to add a delay with `yield` and
    179 coroutines - I just need to learn how to use them. A similar caveat
    180 exists with the username system: all five have been added, but because
    181 the lobby size is currently limited to two players (which itself is
    182 because I haven't implemented a start mechanism), only Judah and
    183 Yochanan are ever used.
    184 
    185 Regardless, some incredible strides have been made in the last couple
    186 days. I'll continue working on rounding out the feature set, and then
    187 polishing the textual interface before I get to actual graphics. A
    188 non-exhaustive list of some things I have to get done:
    189 
    190 - Add confirmation to the ante process with `yield`
    191 - Increase the lobby max size to five and make starting manual
    192 - Add auditory or haptic feedback to dreidel spins
    193 - Polish textual interface
    194   - Make sure it looks nice on both iOS and Android
    195   - Add little delays between messages (also with `yield`)
    196   - Make sure all the message are charismatic and expressive
    197     - Less like logs for a programmer and more like fun messages for a player
    198 
    199 ## 2021-02-11 Thu
    200 
    201 Over the past couple days, I achieved *most* of the above goals! Not bad.
    202 Yesterday, I increased the maximum lobby size to five (which is where it will
    203 stay) – now the first player to join must shake their phone once to start a
    204 match. In doing so, I encountered a weird issue with `yield` that caused the
    205 0.5 second delay I was implementing to not fire depending on where I placed
    206 it within a function. Odd, but I worked it out in the end.
    207 
    208 I've also added haptic/vibrational feedback to dreidel spins. However, I'm not
    209 sure this will make it into the final game. Once I start adding graphics, I
    210 plan on also adding in a dreidel spinning sound effect which may replace the
    211 current system or operate alongside it.
    212 
    213 For the final change I've made so far, I did some research into responsive
    214 design with the Godot 2D editor and have made the `Label` element much more
    215 adaptable to a variety of different screens.
    216 
    217 Current todos (not many left):
    218 
    219 - Go over ruleset one more time
    220   - Lately I've been thinking that games are going on for too long. Potential
    221   ways to fix this include changing up the gelt amounts, anteing after every
    222   turn, and rounding up instead of down when you roll hey.
    223 - Add confirmation to the ante process
    224 - Polish messsages
    225   - Add short delays between messages
    226   - Make sure all messages make sense
    227