so, over the summer I decided to learn python and how to use django. I am very interested in real-time applications, particularly the websocket technology, so I instantly started working on a project with django channels.
I made a chat application first.
There is not much to say about it: features include public and private messaging, attachments, message formatting, moderation (kick/ban/mute) tools, invisible mode, theme and language selection, and tag notifications.
Here’s a feature tour page (the graphical interface looks different as I updated it since creating the page): https://samul-1.github.io/chat1/
Last week, I decided to make an app for playing a card game. This game (don’t know if it’s a thing worldwide) is called dubito, which means I doubt, in Italian.
Here’s how it goes: you have n players, and the deck(s) of cards is divided and dealt equally between those players. There are no cards left. The first player declares a card, and puts down one or more cards covered. All the other players have to put down one or more cards too, when it’s their turn, and they have to be the initially announced card. Here’s the catch: you can lie. You can say you’re putting down 2 aces but it might be a 3 and a K.
At any time, a player can doubt, and the last cards that were put down by the last player are uncovered. If they lied, they take all the cards that were previously put down. If they hadn’t lied, the player who lies is the one who takes all the cards in their hand. To win the game, you must be left with no cards.
A round could go like this:
first player: “3 aces” (puts down 3 aces)
next player: “1 ace” (actually puts down a Q)
next player: “2 aces” (puts down 2 aces)
next player: Dubito! (cards are uncovered, the previous player had actually put down aces, so the last player takes all the 6 cards)
Here’s the code:
I feel like my server-side logic is solid, and it works flawlessly. The frontend js is a hot mess. I am almost embarrassed. I realized I need to learn vue: I would be able to do these things writing one third of the code I did.
Lastly, I made a js-only app which is an assembly interpreter.
https://samul-1.github.io/asm/
It’s not perfect but it does its job well. The type of asm it interprets is the (virtually useless) D-RISC version. There’s an instruction set modal that shows all the supported instructions so you can play around with it. I am aware the way I implemented it is not how you write an interpreter, for the most part. This was more for fun than anything else. Turned out well, for the purpose of playing with code.
Bonus:
http://playcards.altervista.org
Last week I also made this php&ajax app in 48 hours. It’s a much simpler card game than dubito, in which you try to get a score of 7 and a half without exceeding it by drawing cards. I am planning on writing an AI-ish algorithm to allow players to play against a computer, rather than another human.