#code-talk

2 messages ยท Page 10 of 1

coral sundial
#

it uses usart

orchid needle
#

so you're talking about the RX/TX pins?

coral sundial
#

I think so

#

I thought it worked using the USB lol

orchid needle
#

what model arduino do you have

coral sundial
#

atmega128 I think?

#

I have to check AVR dude

orchid needle
#

that's the micro controller

#

but uhh

#

one sec

coral sundial
#

uno

#

arduini uno

orchid needle
#

ah okay, so your serial port connects pins 0 (RX) and 1 (TX)

coral sundial
#

yes

#

I am going to need a custom cable to start xD

#

I am wondering though, if serial communication is just a standard c library or something with just a bunch of functions to send through a connected cable

#

I am totally clueless on this subject

#

Oh I see, you have both USART and UART for the avr

#

but thats the avr side

orchid needle
#

so from what I understand you need to enable the optional interface (uart0) in this case through the config on the device?

coral sundial
#

I think you're going to need to set a flag on one of the arduino's registers yes. but I am not that far yet

orchid needle
#

The USART has to be initialized before any communication can take place. The initialization process normally consists of setting the baud rate, setting frame format and enabling the
Transmitter or the Receiver depending on the usage.

coral sundial
#

where are you getting that from?

orchid needle
#

the data sheet

coral sundial
#

ah

orchid needle
#

if you look up the microcontroller

#

begin with Ctrl+F and find the topic you're interest in

#

in this case USART

#

and you'll see it starts on page 171

#

scroll down to 176, on the topic of USART Initialization

coral sundial
#

I am more specifically interested right now in enabling usart from the computers side. since I want to send information through an existing framework instead of a console/logger application to be honest

orchid needle
#

then make sure you understand what stuff like Clock Speed, Baud Rate, and Frame Format is, and set them according to your needs

coral sundial
#

I am reading baout baud rate now

orchid needle
#

from the computer's side...

#

you're uploading a program to the device right?

coral sundial
#

yeah

orchid needle
#

you enable it using #define 's and some builtins macros

#

implementing something like USART_Init from the datasheet

coral sundial
#

and I want to send information, for example a postion x,y on a screen to an arduino.

#

is that standard c library stuff?

orchid needle
#

depends on the implementation

coral sundial
#

because I can include that and it should just compile without issues

orchid needle
#

it's probably standard for arduino, whatever you're using to compile

coral sundial
#

I can just try it lol

orchid needle
rain gazelle
#

@hoary dune oh ok mb I didn't see that

hoary dune
#

^^

orchid needle
#

the UBRRH UBRRL are the high/low parts of a 16 bit memory address

#

declared as macros, in the library that the datasheet is assuming should be implemented for your device

coral sundial
#

it is, then I have enabled it on the arduino

#

I would then need a terminal on my computer

#

and thats what I am most interested in

#

since a terminal is just a terminal. and I kind of want to use a framework so I can also do fancy stuff on the PC

#

but I got a feeling that stuff like that is really complicated haha

orchid needle
#

so you want to send and receive data over a usb port and interface with the arduino using the terminal?

coral sundial
#

yeah

orchid needle
#

you'll want a device that lets you pretend to be a serial port if you're communicating using uart

#

if you were just doing this with the arduino's usb port it'd be easy as hell

#

because the arduino's usb port is seen as a serial port for computers

#

and some standard C code as an example for communicating over such a port

coral sundial
#

I dont think you quite get what I am trying to achieve. I just want to be able to send the number 8 to an arduino using any normal c library if at all possible

#

I dont want to use a terminal program :V

#

its hard to track down any information that lets you do that. like running your own program and sending some basic info to an arduino

orchid needle
#

I wasn't aware a USB port was treated as serial and that pins 0 and 1 are connect to that USB-to-TTL chip

#

as far as terminal program stuff... you don't need to interface through the terminal

#

but you need to communicate over that serial port, and the code shows you how ;o

#

using these functions, specifically

coral sundial
#

thats exactly what ive been looking for holy shit xD

long raft
#

C is not backwards forward compatible with c++ anymore, c++ doesn't fit in the scope of C now

#

plus new C has all these new things that make it look a lot more like c++, if you look at only a short block of code it can be hard to differentiate it between c/c++/c#/java

orchid needle
#

Well I guess it was never completely forward compatible to begin with

long raft
#

oh i didnt know that, i assumed it was at the start

#

a lot of it seemed to be the particulars of the compiler

timber onyx
#

the fact that you'd think a universal serial bus wouldn't be Serial triggers me @orchid needle

orchid needle
#

thing is it's a bus

#

so you need a usb to ttl

#

I just didn't know the usb on the arduino was set up that way

timber onyx
#

oh finally somebody bringing arduino stuff in this channel

#

@long raft hear that? not everything is high level you nerd

orchid needle
#

I only worked on PIC microcontrollers

timber onyx
#

mmmh thats a bit advanced for what im doing

orchid needle
#

what are you doing ;o

timber onyx
#

mostly interfaces and other learny schooly stuff

#

right now actually im learning about pointers, addresses and all the other boring stuff needed to talk to stupid chips

orchid needle
#

That stuff isn't boring ๐Ÿ˜ฎ

#

I eat that shit up

timber onyx
#

i know but people around THESE parts probably find that tiresome

#

not to mention i probably learned more in an internship i got last summer than i did so far in my session lol

#

always learn better when you're forced to start using everything from scratch lol

coral sundial
#

ive been bringing arduino stuff in here for months disk, MONTHS ๐Ÿ˜›

#

buts its always just press a button, light a led kind of stuff.

hoary dune
#

@long raft hear that? not everything is high level you nerd
@timber onyx I'll be the one to bring script kiddie stuff in here dw ๐Ÿ˜‚

pure sierra
#

most arduino have the usb to serial chip on board or on die

#

various chips wil have 1-4 serial ports

coral sundial
#

I just cant find any tutorials on how to use it though

#

I got as far as finding atmel's own documention for serial communication and a library called LUFA but oh my is it complicated xD

#

the arduino IDE examples just dont cut it anymore, they're not what I am looking for.

timber onyx
#

sorry but unless you have a specialist to explain it to you you're pretty screwed

compact goblet
#

nerds

coral sundial
#

sooo.

#

path finding algorithms

#

I have got no clue.

#

how are you supposed to go from one point to an array to the other

#

Oh I get the theory but I only get stupid java code examples

frozen oriole
#

you need some kinda path map that tell the ai if it is practicable or not

fervent spear
#

how good do you need that algorithm to be?

coral sundial
#

just something that works on a 25 by 25 grid

#

that seems like a good start

frozen oriole
#

and the ai will take the shortest path

fervent spear
#

what structures does your example use?

coral sundial
#

I have a 2d array

fervent spear
#

and a queue?

coral sundial
#

I have a 2D array at the moment.

fervent spear
#

in that you are going to need to mark tiles as checked

frozen oriole
#

i whish i knew how to programm on my own

fervent spear
#

basically, go to a tile, mark it as checked, and then do the same for the surroundig one that aren't checked

frozen oriole
#

still struggling to use a lcd display on arduino

coral sundial
#

thats where I am stuck at tho

#

if I have a position randomly in the graph, how do I find its neighbours?

frozen oriole
#

maybe do like mars rovers

coral sundial
#

I havent done LCD displays either xD

fervent spear
#

how do you have your data? graph with pointers?

#

matrix?

frozen oriole
#

calculate every path possible and take the shortest

