Programming Thread

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

previous topic - next topic

0 Members and 5 Guests are viewing this topic.

Go Down

Legend

What solution did you go with? The solution that popped in my head was imagining a line from 0,0 to N,M on a pixelized grid. Two horizontal pixels next to each other represent a turn for the first unit and two vertical pixels represent a turn for the second unit. Could work with non integer speeds and could work with an arbitrary amount of units.

the-pi-guy

Thinking about it, I described it ambiguously before.

But basically it'd be like chess, if chess players could go more than once based on their speed so if M and N were 28 and 13, the turns would be calculated as:
28, 28, 13, 28, 28, 13

What solution did you go with?
The idea is that you build up a timeline:

Suppose M and N were m/s, then you could take 1 meter / (M) to get seconds.

You do this for the list of units, you sort them in ascending order.  

A.) The first unit in that list would go first. So you remove that one, and add it to the queue.

B.) Then multiply that time by whatever cycle that unit is on. So you calculate when they would make their k+1 move. You add this back into the list, in the place where it stays ordered.

Then you repeat steps A and B until you have the goal number of lookahead steps.

darkknightkryta

So back to my controller to arcade converters.  I managed to find some current sink shift registers, which solves a lot of my issues with hardware for my converter.  Finished up the Linux code for getting controller input, despite the lack of documentation on the controller stuff for evdev (Seriously, I was lucky I found a random post on the internet from someone on the SDL team with a working, useable example).  I managed to get my SPI code working, that I shamelessly took from wiringPi (Rip).  Shiftout worked.  Controller code worked.  I put the two together?  It broke.  Something's up with the way linux or GCC handles loops.  The word I was sending out was getting changed asycrhronously somehow.  So I was investigating multithreading.  Multithreading isn't fun.  I took a chance and copied the word to another variable before the shiftout.  It worked.   (╯°□°)╯︵ ┻━┻

Legend

So back to my controller to arcade converters.  I managed to find some current sink shift registers, which solves a lot of my issues with hardware for my converter.  Finished up the Linux code for getting controller input, despite the lack of documentation on the controller stuff for evdev (Seriously, I was lucky I found a random post on the internet from someone on the SDL team with a working, useable example).  I managed to get my SPI code working, that I shamelessly took from wiringPi (Rip).  Shiftout worked.  Controller code worked.  I put the two together?  It broke.  Something's up with the way linux or GCC handles loops.  The word I was sending out was getting changed asycrhronously somehow.  So I was investigating multithreading.  Multithreading isn't fun.  I took a chance and copied the word to another variable before the shiftout.  It worked.   (╯°□°)╯︵ ┻━┻
Gotta love when there's something fundamental that just doesn't make sense.

A couple days ago I had shader code that was producing impossible errors. Eventually I found out the text itself had an invisible character that was breaking things. Don't know how Unity let that slide vs warning me.

the-pi-guy



Quote
Someone improved my code by 40,832,277,770%
This is hilarious.

His code took over 30 days, someone else got it down under 10 milliseconds.

Legend

I love the casual annoyance when you start a piece of code only to realize you made an infinite loop. Just iterated through a linked list without actually implementing the "iterate" part  ::)

the-pi-guy

I love the casual annoyance when you start a piece of code only to realize you made an infinite loop. Just iterated through a linked list without actually implementing the "iterate" part  ::)
I accidentally made an infinite loop at work.
Iterating over a list, while inserting into the list. (And you know not jumping over the insert elements).

Legend

I accidentally made an infinite loop at work.
Iterating over a list, while inserting into the list. (And you know not jumping over the insert elements).
Oh gosh I just did it again! I fixed it but didn't click save since unity was in the middle of crashing.

darkknightkryta

Somewhat off topic, but this Raspberry Pi shortage makes me sad.  I stopped working on my controller code and switched to trying to wire an arduino micro controller.  The programmer, either doesn't work, or the one atmega chip I bought doesn't work (The variant I bought has issues apparently).  I'm going to try wiring it the hard way with a smd to dip adapter (Those massive ones) and see if I can get something on there.  If it doesn't work I'll have to get a atmega variant that just got restocked.

the-pi-guy

Yeah the raspberry Pi shortage is disappointing.

Kind of want to get one.  

Or try finding the one I bought before.

Legend


darkknightkryta


the-pi-guy

One of the most broken parts of Facebook is comments.

For some reason they filter out comments under posts. It makes sense to filter out spam comments, but it doesn't make sense to filter out comments you're tagged in. And they make it very difficult to unfilter.

Legend

One of the most broken parts of Facebook is comments.

For some reason they filter out comments under posts. It makes sense to filter out spam comments, but it doesn't make sense to filter out comments you're tagged in. And they make it very difficult to unfilter.
That's odd. Prioritizing "interesting" comments makes sense but fully filtering out real comments is silly.


Speaking of broken social media, I don't understand why most video players are is still so bad. The reddit one always breaks if you try to rewatch a video and the twitter one is a blurry mess for the beginning of the video.

the-pi-guy

I really dislike systems that are case insensitive but case preserving.  

It can make it really hard to change case for git, because git doesn't see the change.

Go Up