|
Post by n00b on Jun 21, 2017 11:55:28 GMT -6
I made a huge update video just going over whats going on right now. Check it out here: RCBASIC UPDATE
|
|
|
Post by eyfenna on Jun 24, 2017 11:34:34 GMT -6
Matrix operations sounds nice ... does this mean a lot of geometrical vector calculations are available?
Little wish an implemented atan2 function.
|
|
|
Post by n00b on Jun 24, 2017 12:35:34 GMT -6
I am going to be adding that along with several more functions. Also, I didn't mention this in the video but I am going to be adding an updated version of 2.0.8 as soon as I get it compiled. I am releasing a new installer for linux which should work with any distro that uses apt. The update is using the latest versions of the dependency libraries.
|
|
|
Post by eyfenna on Jul 2, 2017 8:51:47 GMT -6
I am going to be adding that along with several more functions. Also, I didn't mention this in the video but I am going to be adding an updated version of 2.0.8 as soon as I get it compiled. I am releasing a new installer for linux which should work with any distro that uses apt. The update is using the latest versions of the dependency libraries. I sort of currently have the idea that adding something like "enum class" called "adjective" to RCBasic would be worthwhile. They are similar to an array creating them goes like adj C[5]
this creates an adjectives with 5 types, initialising a type goes like: set C[0] = "apple" set C[1] = "orange"
initialising must happen after creation and can only happen once ... okay needs a better syntax. A variables holding one version of all possible within in adjective can be spawned based on an adjective C var! = C:"apple"
or C var! = C[0] let's say there is "apple", "cherry", "orange", strawberry" and "peach" in the adjective C then var! can only be "apple" or "cherry" or "orange" or "strawberry" or "peach", never two or more than one. It can be reset: var! = C[0] 'now it's apple' if(var! != C:"apple") FPritn("This is not an apple") end if 'will not print' var! = C:"orange" 'now it's orange' if(var! != C:"apple") FPritn("This is not an apple") end if 'will print'
this variable can be printed out directly Fprint(var!) prints: 1 this variable can be compared to the adjective they are spawned from if(var! == C[1]) fprint("true") end if
either this way or in a second variant: if(var! == C:"orange") fprint("true") end if
both print true in console. and used in select case: select case (var!) case C[0] fprint("this will not print") case C:"apple" fprint("this will also not print") case C[1] fprint("this will print") Default fprint("not going to print") Would be usefull for defining gamestates with following example showing how this would be done in code before the introduction of "adjectives": Engine = 0 GameStates = 0
WINDOWOPEN ( 0, "TEST WINDOW", 100, 100, 640, 480, 0 ) CanvasOpen ( 0, 640, 480, 0, 0, 640, 480, 1 ) x1 = 0 x2 = 50
while(Engine = 0)
if(GameStates = 0) then if(Key(K_BACKSPACE)) then GameStates = 2 elseif(Key(K_ESCAPE)) then Engine = 1 end if
'Draw no filled box' canvas(0) update() elseif(GameStates = 1) then if(key(K_BACKSPACE))then GameStates = 2 elseif(Key(K_ESCAPE)) then Engine = 1 end if
setColor(RGB(0,0,255)) canvas(0) clearcanvas() BoxFill (x1, 150, x2, 200) update()
elseif(GameStates = 2) then
if(key(K_BACKSPACE)) then GameStates = 1 elseif(Key(K_ESCAPE)) then Engine = 1 end if x0 = 0 h0 = 0 GetCanvasSize (x0,h0) fprint(x0) if (x2 > x0) then x1 = 0 x2 = 50 end if clearcanvas() x1 = x1 +1 x2 = x2 +1 setColor(RGB(0,255,0)) canvas(0) BoxFill (x1, 150, x2, 200) update()
end if
wend and after introduction of "adjectives" adj ONOFF[2]
set ONOFF[0] = "ON" set ONOFF[1] = "OFF"
ONOFF engine = ONOFF:"ON"
adj STATES[4] set STATES[0] = "GAMEOVER" set STATES[1] = "GAMEMENU" set STATES[2] = "PLAYING" set STATES[3] = "PAUSING"
STATES currentState! = STATES:"GAMEOVER"
WINDOWOPEN ( 0, "TEST WINDOW", 100, 100, 640, 480, 0 ) CanvasOpen ( 0, 640, 480, 0, 0, 640, 480, 1 ) x1 = 0 x2 = 50
while(engine = ONOFF:"ON")
if(currentState! == STATES:"GAMEOVER") then if(Key(KEYPAD_ENTER)) then currentState! = STATES:"PLAYING" elseif(Key(K_ESCAPE)) then engine = ONOFF:"OFF" end if
'Draw no filled box' canvas(0) update() elseif(currentState! == STATES:"PLAYING") if(key(KEYPAD_ENTER)) then currentState! = STATES:"PAUSING" elseif(Key(K_ESCAPE)) then engine = ONOFF:"OFF" end if
setColor(RGB(0,0,255) canvas(0) BoxFill (x1, 150, x2, 200) update()
elseif(currentState! == STATES:"PAUSING") then
if(key(KEYPAD_ENTER)) then currentState! = STATES:"PLAYING" elseif(Key(K_ESCAPE)) then engine = ONOFF:"OFF" end if x0 = 0; h0 = 0; GetCanvasSize(x0,h0)
if (x2 > x0) then x1 = 0 x2 = 50 end if
x1 = x1 +1 x2 = x2 +1 setColor(RGB(0,255,0) canvas(0) BoxFill (x1, 150, x2, 200) update()
end if
wend
So much on this idea, thanks for reading about it.
|
|
|
Post by eyfenna on Jul 2, 2017 12:13:43 GMT -6
Just did a quick thought about above combining it with deepnes attribute similar to a dimensional attribute of arrays.
Array two dimensional is a field with a[2][2] having a[0][0] = 1, a[0][1] = 2, a[1][0] = 3 and a[1][1] = 4 members, an adjective b[2][2] with deepness 2, has 2 types with totally 4 subtypes.
Difference is that setting all members of a[2][2] the same means that comparations between different members will lead to true.
a[0][0] =1 a[0][1] = 1 a[1][0] =1 a[1][1] = 1
if (a[0][0] = a[1][1]) then fprint("true") else fprint("false") end if
prints true
on the other side adj b with all subtype being the same
set int b[0][0] =1 set int b[0][1] = 1 set int b[1][0] =1 set int b[1][1] = 1
if (b[0][0] = b[1][1]) then fprint("true") else fprint("false") end if would print false.
Okay a function to get the value of a subtype of a adjective is a idea here, but then this would also not hand a true as for example a function called data() and a function called mag() as in magnitute
set int b[0][0] =1 set int b[0][1] = 1 set int b[1][0] =1 set int b[1][1] = 1
if (data(b[0][0]) = data(b[1][1])) then 'with data(b[0][0]) gives 0 and data(b[1][1]) gives 3' fprint("true") else fprint("false") end if 'prints false'
if (mag(b[0][0]) = mag(b[1][1])) then 'with mag(b[0][0]) gives 1 and mag(b[1][1]) gives 1' fprint("true") else fprint("false") end if 'prints true'
compared to dim() would be dpn() (as in deepnes) and compared to size() would be amt() (as in ammout) with dpn(b) returns 2 with amt(b,2) returns 2
Compared to array this has the advantage of members being distinctive and the disadvantage of coming with a lot more typing work compared to arrays. It could be used to quickly set up a turing machine adding to numbers in RCBasic:
adj TuringMachine[4] set str TuringMachine[0]= "add" set str TuringMachine[1]= "5" set str TuringMachine[2]= "4" set str TuringMachine[3]= "outcome"
TuringMachine MachineState! = TuringMachine[0]
With val(mag(MachineState!)) following code does the same as 4 +5 and prints 9:
x = 0 while(MachineState! != TuringMachine:"outcome") for i = 0 to 3 MachineState! = TuringMachine[î] if(val(mag(MachineState!)) =0)then if(MachineState! = TuringMachine:"ADD") then if(val(mag(MachineState!)) != 0) then x = x + val(mag(MachineState!)) end if end if end if next wend fprint(x) waitkey()
|
|
|
Post by eyfenna on Jul 2, 2017 16:08:55 GMT -6
second look at it tis does not work, going to test code a turing machine with string array these days.
|
|
|
Post by eyfenna on Jul 4, 2017 4:23:10 GMT -6
How do you plan to introduce matrices or matrix math?
|
|
|
Post by n00b on Jul 6, 2017 19:20:00 GMT -6
Sorry for the late reply. I am thinking about introducing matrices as objects similar to arrays. So something like this:
Matrix m1[2,2] Matrix m2[2,2] Matrix m3[2,2]
m3 = m1 * m2
But I am still not certain it will work exactly like that.
|
|
|
Post by eyfenna on Jul 7, 2017 12:08:54 GMT -6
Sorry for the late reply. I am thinking about introducing matrices as objects similar to arrays. So something like this: Matrix m1[2,2] Matrix m2[2,2] Matrix m3[2,2] m3 = m1 * m2 But I am still not certain it will work exactly like that. be aware that m3 = m1*m2 while m4 = m2*m1 multiplication is not communative or how its called in math terms.
|
|
|
Post by n00b on Jul 7, 2017 12:54:00 GMT -6
The parser would just take into account the first argument and go left to right. But like I said it probably won't work like this because of other issues in this implementation such as possible memory leaks if the expected number of dimensions don't match. Right now I am still in the process of implementing structures so it will be atleast another 3 weeks before I get to this.
|
|
|
Post by eyfenna on Jul 7, 2017 13:18:35 GMT -6
you had to assert a lot of stuff or go with functions that can dynamical allocate or say a matrix member is a 'can be filled but initialized with zeros' position.
at least this is what i would consider first as solution.
what would be nice as structural addition is geometrical vectors as structures that can be called as a whole, added as a whole initialized through a function that takes 1,2 or 3 arguments or with their sub members array like as vector[x] or vector[y] or vector [z].
well would be nice for readability
|
|
|
Post by eyfenna on Jul 8, 2017 8:51:28 GMT -6
Sorry for the late reply. I am thinking about introducing matrices as objects similar to arrays. So something like this: Matrix m1[2,2] Matrix m2[2,2] Matrix m3[2,2] m3 = m1 * m2 But I am still not certain it will work exactly like that. research into wikipedia gives that you have the ordinary matrix product and the hadamard product in above case. what is possible i think is to move another way: introducing matrices with n,n dimension and deriving from them 1d arrays as special case 1,n or n,1 matrices. following above 2d arrays are then (n,o),1 matrices while 3d arrays (n,o,p),1 matrices. well interesting thoughts at the end i'm sure you find a good way to introduce them.
|
|