coral sundial
#
    int tilesY = 50;
    int Map[tilesX][tilesY];



    for(int row = 0; row < tilesX; row++)
    {
        for(int collumn = 0; collumn < tilesY; collumn++)
        Map[row][collumn] = 1;
    }

    Map[6][8] = 2;

    InitWindow(screenWidth, screenHeight, "Strategy game");```
fervent spear
#

you can make a queue, and add all the tiles you haven't visited surrounding the one you are in

coral sundial
#

yeah but that is the issue, how do I find the tiles surrounding me? and then recursively finding the tiles surrounding those tiles

fervent spear
#

where are you trying to pathfind?

#

what is your input?

coral sundial
#

any position inside the graph

fervent spear
#

which graph?

coral sundial
#

lets just say map[20][40] to map[23][50]

#

array grid whatever

fervent spear
#

i = row
j = column;
surroundig tiles to map[i][j]:
map[i+1][j]
map[i-1][j]
map[i][j+1]
map[i][j-1]

frozen oriole
#

are there any obstacles ?

fervent spear
#

you also have to check those aren't offlimits

coral sundial
#

so I have to check every tile around me? save those locations in an array, and then check for every item in that array locations around that?

fervent spear
#

in the array you save the tiles you have visited, you need another structure to save the ones that you are going to visit

#

a queue or a stack

#

depending which type of pathfinding you want to use

coral sundial
#

well considering I am completly new to pathfinding the most basic one imaginable ๐Ÿ˜„

#

@frozen oriole no obstacles yet

fervent spear
#
queue q;
q.push(starting tile);
visited[startingtile]= true;


while(q not empty){
  tile = q.front;
  q.pop;
  if(not visited[tile]) {
    if(goal) finish or save it
    else{
      visited[tile] = true;
      for(each tileB surroundig tile){
        q.push(tileB);
      }
    }  
  }
}
#

this is supposed to be comprenshible pseudocode

coral sundial
#

mmmh the pseudo code isnt that helpful, I am mostly stuck on how to code it and its hard to follow that.

fervent spear
#

you need to have the shape of the algorithm clear

coral sundial
#

Ive gotten this far. you get your position. then iterate through every position around you.

#

then you save those positions as visited? and add them to a queue to visit?

fervent spear
#

you mark the starting one as visited and save the others in a queue to visit

barren quarry
#

A*

fervent spear
#

let's not start with that

coral sundial
#

yes lets not do that

barren quarry
#

why

coral sundial
#

but how do I save a coordinate in an array. since they are technically two different integers

fervent spear
#

learning by bits, and honestly you can adapt it fairly easily

#

you mark the same position in the second array

#

so you go visited[rows][columns] = true

coral sundial
#

ah okay, so I have a second array in which I store the visited area's

fervent spear
#

yeah

frozen oriole
#

you can make a vector system

coral sundial
#

I can work with vectors as well but I havent made the grid out of vectors

fervent spear
#

as a matrix is a vector of vectors you, technically, have

frozen oriole
#

it does ydesiredposition-ycurrentposition and xdesiredposition-xcurrentposition

fervent spear
#

that's A*

frozen oriole
#

and you got the path

fervent spear
#

and that's only a part of it

#

the base is what he is doing now

coral sundial
#

oh so if youre wondering, I am using a framework that lets me make some basic C games. I use it for stuff

fervent spear
#

what are you pathfindig for?

coral sundial
#

I want to make a character move from one place to another

fervent spear
#

then you should be fine with this approach

coral sundial
#
        Map[posX-1][posY] = 0;
        Map[posX][posY+1] = 0;
        Map[posX][posY-1] = 0;```
I got this right now, but do I now need to save each position after it changed in an array?
fervent spear
#

you need to save them before marking them

coral sundial
#

I am having a really hard time wrapping my silly brain around that

fervent spear
#

if you want your code not too look like a mess you can set up

 const int directions[4][2];
    directions[0] = {1,0};
    directions[1] = {-1,0};
    directions[2] = {0,1};
    directions[3] = {0,-1};

and then

  for(int d = 0; d < 4; d++){
    pos[posX+directions[d][0]][posY+directions[d][1]] =...;
  }
#

that is for later

coral sundial
#

yeah, I am going to have to wrap my head around every step first before I can loop it

fervent spear
#

the first step is just that:
am i there yet?
ok, i have been here, i will have to go to this places around me

coral sundial
#

how do I find it if I've been somewhere? I marked it as 0. do I now need to check for every 0 and if so, look around that?

fervent spear
#

you usually initialize the second array as not visited

#

and mark every place you visit as visited

frozen oriole
#

wow, this is getting complicated

coral sundial
#

I know ๐Ÿ˜ญ

frozen oriole
#

imma head back to my blinking led on arduino

coral sundial
#

its not okay how complicated it is

fervent spear
#

you could try to manually emulate BFS on a graph, try if it helps you understand

#

I marked it as 0. do I now need to check for every 0 and if so, look around that
no, you need to remember the places around the one you marked as zero

coral sundial
#

okay so everything time we make a 0. we save that location?

fervent spear
#

we save those around it

#

(if they are not marked and not out of bounds)*

coral sundial
#

okay, but that still means I got to check every location around that zero. which still means I need the location of the zero right?

fervent spear
#

the first one you decide it arbitrarily , and the next ones are the ones you saved

#

so you shouldn't have to search for a zero

coral sundial
#

No I mean. we have that location. that is saved. and then check around that location.

#

or am I being retarded?

fervent spear
#

save the tiles around that location, to check them later

coral sundial
#

how do I save the tiles around that location?

fervent spear
#

you add them to a queue

#

are you in java?

coral sundial
#

C

fervent spear
#

that makes it complicated

coral sundial
#

I could use c++ as well since its accepted code

#

but I am not known in c++

#

I only know how to use structs

fervent spear
#

so you can use any c++ library

coral sundial
#

yes?

fervent spear
#

#include <queue>
compiles?

coral sundial
#

no

#

its not linked

fervent spear
#

you can always implement one manually.

#

Any other way to implement a FIFO structure?

coral sundial
#

you could do something with an array

fervent spear
#

I Can't help you getting the C queue on your environment, but i can help you making a homemade one

coral sundial
#

array 0 is first out. shift everything index - 1, add something at the end

fervent spear
#

alternatively you could also go with the equally complicated less efficient but queue less version

#

for a array queue, you can also copy C and do it with two indexs, a index for the first out and another for the last in

timber onyx
#

yes i was wondering why use a queue when this could be done more easily with a longer code

fervent spear
#

recursive DFS?

#

or have I forgoten a simpler one?

coral sundial
#

I figured something should be recursive

timber onyx
#

eeeh i might not completely understand what you need then

coral sundial
#

finding a path from A to B

#

by checking literally every possible space

timber onyx
#

oh i thought you just wanted the thing to move when you pressed the arrow keys

coral sundial
#

no i can do that

#

I want it to move for me

timber onyx
#

oh then that is beyond me, ignore what i was saying

fervent spear
#

DFS uses a stack instead of a queue, and since recursivity is a call-stack no extra structures are required

#

DFS makes a beeline for one corner, then a beeline for the next one and so on

#

it looks really stupid to have a character moving that way, but it gets there

coral sundial
#

hehe

#

I mean, it doesnt have to move untill a path is found?

fervent spear
#

the goal is to know which is the first step to take, BFS you can trace back which was the first one that lead to this path, in DFS you will probably find it with the first one you check

