Cobalt segmentation fault in blitter - cobalt

From today, the Cobalt application that uses blitter/directFB layer does crash while starting with the below segmentation fault.
It seems to be linked with animated images but even by disabling it with --disable_image_animations the crash still occurs.
The same issue occurs with qual-e.appspot.com/webp.html and qual-e.appspot.com/awebp.html
Do you know how to solve the issue? In the meantime is it possible to disable animated images?
Caught signal: SIGSEGV (11)
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f62de]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f7b88]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f66f0]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f7b88]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f7b88]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f7b88]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f66f0]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f7b88]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::RenderTreeNodeVisitor::Visit()
[0x12f5e74]
cobalt::renderer::rasterizer::blitter::HardwareRasterizer::Impl::Submit()
[0x12f4d58]
cobalt::renderer::Pipeline::RasterizeSubmissionToRenderTarget()
[0x1096350] cobalt::renderer::Pipeline::RasterizeCurrentTree()
[0x1097630] base::Timer::RunScheduledTask() [0x4a5cf8]
MessageLoop::RunTask() [0x479d24]
MessageLoop::DeferOrRunPendingTask() [0x47aacc]
MessageLoop::DoDelayedWork() [0x47b83c]
base::MessagePumpDefault::Run() [0x47f188] base::RunLoop::Run()
[0x48ae80] MessageLoop::Run() [0x4794cc] base::Thread::ThreadMain()
[0x4a44ec] base::(anonymous namespace)::ThreadFunc() [0x4a38b8]
(anonymous namespace)::ThreadFunc() [0x4bb670] start_thread
[0x77f73e14] Aborted

It looks like an issue with WebP support.
Please file a bug here w/ your Cobalt version, build type, Starboard, stracktrace information.
https://issuetracker.google.com/issues/new?component=181120&template=699202

Related

Build crashing on launch

