Hearts CLI
- 2 Devlogs
- 12 Total hours
A CLI version of the classic card game Hearts. Written in Go, this is my first time making a full project in the language.
A CLI version of the classic card game Hearts. Written in Go, this is my first time making a full project in the language.
Strategy Functions!
.
So I have a UI (CLI) for the player now. I think it’s pretty cool, each player (3 bots, 1 player) has a field for a strategy function which takes in a game state and returns a card. In the bots’ cases, that means doing logic.
.
But, for the player, I just have a player strategy function that gets the card the user wants and returns that. I really love when something fits in like that without having to make exceptions.
.
Right now, I’m trying to figure out why my code has decided to deal every player the same cards. Very fun.
I’ve started outlining my new project! I’m making the game Hearts as a CLI.
I’m writing this in Go, a new language for me. I’m excited to learn but it’s been difficult, what with all the unique structure.
About the project, I’ve decided to make structs for players that have a field for their strategy, a function that takes in a state and returns a card. This will let me try out different strategies easily just by writing it in code, but it also seamlessly translates to player input. The function just gets input from stdin instead of doing logic to return a card.
My knowledge of Go (or lack of it) has been challenging because I’m used to knowing the correct way of doing something in Python whereas in Go I’m just making things up :)