Yeah.. I see that the obfuscation feature is broken at the moment.. I really need to rewrite it completely, since it's implemented rather bad right now. Anyway, I fixed some of the bugs, and released a new version.
I got a couple of deadlines comming up for some school projects, which is why I haven't been very active the last couple of days.
@Slarti: Go
Hmm.. wouldn't really call it a bug. It's meant to overload binary operators, and it's not syntactically correct to write 2*3; Still, I might be able to relax that for custom operators.
@Kueken531: Go
Good point with the mod files.. Ill look into that when I have the time. Although, you will probably need to give the compiler the script explicitly, since, if I remember correctly, you can't get the .SC2Mod file from the dependencies.
Doesn't give me any errors.. Did you forget the * in the type?
In terms of output script, it doesn't really matter if you write
Foo*f=newFoo();
or
newFoo();
Although the latter is not possible. If f in the first one is not used, it will be removed when optimizing. To be honest, if I were to make the latter possible, I would probably just insert "Foo* f =" during compilation.
Yeah, it won't do horizontal or vertical lines very well due to clamping it to [-1, 1]. But they are rather simple shapes that you can test for before clamping.. There are some room for optimizations and improvements in this code.
Also, the "probably not a match" thingy is just testing if the distance pr point is greater than 0.04, so you can tweak that.. Anyway, you might find better ways of doing it, but there's my go at it :)
Initializer{shapes[(int)Shape.Circle]=newpoint[16]();for(inti=0;i<16;i++){fixedangle=i*360.0/16.0;shapes[(int)Shape.Circle][i]=Point(Cos(angle),Sin(angle));}shapes[(int)Shape.PositiveLine]=newpoint[16]();for(inti=0;i<16;i++){shapes[(int)Shape.PositiveLine][i]=Point(i/8.0-1,i/8.0-1);}shapes[(int)Shape.NegativeLine]=newpoint[16]();for(inti=0;i<16;i++){shapes[(int)Shape.NegativeLine][i]=Point(i/8.0-1,1-i/8.0);}userPoints=newpoint[0]();}point[]userPoints;point[][3]shapes;enumShape{Circle,PositiveLine,NegativeLine}TriggerMouseDown{events{TriggerAddEventMouseClicked(MouseDown,c_playerAny,c_mouseButtonLeft,true);}actions{userPoints->Resize(0);TriggerEnable(TrackMouse,true);}}TriggerTrackMouse{events{TriggerAddEventMouseMoved(TrackMouse,c_playerAny);TriggerEnable(TrackMouse,false);}actions{//Might be able to optimize this - you probably dont need as many pointsintlength=userPoints->length;userPoints->Resize(length+1);userPoints[length]=Point(EventMouseMovedPosXUI(),EventMouseMovedPosYUI());}}TriggerMouseUp{events{TriggerAddEventMouseClicked(MouseUp,c_playerAny,c_mouseButtonLeft,false);}actions{TriggerEnable(TrackMouse,false);if(IsHorizontalLine(userPoints)){UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Horizontal line");return;}if(IsVerticalLine(userPoints)){UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Vertical line");return;}ClampPoints(userPoints);intbestMatch=-1;fixedbestMatchDist=-1;for(inti=0;i<shapes.length;i++){fixeddist=DistanceTo(i,userPoints);if(bestMatch==-1||dist<bestMatchDist){bestMatch=i;bestMatchDist=dist;}}UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Best match was "+(string)(Shape)bestMatch+" with a distance of "+bestMatchDist+".");UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Distance pr point: "+bestMatchDist/userPoints->length);if(bestMatchDist/userPoints->length>0.2)UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Probably not a match");}}boolIsHorizontalLine(point[]points){fixedminY=points[0].y;fixedmaxY=minY;fixedx=points[0].x;intindex=points->length-1;boolpositiveDir=points[index].x>x;intcount=points->length;for(inti=1;i<count;i++){if(x!=points[i].x&&positiveDir!=(x<=points[i].x))returnfalse;x=points[i].x;fixedy=points[i].y;if(y<minY)minY=y;if(y>maxY)maxY=y;if((maxY-minY)>50)returnfalse;}returntrue;}boolIsVerticalLine(point[]points){fixedminX=points[0].x;fixedmaxX=minX;fixedy=points[0].y;intindex=points->length-1;boolpositiveDir=points[index].y>=y;intcount=points->length;for(inti=1;i<count;i++){if(y!=points[i].y&&positiveDir!=(y<=points[i].y))returnfalse;y=points[i].y;fixedx=points[i].x;if(x<minX)minX=x;if(x>maxX)maxX=x;if((maxX-minX)>50)returnfalse;}returntrue;}fixedDistanceTo(intshape,point[]userPoints){//You will be able to optimize this if the shape points is saved in a specific way, for instance sorted by x or y//Also, you can terminate early if you send the current min dist withfixedtotDist=0;for(inti=userPoints->length-1;i>=0;i--){fixedminDist=10;//Since it's clamped, 8 is max distance in calculationsfor(intj=shapes[shape]->length-1;j>=0;j--){fixedx=userPoints[i].x-shapes[shape][j].x;fixedy=userPoints[i].y-shapes[shape][j].y;fixeddist=x*x+y*y;if(dist<minDist*minDist)minDist=SquareRoot(dist);}totDist+=minDist;}returntotDist;}voidClampPoints(point[]points){//Make points within [-1, 1]fixedmaxX=points[0].x;fixedmaxY=points[0].y;fixedminX=maxX;fixedminY=maxY;for(inti=points->length-1;i>0;i--){fixedx=points[i].x;fixedy=points[i].y;if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;}fixedmidX=(maxX+minX)/2;fixedmidY=(maxY+minY)/2;fixedsizeX=(maxX-minX)/2;fixedsizeY=(maxY-minY)/2;for(inti=points->length-1;i>=0;i--){points[i].x=(points[i].x-midX)/sizeX;points[i].y=(points[i].y-midY)/sizeY;}}enrichpoint{fixedx{get{returnPointGetX(this);}set{this=Point(value,this.y);}}fixedy{get{returnPointGetY(this);}set{this=Point(this.x,value);}}}
I decided to try making something to do this, when I saw the post.. I save some arrays of points for each shape. Then, for each shape I measure for each point from the users dawing, the distance to the closest point int the shape and sum them up. That is the distance to a shape. The shape with the smallest distance is probably what he was trying to draw.
I tested it, with the shapes circle and line, and it seems to work.
Initializer{shapes[(int)Shape.Circle]=newpoint[16]();for(inti=0;i<16;i++){fixedangle=i*360.0/16.0;shapes[(int)Shape.Circle][i]=Point(Cos(angle),Sin(angle));}shapes[(int)Shape.PositiveLine]=newpoint[16]();for(inti=0;i<16;i++){shapes[(int)Shape.PositiveLine][i]=Point(i/8.0-1,i/8.0-1);}shapes[(int)Shape.NegativeLine]=newpoint[16]();for(inti=0;i<16;i++){shapes[(int)Shape.NegativeLine][i]=Point(i/8.0-1,1-i/8.0);}userPoints=newpoint[0]();}point[]userPoints;TriggerMouseDown{events{TriggerAddEventMouseClicked(MouseDown,c_playerAny,c_mouseButtonLeft,true);}actions{userPoints->Resize(0);TriggerEnable(TrackMouse,true);}}TriggerTrackMouse{events{TriggerAddEventMouseMoved(TrackMouse,c_playerAny);TriggerEnable(TrackMouse,false);}actions{//Might be able to optimize this - you probably dont need that many pointsintlength=userPoints->length;userPoints->Resize(length+1);userPoints[length]=Point(EventMouseMovedPosXUI(),EventMouseMovedPosYUI());}}TriggerMouseUp{events{TriggerAddEventMouseClicked(MouseUp,c_playerAny,c_mouseButtonLeft,false);}actions{TriggerEnable(TrackMouse,false);ClampPoints(userPoints);intbestMatch=-1;fixedbestMatchDist=-1;for(inti=0;i<shapes.length;i++){fixeddist=DistanceTo(i,userPoints);if(bestMatch==-1||dist<bestMatchDist){bestMatch=i;bestMatchDist=dist;}}UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Best match was "+(string)(Shape)bestMatch+" with a distance of "+bestMatchDist+".");UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Distance pr point: "+bestMatchDist/userPoints->length);if(bestMatchDist/userPoints->length>0.04)UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,"Probably not a match");}}point[][3]shapes;enumShape{Circle,PositiveLine,NegativeLine}fixedDistanceTo(intshape,point[]userPoints){//You will be able to optimize this if the shape points is saved in a specific way, for instance sorted by x or yfixedtotDist=0;for(inti=userPoints->length-1;i>=0;i--){fixedminDist=10;//Since it's clamped, 8 is max distance in calculationsfor(intj=shapes[shape]->length-1;j>=0;j--){fixedx=userPoints[i].x-shapes[shape][j].x;fixedy=userPoints[i].y-shapes[shape][j].y;fixeddist=x*x+y*y;if(dist<minDist)minDist=dist;}totDist+=minDist;}returntotDist;}voidClampPoints(point[]points){//Make points within [-1, 1]fixedmaxX=points[0].x;fixedmaxY=points[0].y;fixedminX=maxX;fixedminY=maxY;for(inti=points->length-1;i>0;i--){fixedx=points[i].x;fixedy=points[i].y;if(x<minX)minX=x;if(x>maxX)maxX=x;if(y<minY)minY=y;if(y>maxY)maxY=y;}fixedmidX=(maxX+minX)/2;fixedmidY=(maxY+minY)/2;fixedsizeX=(maxX-minX)/2;fixedsizeY=(maxY-minY)/2;for(inti=points->length-1;i>=0;i--){points[i].x=(points[i].x-midX)/sizeX;points[i].y=(points[i].y-midY)/sizeY;}}enrichpoint{fixedx{get{returnPointGetX(this);}set{this=Point(value,this.y);}}fixedy{get{returnPointGetY(this);}set{this=Point(this.x,value);}}}
Although I didn't use sc layout files much, I thought I would post some pictures of a project of mine :)
I'm not really developing much on it anymore... got this compiler thingy taking up time, but I did use it to test many of the features of the compiler.
Well, I kindda feel like it's about time to get new versions up, but on the other hand - they will be outdated as soon as I implement a new feature.. I think I will wait a bit, and work on the compiler instead.
I probably should get these videos update to a newer version of the editor. They are currently 8 months old. Although I don't think anyone really watches them..
You can use the initializer library functionally.. Any dependancies will be run before the current initializer. It will be faster to write with a simple integer, but harder to maintain if you share code with multiple people, like if you use libraries that use initializers.
Initializer(LibraryName="Run me last",LibraryVersion="1",RequiredLibraries="Run me first:1"){}Initializer(LibraryName="Run me first",LibraryVersion="1"){}
Are you sure the int[0] i; presists to galaxy code? It should be removed.
Also, it's impossible check at compile time if you create a dynamic array of size 0 - You could use the returned value of a function, and well.. Rice's theorem.
And a question: Is implicit resizing supported? I cannot test the result right now, but writing
int[]i=newint[5]();i[10]=5;
throws no error for me.
No. It is not supported, though it will work. The only issue with it is that when you delete i, it will only remove elements up to the specified length of the array.
There's also an issue that you can't "right-click" warnings such as "unused struct: MyStruct", as that activates the error box which says it is unable to open the file. The label stating where the struct is declared seems to not be set properly either, as it says "Library file[1, 8]: Unused struct: MyStruct" when my struct isn't originating from any library.
Hell, it's about time - Version 3.0.0 is finally here :)
I don't think that it is bug free though. So much code as been written, so there are likely to still be bugs lurking around.. If it's horrible, remember that you can downgrade in Help->Change to another version.
I just had a look at your bug. It is caused by an incorrect update to my control flow graph, after removing an unused local assignment. I will fix it for next version of course, but you should be able to fix it by removing your unused local assignments.
if(id==0){k=350;}else{k=150;}//In your code, this value of i is not being read.i=libNtve_gf_CreateDialogItemLabel(d,400,k,c_anchorTopLeft,75,95,GetUnitTooltip(id),Color(100,100,100),false,2.0);
So far, I should have the compiler part done, and about half of the suggestion list done. But once I get that done, there will be some time with bug fixing.
The compiler is written in c#. It's probably not be a bad idea to bring others aboard for faster updates - although there are a lot of code for someone to wrap his head around - and that's probably even harder right now where the code won't compile.
Hmm.. that looks weird.. I'm still working on the big rewrite and fixing its bugs though. Before I get that done, I can't really release any bug fixes, because the program is too unstable - at this point I got error reports popping up all the time :).
I know it's been a while, but changing the naming really has ramifications everywhere.. Also, as I said earlier, I do have other things to do apart from this project.
Anyway.. only advice I can really give right now is to use fields when it bugs on you like that.. It shouldn't join them.
0
Yeah.. I see that the obfuscation feature is broken at the moment.. I really need to rewrite it completely, since it's implemented rather bad right now. Anyway, I fixed some of the bugs, and released a new version.
0
I got a couple of deadlines comming up for some school projects, which is why I haven't been very active the last couple of days.
@Slarti: Go Hmm.. wouldn't really call it a bug. It's meant to overload binary operators, and it's not syntactically correct to write 2*3; Still, I might be able to relax that for custom operators.
@Kueken531: Go Good point with the mod files.. Ill look into that when I have the time. Although, you will probably need to give the compiler the script explicitly, since, if I remember correctly, you can't get the .SC2Mod file from the dependencies.
Doesn't give me any errors.. Did you forget the * in the type?
In terms of output script, it doesn't really matter if you write
or
Although the latter is not possible. If f in the first one is not used, it will be removed when optimizing. To be honest, if I were to make the latter possible, I would probably just insert "Foo* f =" during compilation.
0
Yeah, it won't do horizontal or vertical lines very well due to clamping it to [-1, 1]. But they are rather simple shapes that you can test for before clamping.. There are some room for optimizations and improvements in this code.
Also, the "probably not a match" thingy is just testing if the distance pr point is greater than 0.04, so you can tweak that.. Anyway, you might find better ways of doing it, but there's my go at it :)
0
I decided to try making something to do this, when I saw the post.. I save some arrays of points for each shape. Then, for each shape I measure for each point from the users dawing, the distance to the closest point int the shape and sum them up. That is the distance to a shape. The shape with the smallest distance is probably what he was trying to draw.
I tested it, with the shapes circle and line, and it seems to work.
0
Although I didn't use sc layout files much, I thought I would post some pictures of a project of mine :)
I'm not really developing much on it anymore... got this compiler thingy taking up time, but I did use it to test many of the features of the compiler.
0
Hmm.. seems I for some reason commented the call to the code that fixes value refs :s Shame on me for only testing if my projects could compile
0
Well, I kindda feel like it's about time to get new versions up, but on the other hand - they will be outdated as soon as I implement a new feature.. I think I will wait a bit, and work on the compiler instead.
0
I probably should get these videos update to a newer version of the editor. They are currently 8 months old. Although I don't think anyone really watches them..
0
You can use the initializer library functionally.. Any dependancies will be run before the current initializer. It will be faster to write with a simple integer, but harder to maintain if you share code with multiple people, like if you use libraries that use initializers.
0
@Kueken531: Go
Are you sure the int[0] i; presists to galaxy code? It should be removed.
Also, it's impossible check at compile time if you create a dynamic array of size 0 - You could use the returned value of a function, and well.. Rice's theorem.
0
Thanks guys, Ill get to work on fixing them.
No. It is not supported, though it will work. The only issue with it is that when you delete i, it will only remove elements up to the specified length of the array.
Edit:
How exactly do you define this 0 sized array? I thought I fixed that one.
I can't replicate this one : / you got some code?
0
Hell, it's about time - Version 3.0.0 is finally here :)
I don't think that it is bug free though. So much code as been written, so there are likely to still be bugs lurking around.. If it's horrible, remember that you can downgrade in Help->Change to another version.
0
@Kueken531: Go
I just had a look at your bug. It is caused by an incorrect update to my control flow graph, after removing an unused local assignment. I will fix it for next version of course, but you should be able to fix it by removing your unused local assignments.
0
So far, I should have the compiler part done, and about half of the suggestion list done. But once I get that done, there will be some time with bug fixing.
@Wyatt124: Go
The compiler is written in c#. It's probably not be a bad idea to bring others aboard for faster updates - although there are a lot of code for someone to wrap his head around - and that's probably even harder right now where the code won't compile.
@Kueken531: Go
What I meant was to use global fields instead of local variables. It won't merge a field with a local variable.
If the g
++
compiler can generate invalid code, then that is a bug, so arrays of size 0 should be reported as an error, or removed by the compiler.0
Hmm.. that looks weird.. I'm still working on the big rewrite and fixing its bugs though. Before I get that done, I can't really release any bug fixes, because the program is too unstable - at this point I got error reports popping up all the time :).
I know it's been a while, but changing the naming really has ramifications everywhere.. Also, as I said earlier, I do have other things to do apart from this project.
Anyway.. only advice I can really give right now is to use fields when it bugs on you like that.. It shouldn't join them.