I implemented the google play game services to my game for leaderboards and achievements, my game builds normally, but when I try to launch it on android, it crashes before the unity splash logo shows, logcat gives me this:
com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity
03-03 16:48:59.617 2993 2993 D ActivityManager: starting Active launch
03-03 16:48:59.648 2993 5385 I ActivityManager: START u0 {act=android.intent.action.MAIN typ=null flg=0x10200000 cmp=ComponentInfo{com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity}} from uid 10077
03-03 16:48:59.665 2993 3769 I ActivityManager: DSS on for com.FarSouth.RocketJumper and scale is 0.75
03-03 16:48:59.702 2993 3628 D ActivityManager: isScaleDownAnimationEnabled() : false
03-03 16:48:59.702 2993 3628 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_UP, x : 803, y : 879, isHomeItem : false
03-03 16:48:59.702 2993 3628 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_UP, task.getRootActivity() : ActivityRecord{f3e35f2 u0 com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity t21599}, task.getTaskToReturnTo() : 1
03-03 16:48:59.702 2993 3628 D ActivityManager: setAppIconInfo(), x : 803, y : 879, width : 251, height : 312, isHomeItem : false
03-03 16:48:59.704 2993 3628 I ActivityManager: Config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.21}
03-03 16:48:59.724 2993 3628 I ActivityManager: Override config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.21} for displayId=0
03-03 16:48:59.762 2993 3314 D ActivityManager: package com.samsung.android.game.gametools, user - 0 is SDcard whitelisted
03-03 16:48:59.775 2993 3314 I ActivityManager: Start proc 32163:com.samsung.android.game.gametools/u0a27 for service com.samsung.android.game.gametools/.floatingui.service.external.GameToolsIntentService
03-03 16:48:59.781 2993 5473 W ActivityManager: crash : com.FarSouth.RocketJumper,0
03-03 16:48:59.795 2993 5473 W ActivityManager: Force finishing activity com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity
03-03 16:48:59.817 2993 5385 I ActivityManager: DSS on for com.samsung.android.game.gametools and scale is 1.0
03-03 16:48:59.857 2993 3628 I ActivityManager: Config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 1920) s.22}
03-03 16:48:59.884 2993 3628 I ActivityManager: Override config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 1920) s.22} for displayId=0
03-03 16:48:59.914 2993 3027 I ActivityManager: Showing crash dialog for package com.FarSouth.RocketJumper u0
03-03 16:48:59.995 2993 5329 D PackageManager: getSelectedMetaData : packageName(com.FarSouth.RocketJumper) or Metadata strings {[Ljava.lang.String;#b99c7e3}
03-03 16:49:00.307 2993 3026 W ActivityManager: Activity pause timeout for ActivityRecord{f3e35f2 u0 com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity t21599 f}
03-03 16:49:00.313 2993 3026 D ActivityManager: isScaleDownAnimationEnabled() : true
03-03 16:49:00.313 2993 3026 D ActivityManager: clearAppIconInfo()
03-03 16:49:00.313 2993 3026 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_DOWN
03-03 16:49:00.343 2993 5329 D ActivityManager: post active user change for 0 fullscreen true isHomeActivity() true
I don't have any experience with crash logs but it seems that its either Android Game Tools or Unity Player Activity that's crashing my game? Before adding the GPGS to my game it worked normally. Thanks in advance.
I know that GPGS let your game crash with an IllegalStateException if you don't set its ID. I assume that's the case here, although I can't see it in your log.
dou you have Admob SDK in your game? GPGS and Admob did not work well together. Maybe use a older Version of GPGS the newest version makes often problems.

Why does the same Prolog query produce duplicate results only in specific cases?

While working in Prolog I frequently encounter that my implementation produces duplicate results when querying specific things. Below is my knowledge base:
connection(bus,kerkrade, heerlen, 1100, 1200).
connection(bus,kerkrade, bleijerheide, 1100, 1125).
connection(plane, kerkrade, sittard, 1100, 2100).
connection(bus, bleijerheide, heerlen, 1200, 1215).
connection(bus,heerlen, kerkrade, 1115, 1230).
connection(bus,heerlen, maastricht, 1230, 1330).
connection(plane, heerlen, groningen, 1400, 1420).
connection(bus,maastricht, heerlen, 1430, 1530).
connection(plane,maastricht, sittard, 1415, 1430).
connection(bus,maastricht, sittard, 1345, 1445).
connection(train,maastricht,sittard,1345,1600).
connection(bus,sittard, maastricht, 1630, 1530).
connection(bus,sittard, denbosch, 1530, 1700).
connection(plane,sittard, groningen, 1520 ,1700).
connection(bus,denbosch, sittard, 1800, 1930).
connection(bus,denbosch, amsterdam, 1000, 1330).
validConnection(T,X,Y,Z, connection(B,X,Y,S,W)):-
connection(B,X,Y,S,W),
member(B,T),
(Z =< S).
findRoute(TransportList,DepartureLoc,ArrivalLoc,TimeLeftAtHome,ToSolve):-
route(TransportList,DepartureLoc,ArrivalLoc,TimeLeftAtHome,[],ToSolve).
route(T,A,B,Time,V,[Head|L]) :-
validConnection(T,A,X,Time,Head),
not(member(X,V)),
(
B = X, L=[];
connection(_,A,X,_,S),
route(T,X,B,S,[A|V],L)
).
Querying if there is a route between Heerlen and Sittard, I get the following non-duplicate result:
findRoute([bus,train,plane],heerlen,sittard,900,V)
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(plane, maastricht, sittard, 1415, 1430)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(bus, maastricht, sittard, 1345, 1445)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(train, maastricht, sittard, 1345, 1600)] ;
false.
However, querying again, but this time our destination is groningen, I receive the following output in which every result is duplicated:
findRoute([bus,train,plane],heerlen,groningen,900,V)
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(plane, maastricht, sittard, 1415, 1430), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(plane, maastricht, sittard, 1415, 1430), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(bus, maastricht, sittard, 1345, 1445), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(bus, maastricht, sittard, 1345, 1445), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(train, maastricht, sittard, 1345, 1600), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(train, maastricht, sittard, 1345, 1600), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(plane, heerlen, groningen, 1400, 1420)] ;
false.
Using the built-in debugger I keep losing track of what is happening and can't see where the problem is. I have tried some minor edits to my KB but it keeps producing the same results.
I am aware that I can use setof\3 and others methods to negate the duplicate results, but that's not what I am interested in. I have also checked the facts to see if there are any duplicates in them and there aren't.
How is it possible that the second query produces duplicate results while the first one doesn't?
You could try cut (!) in various places in your program but it is not so easy. An easy way would be to write:
findall(V,findRoute([bus,train,plane],heerlen,groningen,900,V),L),sort(L,L1).
This will create a list of lists (L1) with all answers. To get only one answer (one list) and by pressing ';' get another...(of course with no duplicates) you could add:
member(L1,Result).
To answer to your question, the problem is in the lines:
connection(_,A,X,_,S),
route(T,X,B,S,[A|V],L)
There you want to say if there is a connection then find route...
but this should be using -> (then operator):
B = X, L=[];
connection(_,A,X,_,S)->
route(T,X,B,S,[A|V],L)
Example:
?- findRoute([bus,train,plane],heerlen,groningen,900,V).
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(plane, maastricht, sittard, 1415, 1430), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(bus, maastricht, sittard, 1345, 1445), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(bus, heerlen, maastricht, 1230, 1330), connection(train, maastricht, sittard, 1345, 1600), connection(plane, sittard, groningen, 1520, 1700)] ;
V = [connection(plane, heerlen, groningen, 1400, 1420)] ;
false.
This is exactly what the above sentence-goal should be written in Prolog-code . By using , (and) it is not the same and finds more cominations.
As a conclusion it is not easy to find such duplicates, (in more complicated programs it may be very hard) so using the above solution with findall or anything else that removes duplicates may be more easy.

