• BeigeAgenda@lemmy.ca
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    Reminds me of my lottery number randomizer in VB 3.0 I calculated 10 rows and checked each input box against the others without any loops, and then each row was just copy pasted. 🤦

  • SuperDuper@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    YandereDev coding chess.

    Also who has a variable to store an input and decides to name it “player”?

    • iAvicenna@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      10 months ago

      “John Tromp and Peter Österlund estimated the number of legal chess positions with a 95% confidence level at ( 4.822 ± 0.028 ) × 10^44, based on an efficiently computable bijection between integers and chess positions.”

      %95 confidenece level? Did they make a poll?

    • Ech@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      ·
      10 months ago

      Tldr Estimated total number of legal chess positions is (4.822 ± 0.028) * 10⁴⁴

  • iAvicenna@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    what if you write an algorithm that will produce the necessary code for each possible move, so you don’t have to type them all manually

  • TootSweet@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    10 months ago

    I’ve seen someone code that way. Not since high school, but that’s a way that some people think coding works when they start out writing code.

    This person was trying to write a game in (trigger warning: nostalgia) QBasic and had it drawing kindof a Pacman kind of character. And in pseudocode basically what he was doing was:

    // Draw character with mouth open at (100, 100)
    moveCursorTo(100, 100)
    drawLineFromCursorAndMoveCursor(116, 100)
    drawLineFromCursorAndMoveCursor(108, 108)
    drawLineFromCursorAndMoveCursor(116, 116)
    drawLineFromCursorAndMoveCursor(100, 116)
    drawLineFromCursorAndMoveCursor(100, 100)
    
    // Wait for half a second.
    sleepSeconds(0.5)
    
    // Draw character with mouth closed at (101, 100)
    moveCursorTo(101, 100)
    drawLineFromCursorAndMoveCursor(109, 100)
    drawLineFromCursorAndMoveCursor(117, 108)
    drawLineFromCursorAndMoveCursor(109, 116)
    drawLineFromCursorAndMoveCursor(101, 116)
    drawLineFromCursorAndMoveCursor(101, 100)
    
    // Wait for half a second.
    sleepSeconds(0.5)
    
    // Draw character with mouth open at (102, 100)
    moveCursorTo(102, 100)
    drawLineFromCursorAndMoveCursor(118, 100)
    drawLineFromCursorAndMoveCursor(110, 108)
    drawLineFromCursorAndMoveCursor(118, 116)
    drawLineFromCursorAndMoveCursor(110, 116)
    drawLineFromCursorAndMoveCursor(102, 100)
    
    // Wait for half a second.
    sleepSeconds(0.5)
    
    ...
    

    He hadn’t gotten to the point of working in user controls. (Like “change direction to ‘up’ when user presses the ‘up’ key” or whatever.) And understandably had no idea how that would work if/when he got that far.

  • SeismicNote@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 months ago

    When I was learning c++ in high school, I made a working 10x10 implementation of Conway’s Life before I had learned about arrays.

    Even then I didn’t do it like this. Just had 200 variables for the front and back buffers, and one big function with individual checks for each grid coord variable to check it’s neighbors.

  • Venator@lemmy.nz
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    Reminds me of how I made tic tac toe game for my first university assignment 🤣

    • jaybone@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      10 months ago

      That has a finite number of moves. And then you could possibly generate the code based on that finite set.

      • Shard@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        10 months ago

        Chess technically has a finite number of moves. Although its a huge number and some have theorized its larger than the number of atoms in the known universe.

        • Albbi@lemmy.ca
          link
          fedilink
          arrow-up
          0
          ·
          10 months ago

          Technically it’s infinite, but that’s because of a stalemate. You can keep repeating the same moves over and over.

            • my_hat_stinks@programming.dev
              link
              fedilink
              arrow-up
              0
              ·
              10 months ago

              It’s not just repeated moves, a draw can be called if the board is in the same state 3 times at all during the game; if you get to the same position 3 times using different moves that still counts, even if it was a white move the first two times and a black move the third.

              The game also ends after 50 moves with no captures or pawn moves so you can’t play indefinitely by just avoiding those board states. Interestingly those two moves also make it impossible to return to a previous board state (pawns can’t move backwards, extra pieces are never added) so if you’re enforcing both rules in code you can safely discard previous board states every time you reset the move counter.

            • jaybone@lemmy.world
              link
              fedilink
              arrow-up
              0
              ·
              10 months ago

              But it’s a state machine, and you could easily contrive scenarios for infinite moves, without stalemate.

  • xlash123@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    Reminds me of when I downloaded Tic Tac Toe for my graphing calculator in high school. It wasn’t this verbose, but the original author copy pasted the logic for each turn. Even I knew this was awful, so I refactored it to use a loop.