Project GoSnake Log
3D snake clone using Go and G3N (for practice)
[thread]
Project GoSnake Log
3D snake clone using Go and G3N (for practice)
[thread]
From the get go, first lesson:
When importing modules Go fetches the newest tag in the repo's main branch. If that's not latest, you run into a problem.
It confused me when I called a function from the example game (https://github.com/danaugrs/gokoban) and Go threw a build error saying the signature it has is different.
To fix this you have to use a feature called pseudo-version (https://go.dev/doc/modules/version-numbers#pseudo-version-number) to fetch an exact ref/branch by running:
```sh
go get github.com/User/Repo@branch-or-ref
```
Experimented on different ways to structure the code in a Go way. Funny enough the method that won is how I write my things in C++ nowadays: lambda/inline functions working on in-context defined data.
Missed one thing that I thought would be trivial in Go: coroutines!
Turns out, goroutines are light threads that can't yield. Discussion: https://stackoverflow.com/questions/18058164/is-a-go-goroutine-a-coroutine
Coros can be implemented but not trivially. Here's an excellent writeup: https://research.swtch.com/coro
Anyway, snake alive now 🐍
It occurred to me that the way goroutines + channels work is similar to a particular programming game I like called: [TIS-100](https://store.steampowered.com/app/370360/TIS100)
In it there's N computers that communicate with each other via send/receive channels that block execution until data is received. This forms the main puzzle mechanic: how to solve algorithmic problems via a grid of minimal-code communicating parallel processes.
Also similar to the main runtime model that the FORTH computer uses I believe 🤖
Finally I'm finished with gosnake, release time! 🕺
GoSnake v1.0 🐍
* Windows: https://zenithsal.cloudmillgames.com/assets/releases/gosnake/gosnake-v1.0-win64.zip
* Linux: https://zenithsal.cloudmillgames.com/assets/releases/gosnake/gosnake-v1.0-linux.zip
Learned a lot about Go from this. The code is horrendous due to my experimentation and I should really have followed a style guide, but hey .. it-works-on-my-PC (™️) 🎆