coral sundial
#
    #include<conio.h>
    int a[20][20],q[20],visited[20],n,i,j,f=0,r=-1;
    void bfs(int v) {
        for (i=1;i<=n;i++)
          if(a[v][i] && !visited[i])
           q[++r]=i;
        if(f<=r) {
            visited[q[f]]=1;
            bfs(q[f++]);
        }
    }
    void main() {
        int v;
        clrscr();
        printf("\n Enter the number of vertices:");
        scanf("%d",&n);
        for (i=1;i<=n;i++) {
            q[i]=0;
            visited[i]=0;
        }
        printf("\n Enter graph data in matrix form:\n");
        for (i=1;i<=n;i++)
          for (j=1;j<=n;j++)
           scanf("%d",&a[i][j]);
        printf("\n Enter the starting vertex:");
        scanf("%d",&v);
        bfs(v);
        printf("\n The node which are reachable are:\n");
        for (i=1;i<=n;i++)
          if(visited[i])
           printf("%d\t",i); else
           printf("\n Bfs is not possible");
        getch();
    }```
#

I hate that its so obfuscated though. for my eyes it just uses random letters to name things

fervent spear
#

that is hideous
bfs(q[f++]);

#

and yeah, it uses a array and two indexs as queue

#

afk.

fervent spear
#

@coral sundial back, want to continue trying to adapt that?

coral sundial
#

Sure

#

Walking the dog at the moment though

fervent spear
#

@coral sundial
So for the home-made queue, you need a long array of size 2 arrays, and two indexes (front and back), push is saving in the back position and increasing back, front is just reading front and pop is increasing front

#

can you use structs you said?

#

so for every tile you want to save :

  queue[back] = {posX, posy}
  back++;
coral sundial
#

Will do

timber onyx
#

alright so i know absolutely nothing of high level programming

#

does anybody know how unity engine files work

languid harness
#

You put them in a folder and is read by the unity engine

#

This needs more precise wording @timber onyx

timber onyx
#

ok how do you open a unity file without using the engine, like you were opening the code to a blinking LED light to check the frequency or something

#

i really know nothing about how this works

timber onyx
#

you know what, i might just be looking at it wrongly

coral sundial
#

alright

#

back to wurk

hoary dune
#

@coral sundial I missed the convo earlier but for pathfinding I think the big ones are Dijkstra's algorithm and A*

#

might wanna look into those

coral sundial
#

yeah but the tutorials are pretty advanced

#

and often use obscured names for integers

hoary dune
#

A* is pretty straightforward no?

coral sundial
#

yup but its hard reading code that has names for integers such as dsf(adj[a][i]);

#

following this one at the moment

#

still lost at how to make the queue

hoary dune
#

which coding language is this for?

coral sundial
#

c/c++

#

but I am not fluent in C++ syntax

#

using things like std::namespace is lost on me

hoary dune
coral sundial
#

YUP

#

look at the code

hoary dune
#

I mean

#

I don't see anything weird in the code

worldly thunder
#

A* algorithm ๐Ÿ˜ข

coral sundial
#

I see alot of comments to add too much explantion

#

and codes with things like [i-1][j-1]

#

which is imho really hard to read

hoary dune
#

that's not hard tho

#

it's simply itteration

coral sundial
#

once you know what it does

hoary dune
#

it's a double nested for loop

#

to itterate through the entire array

#

so I is the row, J is the column

#

what is hard about that?

#

I and J is the current Cell

#

[I-1][J-1] would be the cell to the NW of the current one

#

in 2D space atleast

#

Yes, it's overcommented but it's a tutorial to explain into the smallest detail how it works ._.

#

funny thing tho they made a mistake in their graphic ๐Ÿ˜‚

#

anyways, if it makes any more sense.... f is basically the cost of the entire path from point A to point B

#

f = g + h

coral sundial
#

besides that, I am mostly looking for something that just looks through the entire grid at the moment, since that is where I am struggling

hoary dune
#

g is the previous node, h is the current node

coral sundial
#

but I got something in my mind now

#

lets just leave constructing a path for another day xd

hoary dune
#

I mean your question was about pathfinding :p

#

pathfinding isn't easy until it clicks

#

then it's not that hard :p

coral sundial
#

yeah, so baby steps xd

hoary dune
#

you were on the right track tho

#

you wanna map the positions around your current position

#

and figure out which one is closest to the target

coral sundial
#

I get it somewhat.

  1. you have a start position. add that to a list of open positions
  2. check around you, add those tiles to the list of open positions
  3. remove the tile you just checked and add it to closed positions
#

but now I need to know how to construct a list.

#

which could be a simple array i guess??

hoary dune
#

yes

#

in the example I linked as well

#

example

#
                     isUnBlocked(grid, i-1, j+1) == true) ```
#

again, itteration over those arrays

coral sundial
#

hollup

#

we can check for valid positions later

hoary dune
coral sundial
#

which is I think just checking your tile and checking if its valid. if so add it to open positions, if not add it to closed positions

hoary dune
#

maybe this will make more sense

coral sundial
#

the thing I am also struggling with is that I am pathfinding through a map array that I also use to draw textures with

#

mmmh

hoary dune
#

can't you just convert the array to a binary array?

#

if it's a tile that is blocked = 0

#

if it's a tile that is accessible = 1

coral sundial
#

mmmh

#

yes

#

I think so

#

every location in the array could refer to a structure that contains more info about that terrain type

hoary dune
#

so basically you got something like

#

tileData.walkable

#

that is either 0 or 1

#

also sorry I haven't used C++ in forever

#

I'm so used to javascript nowadays ;-;

drifting hornet
#

Ew.

hoary dune
#

yea I know

coral sundial
#

yeah, and then loop over the array and check for every tile if its walkable or not. and then add that to a pathfinding data array

hoary dune
#

yup

#

basically just project it to a new array

#

yea I make shitty scripts for a browser game don't shoot me ๐Ÿ˜ญ

drifting hornet
#

I usually keep that pathfinding array cached somewhere kind of like a layer because I often need it around.

hoary dune
#

I'm not a programmer

coral sundial
#

I aint either

#

I learned C to code arduino's with

#

I dont know how any of this schmancy c++ stuff works

hoary dune
#

the 0 -1 stuff is also used in collision mapping

drifting hornet
#

I'm been writing a turn-based strategy for a month now in Rust. I began writing the design document last night as a way to formalise the project.

#

Right.

hoary dune
#

I'm looking into unreal engine atm

coral sundial
#

before you ask. the arduino languange is bad. it abstracts perfectly fine c code and leaves out the more powerful stuff

hoary dune
#

I studied character design so I have a small amount of knowledge of it

#

but wanna see how much I can do with the blueprint technology

drifting hornet
#

So, often the pathfinding layer contains information like:
Is the tile see-through?
Is the tile physically solid or otherwise unwalkable to me?
Etc.

coral sundial
#

honestly, I use raylib. its a c/c++ framework. it provides alot of the basic functions to make a simple game

hoary dune
#

the only 2 games I ever made in C++ was a bomberman clone, and a candy crush clone

coral sundial
#

I dont need to use UE right away ๐Ÿ˜›

hoary dune
#

for assignments

#

I hated programming back then

#

I got into it again making scripts for a browser game called tribalwars LOL

drifting hornet
#

That's my project right now.

#

Well they're older screenshots but it's mostly the same.

hoary dune
#

how do you find the motivation to actually START on a project

#

like

coral sundial
#

back to A*

hoary dune
#

I have all these ideas but knowing the effort that goes into it

#

it's like.... o god what am I getting myself into

coral sundial
#

I have an open list. I have one coordinate in it. 0,0
if I go to 1,0
I then need to add that to the closed list

#

how do I do that

#

another integer to hold that value?

drifting hornet
#

Motivation to start? Usually it's the middle part that gives people trouble.

hoary dune
#

I think you just have to make the entire list the exact same coordinates

#

like

#

if 1,0 is closed, then put the 1,0 in closedList to 1

drifting hornet
#

Wait, what list are we talking about?

#

Are you making a list of the path?

coral sundial
#

A*(star)

hoary dune
#

trust me

#

look at that video

coral sundial
#

๐Ÿ˜ 

drifting hornet
#

That's a good one.

hoary dune
#

it explains it super well

drifting hornet
#

I can give you another one as well.

#

Just saying, written documentation of A* is really... shit.

hoary dune
#

cause the idea of what happens behind the scene is way easier to explain visually

#

cause after all, its a path you are trying to draw on a tilemap

drifting hornet
hoary dune
#

oh ya that one is good too

#

I watched that a while ago

coral sundial
#

yeah but I am having an issue with visiting tiles and saving their coordinates

drifting hornet
#

How so? Can you maybe show me your source code?

coral sundial
#

I need something to hold the start position. then go up. save that position in an array. then go left use that something to save that value and add in an array. and then do that again untill you have found a path/matching coordinate

#

but like, everytime I check a tile, I need that coordinate. and save it

fervent spear
#

and how did that vector queue go?

coral sundial
#

doesnt work

#

