R0J0hound's Forum Posts

  • Thanks but I often combine too many things together so it’s not super readable to others. I also did some ugly shortcuts toward the end which made it even less readable. But my goal was to test my ideas instead of just talk about them. If any part of it is useful that’s a good thing.

    You’ll probably want to do it in your own style in a way you understand.

    By far the easiest way to go about the ai would be with simple math and manually inputting the probability numbers.

    Count = claimCount - (number of ones) - (number of dice=claimPip)

    If (number of other players dice)=5

    If count =5

    — set probability to 0.045

    … and so on for ever combination of dice count and count. In a more compact way you can have all the probability numbers in an array and you can access it with one event. That link you posted has a table of some of the probabilities. Or you can calculate them with that formula.

    An amusing side effect of writing the probabilities down manually is you could just use arbitrary numbers and you’d change the ai’s decision making.

  • The actual array object is nice and all, but it’s also nice to be able to have arrays be scoped like local or instance variables. It’s also nice to be able to have temporary arrays.

    It would also be nice to not have to deal with picking with them. Picking two instances separately at the same time, and how created objects have certain limits on how they can be picked for a bit are two complications of using picking.

  • I think we are limited to only numbers, text and Booleans for variables and parameters for the foreseeable future.

  • One way is to have the sprite and shadow as separate objects. Say you click somewhere you'd have the shadow move in a straight line and the sprite in a curved one. Here's one way to do it. You may be able to do it with eases instead, but I'm not super familiar with a lot of C3's easing, timeline or move to features.

    mouse: on click
    -- sprite: set t to 0
    -- sprite: set startX to self.x
    -- sprite: set startY to self.y
    -- sprite: set goalX to mouse.x
    -- sprite: set goalY to mouse.y
    
    sprite: t<1
    -- sprite: set t to min(1, self.t + 5*dt)
    -- shadow: set x to lerp(sprite.startX, sprite.goalX, sprite.t)
    -- shadow: set y to lerp(sprite.startY, sprite.goalY, sprite.t)
    -- sprite: set x to lerp(sprite.startX, sprite.goalX, sprite.t)
    -- sprite: set y to qarp(sprite.startY, (sprite.startY+sprite.goalY)/2-100 ,sprite.goalY, sprite.t)
  • I decided to test the brute force method. It's plenty fast but I'm not sure it's simpler than just using a formula. Guess I'll try making a formula that does the same thing with probability math later.

    I ended up building a full game to test it. You control both players and the ai provides a probability by each button based on guessing the other player's dice. To play as a player don't look at the other player's dice, and to play as an ai press buttons based on the probability by it.

    I probably fudged the rules a bit. I'm assuming you can increase the pip or count by more than one, and the first player gets to start at any pip or count they like. I just had it start at "1 two".

    Anyways, it's not the cleanest or most readable but it was meant to test calculating the probability and seeing how the ai could use that to make a decision. It seems like a viable way to go about it.

    dropbox.com/scl/fi/lqfpg3ur6idb09b50oeup/liars_dice.capx

    Now lets look at the math way to do it. That article you posted gets you most of the way there...

    K = (number of dice in the claim) - (number of dice in the player's hand that match the pip or is wild (one))
    N = (number of dice that the other player has)
    Probability = 0
    
    compare: K=0
    -- set probability to 1
    else
    compare: K<=N
    Repeat K times
    -- add factorial(N)/(factorial(loopindex+1)*factorial(N-loopindex-1))*((1/3)^(loopindex+1))*((2/3)^(N-loopindex-1)) to probability
    
    function factorial(num)
    -- return (num=0 | num=1)?1:factorial(num-1)

    Here's the same thing in formula form in case I made typos.

    Anyways, hopefully some of that helps.

  • What aspect of the math do you need help with specifically?

    Calculating the probability that that the other player’s dice have at least n dice of a certain number?

    Say the other player claims 5 twos. And you have 2 twos, then you’d only need to calculate the probability that the other player has at least 3 twos. (Since 5-2=3)

    After that if the probability is too low you can call the other player a liar.

    The only other action is making another claim. For that you’d take one of the numbers on your dice, count the number of dice you have with that value and add 1,2,3,4 or 5 to it. It just depends how risky you want to be.

    Anyways you want a way to get the probability that the other player has at least n dice with a certain value. N is the number of dice.

    The math way to do it is with “probability math”. You can find some nice tutorials online that explain that well. That’s the only math stuff that that article you linked uses for the most part. And really the only strange math operation is the “!” Whitch is called a factorial. For example 4!=4*3*2*1

    If you don’t like math then you can also brute force it. Just try all possible dice rolls and count the number of them with at least n dice with a certain value. For 5 dice that’s 6^5 or 7776 possible rolls. No issue to do with a loop.

    In a similar vein you could find an approximate probability by only sampling some of the possible rolls. Basically roll all 5 dice 1000 times randomly, and count the number of them with n dice of a certain value.

    Another way is to not count or calculate anything. Just have the probabilities pre calculated in an array and reference that.

  • You could use the timeline to make a path, or so I hear.

    Or you could put a bunch of instances of a sprite and call it “node”. The order you place the node instances will define the path. The events would look like the following. Be sure to use all caps since expressions aren’t case sensitive.

    Var t=0

    Every tick

    — add 5*dt to t

    — sprite: set x to lerp(node(int(t)).x, node(int(t)+1).x, t-int(t))

    — sprite: set y to lerp(node(int(t)).y, node(int(t)+1).y, t-int(t))

    There’s other ways I’m sure.

  • You can loop over all the tiles and use an array to make a list of xy positions where a road tile is. Then you can pick a random xy pair from the list.

    Looping over all the tiles can be time consuming so instead of doing that every time you can just maintain the list of road tiles and update that when you add or remove road tiles.

    Alternatively you could use sprites instead of those tiles. Sprites are great if you want to pick a specific one. Arrays and tile maps are great for accessing things at specific spots.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No idea really. I’m a hobbyist not a freelancer.

  • I’m not for hire but ideas are free.

    There are some example on the forum of fracture by just creating premade pieces and destroying the original object. Also there should be an example somewhere of object slicing. Maybe in a fruit ninja question.

    The meat of it is being able to clip a polygon by a line, polyline or another polygon. That basically amounts to keeping a list of points of the polygons and calculating intersections of line segments and testing if a point is inside a polygon or on either side of a line. You’d want all the polygons to be convex

    To draw the polygons you could use a drawing canvas or use a distort mesh. The distort mesh is better in that it has collisions and is textured.

    After that it’s just a matter of defining how you want it to fracture. Start with just drawing the fracture pattern you’re after. Then you could just use the polygons from that to do the clipping or you could try to procedurally try to generate similar patterns.

    For a super realistic fracture you could define the density of the object as a varying noise texture then doing some kind of pathfinding through that to make the crack. But that’s probably slow and excessive.

  • You can try:

    System -> object overlaps point

  • On the construct community discord there is skymen, mikal and Federico that have made effects, but c3 mostly.

    I’m no longer interested in any aspect of addon development but I can give general information.

    The fx file is glsl not js but it looks similar.

    The scrolling is probably done by shifting the texture coordinates its sampling from.

    Maybe: tex=mod(tex+vec2(offsetX,offsetY), 1)

    But that only works right if the image isn’t spritesheeted.

    To make it work you need the top left and bottom right texture coordinates. It would look similar to this but the names of the values may be different.

    tex = mix(texTopLeft, texTopRight, fact((tex-texTopLeft)/(texBottomRight-texTopLeft)+vec2(offsetX,offsetY)))

    You’d need to look up the correct names of things from the docs I think.

    Anyways I’m assuming a bit here. I haven’t looked at the effect. I’m not available to actually try doing it with the effect, but it’s the rough idea of a possible fix.

  • The question is far too general. You can go through some beginner tutorials to get the basics down.

    Or if you say what you’re trying to do, and show the events that aren’t working for you then maybe someone can probably give more specific help.

  • I don’t mess with effects but likely the fact images are put into spritesheets when exporting is throwing it off.

    The effect probably needs to be fixed so it wraps the texture coordinates around the sub texture instead of the whole texture.

    A workaround is to load the image at runtime. That way the image isn’t spritesheeted.