Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 792 793 [794] 795

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 820699 times)

sodafoutain

  • Bay Watcher
  • [PREFSTRING:incessant muttering]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11895 on: September 18, 2023, 01:13:18 pm »

What pet projects are you guys working on right now? I've been trying to write a Rust program that does some simple cesarean shifting. The most problematic thing right now is looping back over the iterator of the alphabet when it reaches the end. That, and I think something somewhere is organizing the contents of the vecs alphabetically for some reason.
Logged
I have no idea where anything is. I have no idea what anything does. This is not merely a madhouse designed by a madman, but a madhouse designed by many madmen, each with an intense hatred for the previous madman's unique flavour of madness.
Richard Stallman's Kind Communication Guidelines

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11896 on: September 18, 2023, 02:42:53 pm »

I've been working on and off on a space 4X game with lo-fi graphics.  It's not a game yet and so far is mostly just a solar system generator, but these are some screen shots of where it is now.

Spoiler: Large Images (click to show/hide)

I've been told that this is somewhat similar looking to Aurora 4X, but I haven't played it so that's a coincidence.  After reading up on it I can say that while I wanted to do something similar in a lot of ways I have no intention of replicating its level of detail.  I wanted a much stronger focus on societal and cultural aspects compared to the extreme detail for military conflict in most current space 4X games.

Anyway, right now I'm working on a test bed for the architecture.  This version is built as a separate client and server with a focus on making it multiplayer-capable, with even single player mode working with separate client and server processes that just connect locally.  That theoretically makes multiplayer simpler to implement since it has to work that way from the server's perspective, and it has the advantage of making the client interchangeable.  If by some miracle this became popular one day, people could make their own clients that looked like whatever they wanted as long as they stuck to the protocol.  My crummy lo-fi version wouldn't have to be the only version.

The server is built using Node.js and hosts a web socket server that clients can connect to and communicate using a simple JSON protocol.  The client right now is just a website using HTML5+Canvas to render everything.  If the proof of concept works out I planned to try rebuilding the server in Rust as a way of learning Rust and to potentially improve performance.  I may continue to build a web capable version, but my ultimate plan was to distribute it through Electron or something.  Using HTML and an embedded browser makes UI development so much easier for me than anything else since I do web development as my day job.  I'm sure a client could be made with Godot or something so I may look at that eventually, but using a real game engine with web sockets may be tricky.  I could switch to a raw TCP protocol or something instead I guess.

A lot remains to be seen about the viability.  Network communications for multiplayer games like this very nontrivial, and a lot of data is being shuffled around.  I'm trying to go with a centralized server and thin clients instead of a deterministic lock step method that a lot of multiplayer games use, and I may discover why most games don't do this.
Logged
Through pain, I find wisdom.

Loud Whispers

  • Bay Watcher
  • They said we have to aim higher, so we dug deeper.
    • View Profile
    • I APPLAUD YOU SIRRAH
Re: if self.isCoder(): post() #Programming Thread
« Reply #11897 on: September 28, 2023, 06:02:51 am »

Are you thinking of adding nebula clouds or weird stellar objects? I think just having a background png of some galaxies could be a quick and easy way to greatly up the visuals

delphonso

  • Bay Watcher
  • menaces with spikes of pine
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11898 on: September 28, 2023, 09:07:52 am »

I started a new job so am in the process of learning all the paperwork I'm supposed to do so that I can automate almost all of it. Teachers have a ton of busy work that can often be wiped with a loop and a csv file.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11899 on: September 28, 2023, 06:14:39 pm »

That's a very good use of coding skills.  Let the computers do the repetitive work.

Are you thinking of adding nebula clouds or weird stellar objects? I think just having a background png of some galaxies could be a quick and easy way to greatly up the visuals

Yeah, probably.  I'll add something really simple like that to break up the black background at the very minimum.  The galactic map will also eventually have more information like empire borders and such.

I just finished coding a first pass at adding atmospheric data and temperature calculations to planets so my next step is to make the planet graphics based on that.  That'll make the solar system view better.

Otherwise, my plan was to start with a realism-first approach to the game, FTL travel and comms aside, so there aren't any Star Trek style nebulae that you can hide in or anything.  Black holes and neutron stars and such will exist, but all realistic stuff by default.  A very distant goal was to allow the realism to be configured in various ways and to make it moddable, but that's far off enough that I haven't done much planning on it.
Logged
Through pain, I find wisdom.

McTraveller

  • Bay Watcher
  • This text isn't very personal.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11900 on: December 19, 2023, 01:47:07 pm »

Anyone know why clang/llvm would output assembly like this for x86_64?