expected expression before {

fervent spear
#

in this line?
queue[back] = {posX, posy};

coral sundial
#

yes

fervent spear
#

and you declared queue as
int queue[100][2];

coral sundial
#

yes

fervent spear
#

you may have to do

queue[back][0] = posX;
queue[back][1] = posY;

due to C not helping

#

yep, C doesn't like the first one unless you are declaring the array

coral sundial
#

mmmh

fervent spear
#

if you can do structs you can alway declare it as a vector of structs with a posX and a posY

coral sundial
#

I have acces to vectors

fervent spear
#

C vectors don't seem to change this much

timber onyx
#

@coral sundial shush arduino is perfect for hardware

#

definitely not the best

coral sundial
#

I grew out of it while not even using it...

#

AVR c master raceuuu

timber onyx
#

i mean if you arent using small project boards why even use it

#

in school i learned to use some cool industrial code languages

#

real professional stuff i tell you

#

labview beats arduino by miles

#

hell even the ISS uses labview

coral sundial
#

oh I have no doubt

#

arduino IDE is hobby code at best

#

you should move on to C as soon as you can though. the data sheets arent that intimidating anymore once you get comfortable with setting flags and banks

#

youre also closer to the hardware that way and can manipulate it to your hearts content

timber onyx
#

yeah i got to use C in one of my classes

#

honestly i loved the extra control it gives you over the small details

coral sundial
#

how to understand A*: copy someone elses code

#

it still doesnt work

fervent spear
#

how the hell are you doing A* on C

coral sundial
#

by copying his code lol

fervent spear
#

pretty memory hungry but not too bad

#

And it is pretty intuitive too.

It does kill the performance of A* but it has the advantage of not using any complex containers and finding the same path.

coral sundial
#

yeah but its not working yet on my end

#

it isnt interating past the initial 9 tiles

#

I havent fully implemented it yet though

#

I was hoping I could skip the g f and H nonsense

#

there is also this little thing where I cant use bools so I declared FALSE 0 and TRUE 1

fervent spear
#

how do you look for current node without costs?

coral sundial
#

I am not

#

thats probably why it isnt working

#

I dont know whats happening xd

fervent spear
#

what this is doing is it is marking on a 2nd matrix with a lot of data, all the neighbouring tiles as "open" and a cost to each

#

then he marks that one as visited and searches all the second matrix for the lowest cost open tile

#

then grabs that one as active and repeats

coral sundial
#

mmmh

#

He is looking for the lowest cost tile with

for(int x = 0; x < tilesX; x++)
        {
            for(int y = 0; y < tilesY; y++)
            {
                Nodes[x][y].f = Nodes[x][y].g + Nodes[x][y].h;
                if(Nodes[x][y].OnOpen)
                {
                    if(Nodes[x][y].f < lowestf)
                        {
                            currentX = x;
                            currentY = y;
                            lowestf = Nodes[x][y].f;
                        }
                }

            }
        }
        // we found it, so now put that node on the closed list
        Nodes[currentX][currentY].OnOpen = FALSE;
        Nodes[currentX][currentY].OnClose = TRUE;

I changed the code a bit

#

right?

fervent spear
#

yes

#

if you do that without costs you will have a weird DFS, which will make a weirdest path, but should work

#

you also have to decide if you allow diagonals or not

coral sundial
#

Oh I copied the calculations now too

#

but its not going past the initial 9 tiles. atleast its not drawing past them.

#

because I dont fully understand where he selected the tile

#

or do I?

#

its in the function I just copied

fervent spear
#

problem with that is that he doesn't seem to reset lowestf, and f will be increasing trough the nodes.

#

try adding int lowestf=10000; above that code

coral sundial
#

right under the while loop?

fervent spear
#

yes

coral sundial
#

so I am having an issue. what its supposed to do is make the active tile a value of 3. I did that by adding a line of code right underneath putting it on the closed list

#

I am also just constantly trying to calculate the same path

#

should I make it run once by pressing space?

fervent spear
#

Not quite getting you here

#

should I make it run once by pressing space?
advance one step?

coral sundial
#

its in my game loop, so its constantly called upon with the same values

#

so once its finished finding a path, it does the rest

#

then goes back into the loop and does it again

#

but that shouldnt matter

#

because its changing the tiles in the while(!Nodes[currentX][currentY].OnClose) loop

fervent spear
#

that loop has the wrong entrance condition now that i look at it

coral sundial
#

oh right

#

it should exit when its on a closed tile?

fervent spear
#

it should exit when it's finished

coral sundial
#

xD

fervent spear
#

change it for
(currentX!=endx || currenty!=endy)

drifting hornet
#

What is OnClose?

fervent spear
#

it is a propierty of the tile that marks it as closed

coral sundial
#

onclosed

fervent spear
#

not ready to visit or already visited

drifting hornet
#

So wouldn't you rather call it closed or is_closed?

coral sundial
#

I noticed it when I was typing away

#

have yet to replace all

fervent spear
#

it is meant to simulate a list

#

and the program moves tiles from the closed list to the open and then back

coral sundial
#

it crashed

#

progress

#

๐Ÿ‘

fervent spear
#

now it is running

#

probablly too much

drifting hornet
#

That seems way more complicated than the usual implementation I see.

coral sundial
#

it probably checks outside the array?

#

its a c implementation

fervent spear
#

the thing is that it doesn't use queues

drifting hornet
#

Can somebody link me the source? It's hard to get an idea of what is going on.

fervent spear
#

because, well, C doesn't have tehm

drifting hornet
#

Wait, what?

#

No, your source. Not some blog.

coral sundial
#

oh you got it from the blog

fervent spear
#

the one on the forum has several bugs

drifting hornet
#

Source code.

coral sundial
#

message too long

drifting hornet
#

Okay, cool.

coral sundial
#
int STAR(int StartX, int StartY, int EndX, int EndY)
{

    int currentX = StartX;
    int currentY = StartY;
    int lowestf = 1000;

    Nodes[StartX][StartY].OnOpen = TRUE;

    while(currentX!=EndX || currentY!=EndY)
    {
        int lowestf = 1000;

        //look for lowest F cost node on open list - this becomes the current node
        for(int x = 0; x < tilesX; x++)
        {
            for(int y = 0; y < tilesY; y++)
            {
                Nodes[x][y].f = Nodes[x][y].g + Nodes[x][y].h;
                if(Nodes[x][y].OnOpen)
                {
                    if(Nodes[x][y].f < lowestf)
                        {
                            currentX = x;
                            currentY = y;
                            lowestf = Nodes[x][y].f;

                        }
                }

            }
        }
        // we found it, so now put that node on the closed list
        Nodes[currentX][currentY].OnOpen = FALSE;
        Nodes[currentX][currentY].OnClose = TRUE;
        Nodes[currentX][currentY].tile = 3;
#
for(int dx = -1; dx <= 1; dx++)
        {
            for(int dy= -1; dy <= 1; dy++)
            {
                if(!Nodes[currentX+dx][currentY+dy].OnOpen)//its not on the open list
                {
                    //add to open list
                    Nodes[currentX+dx][currentY+dy].OnOpen = TRUE;
                    Nodes[currentX+dx][currentY+dy].OnOpen = FALSE;
                    //CHANGE TILE TYPE TO 3


                    if(dx!=0 && dy!=0)
                    {
                        Nodes[currentX+dx][currentY+dy].g = 14;// diagonals cost 14
                    }
                    else
                    {
                        Nodes[currentX+dx][currentY+dy].g = 10;// straights cost 10
                    }
                    Nodes[currentX+dx][currentY+dy].h = abs(EndX-currentX+dy + EndY-currentY+dy) * 10;

                }
                else //its on the open list
                {
                    //CHANGE TILE TYPE TO 3

                    if(dx==0 || dy==0) // if its not a diagonal
                    {
                        if(Nodes[currentX+dx][currentY+dy].g!=10) //and it was previously
                            {
                                Nodes[currentX+dx][currentY+dy].g = 10; // straight score 10
                                Nodes[currentX+dx][currentY+dy].h = abs(EndX-currentX+dy + EndY-currentY+dy) * 10;
                                Nodes[currentX+dx][currentY+dy].f = Nodes[currentX+dx][currentY+dy].g + Nodes[currentX+dx][currentY+dy].h;


                            }
                    }



                }
            }
        }

    }
    return 0;
}
drifting hornet
#

Wait what?

coral sundial
#

I havent added parents

drifting hornet
#

Where is Nodes first declared?

coral sundial
#
{
    int tile;

    int OnOpen;
    int OnClose;
    int f;
    int g;
    int h;

} Nodes[25][25];```
fervent spear
#

Global matrix of structs

drifting hornet
#

Okay, thanks.

#

I'd recommend passing it in by the way.

coral sundial
#

yeah I hate global variables

#

but I wanted to figure out A* not passing a 2d array

drifting hornet
#

It would have been like ten extra characters.

coral sundial
#

ssh

drifting hornet
#

Regardless, I have a few questions about the struct.

#

So I know what's going on.

fervent spear
#

it is C, you have to unreference at every step

#

so one character per time Nodes is used

drifting hornet
#

I am familiar. I've written C and C++ for almost ten years.

#
struct Node
{
    int tile; // Is this the index into the map, tile ID, type of tile?

    int OnOpen;
    int OnClose;
    int f; // This is F-Cost?
    int g; // G-cost?
    int h; // H-cost?

} Nodes[25][25];
coral sundial
#

yes to all

drifting hornet
#

Thanks.

coral sundial
#

tile 1 is a grass tile. tile 3 is just nothing

drifting hornet
#

Does nothing also mean solid?

coral sundial
#

I havent added that yet

#

I am more concerned about that its crashing

drifting hornet
#

And these must be more globals, right?
tilesX, tilesY
They are the width and height of the map in tiles?

coral sundial
#

yes

drifting hornet
#

To save me some time, do you get any debug information like where the crash occurs or is it just a silent segfault?

coral sundial
#

I'd have to look into the debug mode first...

#

it probably happens upon running a star

#

I could add a button before running it

drifting hornet
#

So what is the value of tilesX and tilesY? 25 and 25?

fervent spear
#

what happens if you look outside the array?

drifting hornet
#

I'd expect a crash.

fervent spear
#

the code doesn't controll that

coral sundial
#

yeah I'd expect that as well

fervent spear
#

as in, it looks everywhere

coral sundial
#

so I'd have to add in a check

fervent spear
#

yup

drifting hornet
#

Okay.

#

I found an issue.

coral sundial
#

ive done that in the past with a simple array and a pointer comparing it to the memory adress

drifting hornet
#

In this loop here.

#
for(int dx = -1; dx <= 1; dx++)
        {
            for(int dy= -1; dy <= 1; dy++)
            {
                if(!Nodes[currentX+dx][currentY+dy].OnOpen)//its not on the open list
                {

#

You aren't bounds checking.

#

Let's say currentX and currentY is zero.

#

That means you'll be indexing -1, -1 at some point.

#

And a few other outside-bounds indices as well.

fervent spear
#

I guess you can use memory directions to check that

coral sundial
#

I used memory at the time because I didnt know what to compare it too. and it was for selecting a menu.

fervent spear
#

I would do it by ensuing the coordenates are between 0 and 24

coral sundial
#

but I have to check for X,Y smaller than 0 and bigger than 25,25 (oh)

#

:V

drifting hornet
#

What???

#

Dyno is retarded.

#

What does that even mean? "No spoilers allowed."

fervent spear
#

it is so mods don't have to click everything

drifting hornet
#

I didn't even put any spoilers in?

#

Unbelievable.

#

I'll try again.

coral sundial
#

I think some C syntax are spoilers in discord

#

put it in a code block

fervent spear
#

it is ||

drifting hornet
#

Ah. I'll just write or

#
int nx = currentX + dx;
int ny = currentY + dy;

if nx < 0 or nx >= tilesX or ny < 0 or ny >= tilesY {
  continue;
}
#

This ensures you don't process any tiles that are out of bounds.

fervent spear
#

if it is equal it will still be out of bounds

drifting hornet
#

Yes. I wrote >=.

fervent spear
#

so you will be allowing the reference Nodes[25][25]

drifting hornet
#

That snippet skips the current iteration of the inner loop.

#

No I won't.

#

If nx == 25 or ny == 25, it will skip.

fervent spear
#

yes, My Bad

drifting hornet
#

We only want the interval [0, 25).

coral sundial
#

where do I check for out of bounds? I am not updating any values dx, dy except for the two nested for loops

fervent spear
#

at the start of every inner loop

drifting hornet
#

Let me integrate it in then.

long raft
#

for optimization sake, youd calculate startx and endx, and starty and endy before the loop, and not introduce an extra branch inside every iteration of the loop

coral sundial
#

optimization comes later

long raft
#

even for debugging

drifting hornet
#

Also you want parenthesis around predicate in the if.

#

I've been writing Rust for a while so I forgot.

long raft
#

you guys are mandatory curly brace people huh? even for a single continue statement? he_cry

coral sundial
#

I will have to update NX and NY before the if statement inside the inner loop?

fervent spear
#

@long raft are you talking the whole program or this snippet?

long raft
#

in general

drifting hornet
#

Is this in C or C++? I'm curious to know before I type something.

fervent spear
#

not the curly things, the endx, startx

coral sundial
#

C

long raft
#

oh, yes thats in general too. as a rule of thumb dont add extra calculations per iteration

coral sundial
#

I need to upgrade to c++ -_-

#

I know

long raft
#

and it will make it harder to debug that particular line, in my opinion

fervent spear
#

I mean, the program already has a EndX so i was confused

long raft
#

if statements are more costly than people generally expect, and i mostly bring it up because its C

fervent spear
#

and how do you skip the middle tile then Derp?

long raft
#

oh i just mean precalculate the domain of the for loop, dont check bounds inside the loop

#

oh i guess for readable code, in that case you would put in the if statement

fervent spear
#

the domain is not a linear memory portion

long raft
#

but for bounds checking, you dont need to do that in the loop itself

drifting hornet
#

F

coral sundial
#

RIP

#

I got it myself I think

fervent spear
#

if you calculate it from directions general indexs or memory positions won't help

coral sundial
#

I need to add it to the first nested if loop

drifting hornet
#
for(int dx = -1; dx <= 1; dx++)
{
    for(int dy= -1; dy <= 1; dy++)
    {
        // Shorthand relative coordinates.
        int nx = currentX + dx;
        int ny = currentY + dy;

        if (nx < 0 or nx >= tilesX or ny < 0 or ny >= tilesY) {
            continue;
        }

        if(!Nodes[nx][nx].OnOpen) //its not on the open list
        {
            //add to open list
            Nodes[nx][nx].OnOpen = TRUE;
            Nodes[ny][ny].OnOpen = FALSE;
            //CHANGE TILE TYPE TO 3


            if(dx!=0 && dy!=0)
            {
                Nodes[nx][ny].g = 14;// diagonals cost 14
            }
            else
            {
                Nodes[nx][ny].g = 10;// straights cost 10
            }
            Nodes[nx][ny].h = abs(EndX-currentX+dy + EndY-currentY+dy) * 10;

        }
        else //its on the open list
        {
            //CHANGE TILE TYPE TO 3

            if(dx==0 || dy==0) // if its not a diagonal
            {
                if(Nodes[nx][ny].g!=10) //and it was previously
                {
                    Nodes[nx][ny].g = 10; // straight score 10
                    Nodes[nx][ny].h = abs(EndX-currentX+dy + EndY-currentY+dy) * 10;
                    Nodes[nx][ny].f = Nodes[nx][ny].g + Nodes[nx][ny].h;
                }
            }
        }
    }
}
#

Change or to ||.

coral sundial
#

you only added it while looking for an active tile?

fervent spear
#

maybe i'm not understanding you @long raft , can you write a small loop that gets all 8 tiles surounding a tile i,j with your optimitzation?.

long raft
#

so where you have dx = -1 as the starting index, you would calculate just once where it's safe to start. It might be 0 instead of -1, and you do the same for the upper bounds

coral sundial
#

๐Ÿ˜ฑ

#

it still crashes

fervent spear
#

so check if the starting tile is in a corner before checking everything else

coral sundial
#

code did work right out of the bat

long raft
#

ya basically. you can do it later, its not a big deal

fervent spear
#

got you

coral sundial
#

this is some serious headcracking

fervent spear
#

same crash?

coral sundial
#

crashes right as I run the algorithm

long raft
#

what kind of crash

coral sundial
#

freezes

long raft
#

like stuck in the loop?

coral sundial
#

I think so

long raft
#

can you break and see where it is?

coral sundial
#

well YES

#

great idea

#
        {
            for(int y = 0; y < tilesY; y++)
            {


                        Nodes[x][y].f = Nodes[x][y].g + Nodes[x][y].h;
                        if(Nodes[x][y].OnOpen)
                        {
                            if(Nodes[x][y].f < lowestf)
                            {
                                currentX = x;
                                currentY = y;
                                lowestf = Nodes[x][y].f;
                                break;

                            }
                        }


            }
        }```
#

doesnt check out of bounds here

#

and it crashes

fervent spear
#

that loop can't go out of bounds.

#

Is Nodes initialized?

coral sundial
#

its global

fervent spear
#

Is it initialized?

coral sundial
#
    for(int row = 0; row < tilesX; row++)
    {
        for(int collumn = 0; collumn < tilesY; collumn++)
        {
            Nodes[row][collumn].tile = 1;
            Nodes[row][collumn].OnOpen = FALSE;
            Nodes[row][collumn].OnClose = FALSE;
            Nodes[row][collumn].f = 0;
            Nodes[row][collumn].g = 0;
            Nodes[row][collumn].h = 0;
        }

    }
long raft
#

so tilesX and tilesY can exceed the array size maybe?

drifting hornet
#

column* >:)