Different variables - prolog puzzle solver

I'm developing a solution based on prolog restrictions.
Basically I got to rearrange 9 pieces with dots in it to make a dice. I have 9 pieces and 7 are all different but 2 are equal. I want to make a restriction that says it and I got this:
A #= 100000*V1 + 10000*V2+ 1000*V5,
element(P1,Vars,A),
B #= 100000*V7 + 10000*V8 + 10*V11 + V12,
element(P2,Vars,B),
C #= 100000*V13 + 10*V17 + V18,
element(P3,Vars,C),
D #= 100000*V19,
element(P4,Vars,D),
E #= 100000*V25 + 10*V29,
element(P5,Vars,E),
F #= 100000*V31,
element(P6,Vars,F),
G #= 100000*V37,
element(P7,Vars,G),
H #= 100*V47,
element(P8,Vars,H),
I #= 0,
element(P9,Vars,I),
F#=P7,
F#=G,
PiecesIndex = [P1, P2, P3, P4, P5, P6, P8, P9],
all_different(PiecesIndex),
Each VXY is one face of the piece and it can have 0,1,2 dots as you can see in the code below.
The Help I need is:
- Make sure that all pieces are different
- Make sure F and G are equal
- Make sure I dont use repeated pieces.
Can anyone help me! I've been here whole night trying to figure this out and I'm going nuts!
full code:
:-use_module(library(clpfd)).
:-use_module(library(lists)).
dice(Vars):-
Vars=[V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18,
V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36,
V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54],
% pecas dos topos
domain([V5, V6, V11, V12, V17, V18, V23, V24, V29, V30, V35, V36, V41, V42, V47, V48, V53, V54], 0, 1),
% pecas laterais
domain([V1, V2, V3, V4, V7, V8, V9, V10, V13, V14, V15, V16, V19, V20, V21, V22, V25, V26, V27, V28,
V31, V32, V33, V34, V37, V38, V39, V40, V43, V44, V45, V46, V49, V50, V51, V52], 0,2),
table([
[V1, V2, V3, V4, V5, V6], %%peca1
[V7, V8, V9, V10, V11, V12], %%peca2
[V13, V14, V15, V16, V17, V18], %%peca3
[V19, V20, V21, V22, V23, V24], %%peca4
[V25, V26, V27, V28, V29, V30], %%peca5
[V31, V32, V33, V34, V35, V36], %%peca6
[V37, V38, V39, V40, V41, V42], %%peca7
[V43, V44, V45, V46, V47, V48], %%peca8
[V49, V50, V51, V52, V53, V54]], %%peca9
[[2,2,0,0,1,0], %%peca1
[2,1,0,0,1,1], %%peca2
[2,0,0,0,1,1], %%peca3
[2,0,0,0,0,0], %%peca4
[1,0,0,0,1,0], %%peca5
[1,0,0,0,0,0], %%peca6
[1,0,0,0,0,0], %%peca7
[0,0,0,0,1,0], %%peca8
[0,0,0,0,0,0]]), %%peca9
% restricoes para as faces que envolve os topos de cada peça
% Na figura de descriçºao das peças os topos de cima estão guardados
% na posicao 5 de cada lista. Os topos de baixo estoa guardados na
% posicao 6 de cada lista
% Restrições quanto à soma de faces opostas(=7)
V2+V19+V7 #= TotalF1,
V8+V37+V25 #= TotalF2,
V5+V23+V11+V53+V47+V41+V29+V35+V17 #= TotalF3,
V18+V36+V30+V54+V48+V42+V6+V24+V12 #= TotalF4,
V1+V49+V13 #= TotalF5,
V16+V31+V26 #= TotalF6,
Totals = [TotalF1, TotalF2, TotalF3, TotalF4, TotalF5, TotalF6],
domain(Totals, 1,6),
all_different(Totals),
TotalF3 + TotalF4 #= 7,
TotalF1 + TotalF6 #= 7,
TotalF5 + TotalF2 #= 7,
A #= 100000*V1 + 10000*V2+ 1000*V5,
element(P1,Vars,A),
B #= 100000*V7 + 10000*V8 + 10*V11 + V12,
element(P2,Vars,B),
C #= 100000*V13 + 10*V17 + V18,
element(P3,Vars,C),
D #= 100000*V19,
element(P4,Vars,D),
E #= 100000*V25 + 10*V29,
element(P5,Vars,E),
F #= 100000*V31,
element(P6,Vars,F),
G #= 100000*V37,
element(P7,Vars,G),
H #= 100*V47,
element(P8,Vars,H),
I #= 0,
element(P9,Vars,I),
F#=P7,
F#=G,
PiecesIndex = [P1, P2, P3, P4, P5, P6, P8, P9],
all_different(PiecesIndex),
%There are 21 spots on the pieces
%sum(Vars, #=, 21),
labeling([],Vars),
show(Vars).
show([V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18,
V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36,
V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54]) :-
write([V1, V2, V3, V4, V5, V6]), nl,
write([V7, V8, V9, V10, V11, V12]), nl,
write([V13, V14, V15, V16, V17, V18]), nl,
write([V19, V20, V21, V22, V23, V24]), nl,
write([V25, V26, V27, V28, V29, V30]), nl,
write([V31, V32, V33, V34, V35, V36]), nl,
write([V37, V38, V39, V40, V41, V42]), nl,
write([V43, V44, V45, V46, V47, V48]), nl,
write([V49, V50, V51, V52, V53, V54]), nl.
Best regards

Prolog restrictions - puzzle

I'm developing a game named woodntDie. This game consists in 9 pieces which should look like this:
The aim is to arrange all those pieces and make it look like a dice:
This is the four final possible solutions with all those 9 pieces.
I'm trying to implement some restrictions but those arent enough:
sum([V5, V6, V11, V12, V17, V18, V23, V24, V29, V30, V35, V36, V41, V42, V47, V48, V53, V54], #=, 7),
The sum of the opposite faces should always be 7. In this restriction I'm telling that the sum of the top and bottom face it's 7.
sum([V2, V19, V7, V16, V31, V26], #=, 7),
The sum of the front and back faces is 7 aswell.
sum([V1, V49, V13, V8, V37, V25], #=, 7),
The sum of the left and right face is 7.
sum(Vars, #=, 21),
The sum of all the dots it's 21.
But I'm getting a really weird output, I'm getting repeated pieces and a load of solutions that doesnt make any sense and dont form a dice at all. I think I need few more restrictions and my questions are:
How do I make a restrictions saying that some pieces cant be repeated (notice that I can have two F pieces but all the other ones cant be similar)
How do I make a new restriction with this:
The only other remaining bar to have two spots on its side is C, so C must combine with A to make the 4 or 5 face
The only other bar to have a spot on its side near one end is E, so E must combine with B to make the 2 or 3 face.
I mean, is there any way to say "the sum of VX, VY, VZ it's 2 or 3".
And do you have any other opinion that would make the solution easier?
I'm struggling here and I really dont know what to do, I'd really appreciate all the help I could get.
Here's the whole code:
:-use_module(library(clpfd)).
:-use_module(library(lists)).
dice(Vars):-
Vars=[V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18,
V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36,
V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54],
% pecas dos topos
domain([V5, V6, V11, V12, V17, V18, V23, V24, V29, V30, V35, V36, V41, V42, V47, V48, V53, V54], 0, 1),
% pecas laterais
domain([V1, V2, V3, V4, V7, V8, V9, V10, V13, V14, V15, V16, V19, V20, V21, V22, V25, V26, V27, V28,
V31, V32, V33, V34, V37, V38, V39, V40, V43, V44, V45, V46, V49, V50, V51, V52], 0,2),
table([
[V1, V2, V3, V4, V5, V6], %%peca1
[V7, V8, V9, V10, V11, V12], %%peca2
[V13, V14, V15, V16, V17, V18], %%peca3
[V19, V20, V21, V22, V23, V24], %%peca4
[V25, V26, V27, V28, V29, V30], %%peca5
[V31, V32, V33, V34, V35, V36], %%peca6
[V37, V38, V39, V40, V41, V42], %%peca7
[V43, V44, V45, V46, V47, V48], %%peca8
[V49, V50, V51, V52, V53, V54]], %%peca9
[[2,2,0,0,1,0], %%peca1
[2,1,0,0,1,1], %%peca2
[2,0,0,0,1,1], %%peca3
[2,0,0,0,0,0], %%peca4
[1,0,0,0,1,0], %%peca5
[1,0,0,0,0,0], %%peca6
[1,0,0,0,0,0], %%peca7
[0,0,0,0,1,0], %%peca8
[0,0,0,0,0,0]]), %%peca9
% restricoes para as faces que envolve os topos de cada peça
% Na figura de descriçºao das peças os topos de cima estão guardados
% na posicao 5 de cada lista. Os topos de baixo estoa guardados na
% posicao 6 de cada lista
% Restrições quanto à soma de faces opostas(=7)
V2 + V19 + V7 #= TotalF1,
V8 + V37 + V25 #= TotalF2,
V5 + V23 + V11 + V53 + V47 + V41 + V29 + V35 + V17 #= TotalF3,
V18 + V36 + V30 + V54 + V48 + V42 + V6 + V24 + V12 #= TotalF4,
V1 + V49 + V13 #= TotalF5,
V16+ V31 + V26 #= TotalF6,
Totals = [TotalF1, TotalF2, TotalF3, TotalF4, TotalF5, TotalF6],
domain(Totals, 1,6),
all_different(Totals),
TotalF3 + TotalF4 #= 7,
TotalF1 + TotalF6 #= 7,
TotalF5 + TotalF2 #= 7,
A #= 100000*V1 + 10000*V2+ 1000*V5,
element(P1,Vars,A),
B #= 100000*V7 + 10000*V8 + 10*V11 + V12,
element(P2,Vars,B),
C #= 100000*V13 + 10*V17 + V18,
element(P3,Vars,C),
D #= 100000*V19,
element(P4,Vars,D),
E #= 100000*V25 + 10*V29,
element(P5,Vars,E),
F #= 100000*V31,
element(P6,Vars,F),
G #= 100000*V37,
element(P7,Vars,G),
H #= 100*V47,
element(P8,Vars,H),
I #= 0,
element(P9,Vars,I),
F#=P7,
F#=G,
PiecesIndex = [P1, P2, P3, P4, P5, P6, P8, P9],
all_different(PiecesIndex),
%There are 21 spots on the pieces
%sum(Vars, #=, 21),
labeling([],Vars),
show(Vars).
show([V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, V12, V13, V14, V15, V16, V17, V18,
V19, V20, V21, V22, V23, V24, V25, V26, V27, V28, V29, V30, V31, V32, V33, V34, V35, V36,
V37, V38, V39, V40, V41, V42, V43, V44, V45, V46, V47, V48, V49, V50, V51, V52, V53, V54]) :-
write([V1, V2, V3, V4, V5, V6]), nl,
write([V7, V8, V9, V10, V11, V12]), nl,
write([V13, V14, V15, V16, V17, V18]), nl,
write([V19, V20, V21, V22, V23, V24]), nl,
write([V25, V26, V27, V28, V29, V30]), nl,
write([V31, V32, V33, V34, V35, V36]), nl,
write([V37, V38, V39, V40, V41, V42]), nl,
write([V43, V44, V45, V46, V47, V48]), nl,
write([V49, V50, V51, V52, V53, V54]), nl.
and here's a pic with the representation of the dice and all those V's (each V represents the dots on each face)
ALL THE INFORMATION ABOUT THE GAME
Thank you so much in advance
Any doubt just ask or add me on skype: preserverance
Best regards
I mean, is there any way to say "the sum of VX, VY, VZ it's 2 or 3".
If this is the crucial question, try this:
(sum([VX,VY,VZ],#=,2);sum([VX,VY,VZ],#=,3))

Creating an ICNS programmatically: "Unsupported Image Size"

I'm trying to create an ICNS (including a 1024x1024 image) programmatically. Currently I'm creating an NSImage, then I create CGImageRef objects with the appropriate resolution, finally I'm adding them to an icon by using CGImageDestinationAddImage(). Peter Hosey has helped me create '#2x' images already, but the sizes of the images don't wanna be set.
This is the code (still a bit messy, sourcefile represents the path to the image):
NSSize sizes[10];
sizes[0] = NSMakeSize(1024,1024);
sizes[1] = NSMakeSize(512,512);
sizes[2] = NSMakeSize(512,512);
sizes[3] = NSMakeSize(256,256);
sizes[4] = NSMakeSize(256,256);
sizes[5] = NSMakeSize(128,128);
sizes[6] = NSMakeSize(64,64);
sizes[7] = NSMakeSize(32,32);
sizes[8] = NSMakeSize(32,32);
sizes[9] = NSMakeSize(16,16);
int count = 0;
for (int i=0 ; i<10 ; i++) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:#"Size%i",i+1]]) count++;
}
NSURL *fileURL = [NSURL fileURLWithPath:aPath];
// Create icns
CGImageDestinationRef dr = CGImageDestinationCreateWithURL((CFURLRef)fileURL, kUTTypeAppleICNS , count, NULL);
NSImage *img = [[NSImage alloc] initWithContentsOfFile:sourcefile];
for (int i=0 ; i<10 ; i++) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:#"Size%i",i+1]]) {
// Create dictionary
BOOL is2X = true;
if (i == 1 || i == 3 || i == 5 || i == 7 || i == 9) is2X = false;
int dpi = 144, size = (int)(sizes[i].width/2);
if (!is2X) {dpi = 72;size = sizes[i].width;}
[img setSize:NSMakeSize(size,size)];
for (NSImageRep *rep in [img representations])[rep setSize:NSMakeSize(size,size)];
const void *keys[2] = {kCGImagePropertyDPIWidth, kCGImagePropertyDPIHeight};
const void *values[2] = {CFNumberCreate(0, kCFNumberSInt32Type, &dpi), CFNumberCreate(0, kCFNumberSInt32Type, &dpi)};
CFDictionaryRef imgprops = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
// Add image
NSRect prect = NSMakeRect(0,0,size,size);
CGImageRef i1 = [img CGImageForProposedRect:&prect context:nil hints:nil];
CGImageDestinationAddImage(dr, i1, imgprops);
}
}
CGImageDestinationFinalize(dr);
CFRelease(dr);
size is the width or height that the current image should be. dpi is 144 if we're making an '#2x' image, otherwise it's 72. These values have been checked with NSLog.
The images in the resulting ICNS file are all the same size as the input image. If the size of the input image is 1024x1024, ImageIO complains:
ImageIO: _CGImagePluginWriteICNS unsupported image size (1024 x 1024) - scaling factor: 1
The above error is displayed every time the dpi is 72 and the size is 1024x1024.
I need to know how to set the size of the CGImage that is to be added to the ICNS file.
EDIT: I logged the images:
2012-12-31 12:48:51.281 Eicon[912:680f] |NSImage 0x101b4caf0
Size={512, 512} Reps=(
"NSBitmapImageRep 0x10380b900 Size={512, 512} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=1024x1024 Alpha=YES
Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting)
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.058 Eicon[912:680f] |NSImage 0x101b4caf0
Size={512, 512} Reps=(
"NSBitmapImageRep 0x10380b900 Size={512, 512} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO
Format=2 CurrentBacking=|CGImageRef: 0x101c14630|
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.111 Eicon[912:680f] |NSImage 0x101b4caf0
Size={256, 256} Reps=(
"NSBitmapImageRep 0x10380b900 Size={256, 256} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO
Format=2 CurrentBacking=|CGImageRef: 0x101c14630|
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.238 Eicon[912:680f] |NSImage 0x101b4caf0
Size={256, 256} Reps=(
"NSBitmapImageRep 0x10380b900 Size={256, 256} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO
Format=2 CurrentBacking=|CGImageRef: 0x101c14630|
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.309 Eicon[912:680f] |NSImage 0x101b4caf0
Size={128, 128} Reps=(
"NSBitmapImageRep 0x10380b900 Size={128, 128} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO
Format=2 CurrentBacking=|CGImageRef: 0x101c14630|
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.409 Eicon[912:680f] |NSImage 0x101b4caf0
Size={128, 128} Reps=(
"NSBitmapImageRep 0x10380b900 Size={128, 128} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO
Format=2 CurrentBacking=|CGImageRef: 0x101c14630|
CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.534 Eicon[912:680f] |NSImage 0x101b4caf0 Size={32,
32} Reps=(
"NSBitmapImageRep 0x10380b900 Size={32, 32} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO Format=2
CurrentBacking=|CGImageRef: 0x101c14630| CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.616 Eicon[912:680f] |NSImage 0x101b4caf0 Size={32,
32} Reps=(
"NSBitmapImageRep 0x10380b900 Size={32, 32} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO Format=2
CurrentBacking=|CGImageRef: 0x101c14630| CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.729 Eicon[912:680f] |NSImage 0x101b4caf0 Size={16,
16} Reps=(
"NSBitmapImageRep 0x10380b900 Size={16, 16} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO Format=2
CurrentBacking=|CGImageRef: 0x101c14630| CGImageSource=0x10380ae70"
)|
2012-12-31 12:48:52.864 Eicon[912:680f] |NSImage 0x101b4caf0 Size={16,
16} Reps=(
"NSBitmapImageRep 0x10380b900 Size={16, 16} ColorSpace=Generic RGB colorspace BPS=8 BPP=32 Pixels=1024x1024 Alpha=YES Planar=NO Format=2
CurrentBacking=|CGImageRef: 0x101c14630| CGImageSource=0x10380ae70"
)|
The error message is correct. You're putting in images of a size that is not supported by the IconFamily format. Specifically, from your output:
2012-12-26 13:48:57.682 Eicon[1131:1b0f] |NSImage 0x1025233b0 Size={11.52, 11.52} Reps=( "NSBitmapImageRep 0x10421fc30 Size={11.52, 11.52} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=1024x1024 Alpha=NO Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x104221170"
11.52 points is not a valid size for any element of an IconFamily. You need to find out why this image and rep have that size.
A couple of other things:
As I told you on that other answer, you don't need to change the pixel size of the representation. Leave the pixel size alone. Set the size (point size) of the rep and image (preferably to something valid).
The -[NSImage initWithSize:] documentation says:
It is permissible to initialize the receiver by passing a size of (0.0, 0.0); however, the receiver’s size must be set to a non-zero value before the NSImage object is used or an exception will be raised.
You are not setting either object's size, which is what you need to do. (I'm surprised you're not getting an exception about this like the documentation promises.)
As I mentioned on your other question, there is no 1024-point element anymore; the correct specification for a 1024-by-1024-pixel element is as 512 points # 2x. That's a size (of both image and rep) of (NSSize){ 512.0, 512.0 } (points), with the rep being 1024 pixelsWide and 1024 pixelsHigh.
Looks like I was missing one key ingredient before. Here it is.
The CGImage that you give to the CGImageDestination doesn't have a point size associated with it—only NSImages and NSImageReps have that. The CGImage only has a pixel size; nothing to indicate the image's physical size or resolution.
To tell the CGImageDestination whether a given CGImage is meant to be # 1x or # 2x, you need to create a dictionary that gives the image's DPI:
NSDictionary *imageProps1x = #{
(__bridge NSString *)kCGImagePropertyDPIWidth: #72.0,
(__bridge NSString *)kCGImagePropertyDPIHeight: #72.0,
};
NSDictionary *imageProps2x = #{
(__bridge NSString *)kCGImagePropertyDPIWidth: #144.0,
(__bridge NSString *)kCGImagePropertyDPIHeight: #144.0,
};
Pass the correct dictionary as the last argument to CGImageDestinationAddImage.

Resources