Code: [Select]
movq %rdi, -8(%rbp)
movq -8(%rbp), %rdi

This just moves contents of rdi into a stack-local variable then... moves the same value back to rdi? Why would it do this!? Even without optimizations (there are no -Ox command lines here), what intermediate code could possibly result in this no-op!?

NOTE: There are no side-effects here, ebp is not indexing some hardware register that might read different from how it's written.
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11901 on: December 19, 2023, 02:29:14 pm »

Side effects from memory mapped hardware are the only reasons I can think of, so I'm at a bit of a loss.  It's been a while since I've looked at how this all works, but if you compile it with debug symbols can you trace the line of code that it corresponds to?
Logged
Through pain, I find wisdom.

McTraveller

  • Bay Watcher
  • This text isn't very personal.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11902 on: December 19, 2023, 03:46:42 pm »

I did that, it's literally just a variable assignment in a structure element, like:

Code: [Select]
void foo(StructType* s, int a)
{
    s->m1 = a;
    s->m2 = function_of(a);
    :
    :
}

If I compile with -O it of course is sensible.

Interestingly enough, if I create a new local variable it "fixes" it even without -O, so is probably related to something with the structure indirection.

Definitely interesting.

(This is important because these functions are called very often, it's some numerical simulation code... dumb stuff like copying variables twice for no reason stood out as a red flag!)
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11903 on: December 19, 2023, 04:34:37 pm »

That's really interesting and probably has some convoluted cause deep in the AST in clang that they figured was good enough if it gets optimized away for normal builds.

On that note, I'm curious how you found this / why you were inspecting the generated ASM from a non-optimized build.  Inspecting the ASM of an optimized build would be challenging if you're trying to hand optimize it, but I'd expect you'd be compiling anything performance sensitive with compiler optimizations so I'm not sure how useful an unoptimized build is to even look at.

That said, I've never actually used inline ASM in C or C++, so is it possible to reliably infer the registers used so you can hand code it?  I'd be afraid even that might change when optimizing the code.
Logged
Through pain, I find wisdom.

McTraveller

  • Bay Watcher
  • This text isn't very personal.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11904 on: December 19, 2023, 07:06:51 pm »

The totally mundane reason was I was looking at assembly in my debug build was I wanted to verify that -ffast-math was indeed emitting opcodes for things like min/max instead of calling functions.

Even the just base -O code seems to have way more steps than I'd do if I was doing it by hand... I haven't looked at -O2 or -O3 code yet.

Basically, the -O code has way more mov instructions than I'd expect... lots of shuffling stuff around and re-loading constants instead of cacheing a re-used value for example.
Logged

WealthyRadish

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11905 on: December 19, 2023, 07:55:56 pm »

My guess is that it's due to LLVM's heavy use of SSA (but it is just a guess).
Logged

StrawBarrel

  • Bay Watcher
  • I do not use social media regularly.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11906 on: February 22, 2024, 11:12:22 pm »

I did a good chunk of android mobile development today. I'm pretty new to Android studio and Kotlin, but the lessons I'm getting are working out so far.
I was able to work with a little bit of html today. I feel like I am learning how to use github more comfortably as well.
I think my next goal will be to learn how to use React.
https://react.dev/
I never used it before, but I think it will be a good challenge to try something new.
Logged
Max avatar size is 80x80

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11907 on: February 23, 2024, 01:09:54 am »

Learning React was a bit bizarre for me, coming from an AngularJS 1.x background.  Most of that was just getting used to JSX and the tool chain since it's doing a lot of "magical" stuff that I don't fully understand.

I never really felt like I truly got the hang of it, but I do remember it getting a bit easier once I understood some of its quirks.  I wish I could remember the details now, but I do remember there being some complication with scoping and callback functions.

I wonder how Angular 2+ compares to React in that regard.  The only other similar framework that I've used was Vue.js, and I just couldn't get into using it either.

Anyway, React is definitely hot with web dev now so it's a good thing to learn.
Logged
Through pain, I find wisdom.

StrawBarrel

  • Bay Watcher
  • I do not use social media regularly.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11908 on: February 23, 2024, 01:17:05 am »

Ah gotcha. Thank for the info Telgin. Hopefully I will get around to trying it out and seeing what I can learn from React.
Logged
Max avatar size is 80x80

Salsa Gal

  • Bay Watcher
  • Diggy diggy hole
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11909 on: March 05, 2024, 07:48:45 pm »

I started working on the 7DRL game jam a few days ago, but then I got busy and missed out on two days of working on it, so I don't think I'll be able to submit anything this time :(
Pages: 1 ... 792 793 [794] 795