fervent spear
#

If you run that, it should be initialized

long raft
#

waaaait

#

did you swap row and column around?

coral sundial
#

does it matter, row and collumn are 25

long raft
#

shouldnt it be Nodes[collumn][row]?

#

oh.

#

err nah its fine the variables are just named backwards

fervent spear
coral sundial
#

yes

fervent spear
#

that accesses to Nodes[nx][nx]

coral sundial
#

but it doesnt crash there? it crashes at the first for loop

long raft
#

my C balls itch when i see

if(dx!=0 && dy!=0)
            {
                Nodes[nx][ny].g = 14;// diagonals cost 14
            }
            else
            {
                Nodes[nx][ny].g = 10;// straights cost 10
            }

instead of

Nodes[nx][ny].y = dx!=0 && dy!=0 ? 14 : 10;
burnt trellis
#

What's the error?

#

Or no error, it crashes u say.

coral sundial
#

it doesnt throw anything into the console

#

it freezes, excuse me

#

thats probably a big difference

fervent spear
#

so you stopped it one time and it was in the first loop

coral sundial
#

yeah

fervent spear
#

that could mean it is repeating the whole loop

coral sundial
#

actually, it breaks right into the first for loop

long raft
#

i think if you put a break after the loop you will see that it completes it

coral sundial
#
    while(currentX!=EndX || currentY!=EndY)
    {

        int lowestf = 1000;

        //look for lowest F cost node on open list - this becomes the current node
        for(int x = 0; x < tilesX; x++)
        {
            break;
long raft
#

oh what!

coral sundial
#

it freezes before that break;

long raft
#

do you mean for break to escape the while loop? because break will exit the for

coral sundial
#

breaking the while loop actually works

long raft
#

ive never understood why languages dont include something like break 2; to break out of 2 loops

#

but if you write break inside a for loop, it will not break out of the while loop

coral sundial
#

fair

#

then it goes back into the for loop?

long raft
#

it breaks the for, it goes back into the while loop, which has the same conditions

#

so uhh when i said break, i meant use a debugger break, to pause it

#

not the actual break command

coral sundial
#

๐Ÿ™ˆ

long raft
#

if you dont have a debugger you can break, just use output messages somewhere, console or log or whatever to confirm it gets to places

burnt trellis
#

What's tilesX's value?

fervent spear
#

you don't want to use break commands in those loops anyway, it is a search

coral sundial
#

25

#
const int tilesY = 25;```
burnt trellis
#

Since it freezes, that while loop must keep going forever. How's CurrentX and CurrentY being updated?

coral sundial
#

You know I really appreciated you all trying to fix ''my'' code but I really want to sleep.

#

I might as well learn proper c++ tommorow xD

fervent spear
#

and use a queue to do a neat BFS

long raft
#

whats wrong with C?

coral sundial
#

nothing

#

it just that some things work better in c++??

fervent spear
#

c++ has a lot of things that make your life easier IMO

coral sundial
#

besides that, I dont know why I use a* anyway. a BFS works fine as well. when I sleep on it I can probably get my brain around it better tommorow

#

because today was just a wtf day

long raft
#

i think its just a predictable performance thing

#

for real time use

timber onyx
#

i have no idea why you'd need to use C other than in applications where every bit of memory is needed

#

or if you're just old idk

long raft
#

im no fan, but C is the most important language on earth

burnt trellis
#

C is dope and a great stepping stone for Cpp which can be awesome if used properly

rugged cape
#

beep boop

coral sundial
#
int STAR(int StartX, int StartY, int EndX, int EndY)
{



    int CurrentX = StartX;
    int CurrentY = StartY;


    while(CurrentX!=EndX || CurrentY!=EndY)
    {
        //find an open tile
        for(int x = 0; x < tilesX; x++)
        {
            for(int y = 0; y < tilesY; y++)
            {
                if(Nodes[x][y].OnOpen == TRUE)
                {
                    CurrentX = x;
                    CurrentY = y;

                }//if open tile
            }//for2
        }//for 1
        //open tile is found, now close it
        Nodes[CurrentX][CurrentY].OnOpen = FALSE;
        Nodes[CurrentX][CurrentY].OnClose = TRUE;

        //check all tiles around the current tile
        for(int dx = -1; dx <= 1; dx++)
        {
            for(int dy= -1; dy <= 1; dy++)
            {
                if(TRUE)//check for out of bounds... how?
                {
                        if(Nodes[CurrentX + dx][CurrentY + dy].OnClose == FALSE)
                        {
                            //open that tile if its not closed.
                           Nodes[CurrentX + dx][CurrentY + dy].OnOpen = TRUE;
                            //switch the texture to ''open''
                           Nodes[CurrentX + dx][CurrentY + dy].Tile = 3;
                        }
                        else
                        {
                            //its closed, dont check it.
                        }
                        
                }
            }//for2

        }//for1



    }//while




    return 0;
}
#

pathfinding attempt #2

#

currently stuck for how to check its not going of the grid

#

I also realize this algorithm is biased for finding a path toward the lower right corner. problem for another day

coral sundial
barren quarry
#

this looks like a dick

coral sundial
#

shut the fuck up kas

coral sundial
#

huh it actually works

#

but it crashes when it finds the target

coral sundial
#

no it works

#

I didnt change a thing lol

kind glacier
long raft
#

TheEvilChild when you git rebase and squash to the first commit and force push

orchid needle
#

@coral sundial

int w = dx+CurrentX;  // the column
if ((v>0) && (v<tilesY) && (w>0) && (w<tilesX))
{
    
}```

if you want to check the bounds
random plank
#

\

oblique flint
#

Is anyone here still writing in pure C?

#

I like objective languages but. C is just C fun to code.

coral sundial
#

I code C!

#

because I dont know any other languange

fervent spear
#

I code in C too often for my taste

coral sundial
#

I like being masochistic

coral sundial
#

interesting behaviour. it tries to construct a path through an obstructed tile. even though that tile cant have a parent or someone linking to it

#

I dont know what the hell is happening on the left to be honest

#

okay I get it. the left path is the correct path. but when it reaches an obstructed tile its parent is suddenly way up there

amber sail
#

Can anyone here help me with Unreal Engine?

#

It has to do with assets

#

I was wondering if anyone knows how to make cook an asset but it comes out only as a .uasset file

#

not with a .ubulk and .uexp file

#

I believe those are called dependencies and its really annoying me

orchid needle
#

@amber sail why do you need to package the files together?

.uasset = header information
.ubulk = data that can loaded into memory using level streaming
.uexp = data that is loaded into memory when a level is started

They're organized in a .pak in a way that facilitates more optimized loading speeds.

amber sail
#

@orchid needle I need them packaged together because that's how foxhole packages theirs

#

Is it possible?

orchid needle
#

Oh interesting. Perhaps look into using UE3; a brief google search tells me you could cook the assets either into one file or separately using it and that the .ubulk data is located after the header & non-streamed data

amber sail
#

Hmmm I'm not sure how well that would work

#

Because Foxhole is in UE4

#

And I don't know of a way to convert the textures afterward

orchid needle
#

Why not ask the guy behind the sound mod

amber sail
#

I have but i just asked him another question

#

It takes some time for him to respond

orchid needle
#

Is it like family guy

#

"everybody gets one"

amber sail
#

wdym?

orchid needle
#

The spiderman thing? I dunno nvm xD

amber sail
#

lol

#

But yeah i have been in touch with him

#

He was the one who helped me get this far

#

but ive run into this issue

#

which is the last think i need to fix and then textures in foxhole galore

orchid needle
#

Are you cooking it through the editor ui or frontend/commandlet?

amber sail
#

@orchid needle I believe the UI

#

would the commandlet work better

orchid needle
#

Just wondering if there's command line params for it

amber sail
#

@native kernel Still looking for Dev assistance. No rush, but if any of you guys could tell me how you guys cook your textures it would make my day.

barren quarry
#

tfw you try to output an image file into a url field and it outputs the whole file as string

languid harness
#

nice

ember matrix
#

Numbers, many numbers. Hypnotizing.

whole gust
#

Spot two same numbers

coral sundial
#

@barren quarry is that a string of coordinates

barren quarry
#

@coral sundial its an image file

#

buffer or something

coral sundial
#

I am too drunk to think straight

#

lets be honest

#

OHHHHHHH

#

those are binary values of the color?

barren quarry
#

could be

orchid needle
#

Common low/average fidelity image formats are encoded as a series of 8-bit numbers, and their ordering corresponds to what channel they pertain to (red, green, blue, alpha, cyan, magenta, yellow, black, etc). Most images used on the web are also encoded for compression, using a variety of discrete transformations. If you're keen on the topic, you can look up DCT, DWT, EZW and see how some images might be stored and why reading some image file formats isn't as easy as pulling out pixel-by-pixel values

long raft
#

looks like a byte array โœ…

orchid needle
#

^ it looks like a byte array ye. If you want to check if it's decoded you can see if it has jfif markers at the beginning if you think it might be jpeg format, or just try rendering it xD

hoary dune
#

tfw you try to output an image file into a url field and it outputs the whole file as string
@barren quarry you're in the matrix now

#

was she wearing a red dress?

timber onyx
#

Im surprised that it outputs in decimal and not hexadecimal

long raft
#

much easier to parse decimal

#

javascript always does whats easier

hoary dune
#

except dates

#

๐Ÿ˜‚

#

I absolutely hate working with dates and timezones in javascript

scenic river
#

Are there languages where dates and times don't suck?

hoary dune
#

and formats*

languid harness
#

They always suck because every language does it different and messes with your brain @scenic river

#

I dont even think about programming times, because half the time it all is just extra work

#

Like, I used a Python library to get the time difference in a set of measurements (read: the test took a minute or two, but the counter did a hour:min:sec format). As not to have to write an annoying piece of code translating all the minutes into seconds, I thought being smart interperting it as datetime format. Except I had to add years months days to it, and had to do a lot of formatting crap and, jn the long run, it def was not worth it

#

And I got the luck all the data was in the same format

#

The biggest struggle is working with dates originally from a excel worksheet, as sometimes it preinteperts things as time stamps and reformats them, but not all of them

#

Date formats just suck

hoary dune
#

I make scripts for a browser game

#

and they need to work on different markets, some have the month before the day, some after, other languages... regex can only do so much lmao

coral sundial
#
    //define current x and y.
    //create queue for current x and y
    //create a priority queue.
    //calculate Fcost for starting node. starting G cost is 10 + calculate H cost form start to finish.
    //add start to queue
    
    //while(CurrentX != End.x || CurrentY != End.y)
    //get current X and Y from priority queue
        //empty? get current x and y from open queue
        //empty? return FALSE. path found or no more valid nodes;
        
    //for current X and Y calculate F cost. = get F cost.
        
            //check if neighbour is out of bounds.
                //for neighbours calculate F cost.
                //do not visit if visited. do not check if not walkable.
                    //set parents for neighbour.
                    //calculate neighbours fcost.
                    //compare F cost to current cost.
                        //fcost lower than current? add to priority queue. close the visited tile.
                        //set fcost as current fcost. keep looking.
                    //fcost not lower than current?.
                        //close the visited tile. its not worth it right now.
                    //fcost equal? 
                        //add to open list. 
                        //close the visited tile?
            
                //already visited?
                    //is the  fcost equal to current?
                        //add it to the open list
                    //is the current fcost  lower?
                        //add it to the priority queue
                    //else keep it closed.
    //repeat until path found OR all tiles have been checked.
#

Okay I almost capable of making an A star pathfinder

#

I need someone to see if this plan is correct

#

oh I see things might go wrong with the equal f cost. if it updates and its better it wont be removed from the open queue

#

maybe I should take a step back and make it find the cheapest tile every time. not entirely optimized I guess

long raft
#

c# is pretty good with dates and time zones

#

no complaints at all

barren quarry
#

.toISOString()

#

lul

hoary dune
#

if only that was so easy

#

in my example, I have to parse the date from a website, and they don't keep the date in the DOM. It gets passed along from the server, but doing a request to the server to get the current server time, returns local time, rather than the correct server time. So the solution I had to do was parse from the damn html, and considering the site looks different on different markets/localised translations, the time formatting is different every time >_>

#

bottom left is server time ๐Ÿ˜‚

languid harness
#

oof

#

@coral sundial also, interestting choice of method, but I wonder why it has to check if it has already visited the tile, because that one should be less usefull to reach it path in all cases right?

coral sundial
#

a new path mightve been found thats cheaper

#

thats why you update it

#

but its going to cause issues I think with making a path

languid harness
#

oh, in that sens

#

I would rather try doing it without using that part

#

like in a stationary obstacle situation

#

and then try it for a moving obstacle situation

#

and then in a moving target situarion

coral sundial
#

hehe

#

no obstocles are moving

#

that means I have to update the path continuously

languid harness
#

crack

coral sundial
#

is doable

#

you just have to refind a path if for example a wall has been build

#

a* is quite fast so it isnt much of an issue

languid harness
#

but its weird to immeadtly code that

#

babysteps rem

#

babysteps

coral sundial
#

I am already past baby step

#

this is like my teenage step

languid harness
#

that is not how the concept of babysteps works

coral sundial
#

thats now how teenage steps work either

timber onyx
languid harness
#

Resistor goes into space? @timber onyx

long raft
#

what do the numbers on the diode mean, like 1,2,3,4,infinity?

#

is that a diode?

#

and if its a diode can it have negative voltage?

#

jesus its been too long since ive learned anything about electronics

coral sundial
#

Input outputs i guess

timber onyx
#

@languid harness 96.8 farats would break several laws of physics

#

@long raft itโ€™s an op-amp

long raft
timber onyx
#

The 8 pin is just sideways so it looks like an infinity

#

The program simulates actual electronic components

#
 error = goal - measure;
 summ_errors += error;
 variation_error = error - previous_error;
 command = Kp * error + Ki * summ_errors + Kd * variation_error;
 previous_error = error```
languid harness
#

oh lol, idk. I am no EE, I am ME. I see wavy line not connected to anything, I assume it doesnt count

#

Because if you remove all letters, this could go for a spring demper system with the triangle being some weird exciter

long raft
#

im learning about toeplitz matrix calculation on gpu and my head hurts

timber onyx
#

@long raft basically a PID regulator makes sure that an output that you want to reach a certain value wont do it stupidly. first it calculates the error proportionally to the goal you set, then it sums these errors to create a global error so that when the output comes close to the goal it wont slow down drastically and then it calculates the variation between the current error and the last error so that the output wont overshoot the goal too badly. it sounds a lot more complicated than it is

languid harness
#

oh PIDs! I know those! Sadly!

long raft
#

disk has a brand new pair of roller skates and turtle has a brand new key

#

we did it!!

timber onyx
#

what

#

did we break derp

long raft
#

zoomers aint get any references ree

timber onyx
#

so what are YOU learning

#

whats this toeplitz matrix doodad

long raft
#

reimplementing feed forward neural networks on gpu from scratch, not a pleasant experience

languid harness
#

Oh god feed forward. People I am trying to escape model engineering by going on discord to be repeatedly be punched in the face

long raft
#

well its the easy part of CNNs

#

but doing it without a library is an ordeal

timber onyx
#

oh noes a programmer has to do something original

languid harness
#

lol

long raft
#

not just original - math intense

#

i rather prefer working in trig, ive only had 2 classes on linear algebra and its a daunting subject

timber onyx
#

oh yeah linear algebra is annoying

#

it's one of those things where you can relearn it a million times but you'll never remember everything about it unless you use it every day

long raft
#

yea or you just use something pre-written to do it for you like a graphing calculator or library

#

my naive algorithm is slow AF

timber onyx
#

but where's the fun in that julianlol

long raft
#

ive known a lot of programmers who somehow snuck through their math work - when they find something math intense they just hack it some other way

timber onyx
#

well hey if it works it works

#

plus i know the feeling of not wanting to do the complicated way even though it might be the less time consuming one

long raft
#

more human hours, less gpu hours

long raft
#

yah @exotic chasm a commit is fine, at least we'll have the cooperation pipeline figured out that way

exotic chasm
#

@long raft Alright i think i got it after struggling a bit. Never used git or github before.

#

Should be a "pull" request or whatever

long raft
#

sure, useful learning experience; i can help if you get stuck anywhere

#

wow seems like you figured that out hella fast

#

only took me a year to learn git

exotic chasm
#

The lingo is heavy

long raft
#

yea its rough

coral sundial
#

oh shit my A* found a path

long raft
#

we need a real javascript/nodejs wiz chad that i could just make demands on

#

trying not to learn node while just making a million small changes is frustrating

long raft
frozen oriole
#

foxhole in-game GPS when

neat fossil
#

Is code as hard as it seems?

#

You people seem like superior beigns from outside

woven plover
#

Well, it depends on the type of code. Python is an easy one compared to Java being a hard one. So it really depends on what you want to accomplish.

languid harness
#

Python3 gang!

frozen oriole
#

Boolean logic gang!

coral sundial
#

C gang

#

C is by far the easiest to learn but you cant do much fancy stuff with it.

#

easy to learn impossible to master

frozen oriole
#

Boolean logic is by far the most simple but also the most complicated programming system

#

sounds simple, stuff can be on or off

coral sundial
#

untill you write a path finding algorithm xD

frozen oriole
#

but when you get into it, you catch some of these headaches

#

exactly

languid harness
#

I think C and Python are both easy, depending how familiar you are already with programming

stuck moon
#

Imo every programmer should learn C so that they can better their understanding of how computers function at the bare metal. Most other languages under all the abstractions will always end up calling code compiled from C or C++.

fervent spear
#

The same could be argued for assembler

stuck moon
#

That knowledge doesn't hurt either, sometimes you need to step through the dissassembled code to discover some hidden gotchas that the compiler gave you. Also a requirement if you want to get into programming emulators.

rain gazelle
coral sundial
#

you have a pointer to the first element of A, + (b modulus 8)

#

if I read this correct

#

the more important questions is, what is your code supposed to do?

long raft
#

32 % 8 = 0
and a + 0 = a, so +(b%8) does nothing

#

so it prints out a[0] which is 9

#

and it makes coffee

orchid needle
#

int a[] = {9, 8, 7, 6, 5, 4, 3, 2, 1};

This line declares and defines an array of a complete type 'int' (incomplete types such as 'void' or classes without a definition cannot be declared in this way - you'd need to derive a pointer instead) and initializes it using a brace-enclosed list.

int b = 32;

This line declares and defines an integer, and initializes it to the rvalue 32 (value categories are a different topic but I suggest you try to understand them as well).

printf("%d", *(a + (b % 8)));

Operators such as +, %, and * are special names for built-in functions (addition, modulo, multiplication/indirection respectively). In this case, * is being used as a function with a single parameter that corresponds to the unary dereferencing operator overload. * a, a*b, a?b:c are examples of the * and ?: operators and use their associated unary, binary, and ternary functions according to the parameters supplied next to their symbols.

I suggest you look at https://en.cppreference.com/w/cpp/language/operator_precedence if you want to understand more about what each operator does and in what order.

#

@rain gazelle

#

But yeah, as was already said: 32 % 8 resolves to 0, is added to a (an array) which returns a pointer of that array's type (int*) at that offset (in this case, 0, so the first element in the array), and returns the value at that memory address using the indirection/dereferencing operator which the printf functions attempts to parse as a decimal signed integer value

stuck moon
#

don't do his homework

coral sundial
#

Ya'll

#

I made a working a star in c

#

๐Ÿ˜›

#

took me only like 4 weeks

orchid needle
#

Understanding the semantics of array indirection shouldn't qualify as comp sci homework. Important part is understanding that arrays are just consecutive memory addresses that you can perform arithmetic on.

#

Also grats rem xD

coral sundial
#

thaaanks xD

#

at this point I am just coding c++ but with my own additions instead of standard c++... queue's, lists... constructors deconstructors. coded it all myself xD

#

I still have to write a function to clean up constructed lists. I am pretty sure if I dont do that I have a memory leak there

#

with coded myself, I mean half pasted from the internet

orchid needle
#

What makes you pretty sure and not 100% sure :o

coral sundial
#

the fact that ive never had to take that into mind xD

#

I also tried listing all out points but I dont see the list increasing. but this could be due to the fact that each time the algoritm runs a new list with a new adress is made

orchid needle
#

do you have this on a repository somewhere, I'd be really interested to look at it xD

coral sundial
#

Never worked with repositories

#

but its all in its own file

#

I mean almost all

#

the entire thing runs on raylib. I have main.c where I call all functions from. then a pathfinding.c and a list.c and then a header for the structs

#

oh

#

but I can give you a main where I tested the lists

orchid needle
#

sure ;o

coral sundial
#

Ididnt code half of it now that I look back on it. I made some modifications to popnode so it returns data instead of deleting the node

#

and the printlist function is almost entirely mine

#

If I only knew how double pointers work

#

and now that I think about it. I could modify print list to delete every need it goes over.

orchid needle
#

you only return data from the popped node if the head is the popped node?

coral sundial
#

Yep

#

I only need to pop the head node so far

#

Since the important nodes are pushed infront they get popped first

#

Now for an optimization i could indeed look for the lowest fcost node in the list and pop that one

orchid needle
#

do you call pushLast often?

coral sundial
#

Only when the fcost is higher than that of the current node

orchid needle
#

I would wrap this up in another container and keep track of the head, so that you don't need to traverse the list over and over

#
    { ... } ```
coral sundial
#

Oh mmh

#

Yeah that would make it even faster

orchid needle
#

and if you made that container (i.e a list, and had the current 'list' struct become a 'node' struct) you could move those functions to be static member functions

#

and then you could template them so the data isn't limited to being int

coral sundial
#

Yeha so where i copied to code from initially they had a generic linked list

#

But i wanted to try and imitate it rather than copy

orchid needle
#

and the int array[5] declaration doesn't need to have an explicit length, the aggregate initializer sets it anyways

#

other than that nice ^^

coral sundial
#

So i took a bit of a cut and made int for now

orchid needle
#

ahhh

#

good way to learn for sure, to make it from scratch

coral sundial
#

I ended up copying anyway from different sources haha

#

The ** still confuses me

orchid needle
#

a pointer to a pointer ;o?

coral sundial
#

**head is a pointer to a pointer for the first node, which gets its adress passed

#

Which i dont really understand what a double pointer does in this case

orchid needle
#

so the address of the pointer to the first node is passed in as an argument to the first parameter of a lot of the functions

#

I guess the best way to think about it

#

is if there was no second asterisk

coral sundial
#

Mmmh

orchid needle
#

you'd be passing a copy of the pointer, and the original remains unmodified

coral sundial
#

I bet it has something to with the that the list is also a pointer

#

Is there a concept behind this i can google tommorow?

#

Like pass by value or something

orchid needle
#

Passing references to pointers

coral sundial
#

Aha thanks

#

I am going to bed now haha

#

Thanks for the explanation

fervent spear
#

Oh wow, you made your list with pointers, neat

orchid needle
#

no problem ^^ gn

orchid needle
#

also if you look back here later, for more insight into why it's necessary:
*node = new_list;
If you simply did node = new_list and didn't have a ** to the list type, then this line:
push(&start, 10);
would look more like
push(start, 10);
but start wouldn't have changed within that scope so subsequent calls to the push functions wouldn't be doing anything. Your PrintList function doesn't care since it doesn't care to make changes to start and have those changes be reflected in code outside of the function's scope

barren quarry
#

fuck pointers

#

i still don't understand what it is

rain gazelle
#

@coral sundial @long raft @orchid needle thanks for the replies bois it had been a while since I wrote some c language but I get it now thanks to all of you

stuck moon
#

@coral sundial you should totally put your code in repositories. You can rollback code in case you screw up or need an earlier version and you can easily share and collaborate with others. Also if you're doing a lot of these hobby projects the repositories can serve as your portfolio.

#

good to start now imo ๐Ÿ‘

coral sundial
#

fortunately I dont ever want to be a software engineer xD

barren quarry
#

being a software engineer requires a god complex with a side of being fucked in the head a bit

#

fortunately i have both

coral sundial
#

I mean, same

#

but Ive decided on mechatronics

languid harness
#

And you think you will never have to program in in mechatronics? Ha!

coral sundial
#

to be honest

#

I am not even sure

neat fossil
#

hey guys

#

/print (Hello world)

#

Just gonna leave that therr

coral sundial
#

dont know in which code languange that would work

#

python?

kind glacier
#

ngl I often forget the correct syntax and use the syntax error to constantly remind me

print('Hello world')
#

Or Google. Google works too.```cs
Console.WriteLine('Hello world')
#this code color thing is kinda cool but also a tad limited

coral sundial
#

isnt python syntax pretty straightforward?

stuck moon
#

mechatronics is dope

#

idk what other professions do on the job but I can imagine that you may need to do C

long raft
#

mmm somebody must have wrote some c#, my derp sense is tingling

languid harness
#

@coral sundial yeah, that would work in Py without the slash