Help implementing game logic from fish fillets

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Fri Feb 03, 2023 4:08 pm I've recently updated the mini game with the help of some feedback from betatesters and solved many issues, just in case anyone is interested here is the link: https://codeberg.org/glitchapp/fish-fil ... s-mini-0.2
Nice!
Can you show the exit area and which fish is active?
(and the game progress was not saved)
2023-02-03T18_18_30-0.Fish House. How it all started..png
2023-02-03T18_18_30-0.Fish House. How it all started..png (45.5 KiB) Viewed 11288 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hi darkfrei,
Yes, highlighting the active fish is possible, I added it:
contour2.gif
contour2.gif (46.12 KiB) Viewed 11227 times
contour32.gif
contour32.gif (333.17 KiB) Viewed 11226 times
Regarding the exit areas... that's not shown in the original game either... I'm not sure what you mean by this... do you mean highlight the exit area zone in any particular color?

Regarding the save / load function, I have an issue opened because I don't manage to get the right results serializing the data, I already tried with several libraries, please check this issue: https://codeberg.org/glitchapp/fish-fil ... e/issues/2

* Update regarding the save / load function. It is implemented and working now, the new release with that feature is here: https://codeberg.org/glitchapp/fish-fil ... s-mini-0.3

I did not managed to serialize the tables as I wanted but I saved the variables individually instead. It is not the best way to do it but at least it works for now and you can save and load the progress.
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hi, I'm still looking for problems to be solved with this project and I decided to try to find out a method to create proceduraly generated levels on the game.
To try to find an example I tested chatGPT for the first time to try to accomplish this and here is the answer I received:

<my_promt> I need a function in lua to generate procedurally generated maps for a sokoban game
<chatGPT> You can use Lua's built-in `math` module and its functions like `floor`, `ceil`, etc., along with the `table.random()` method, which generates random numbers between two limits (either inclusive or exclusive). Here is an example function that creates a map of 10x5 tiles:

Code: Select all

```luv\begin{code}

function createMap(width, height)
    local result = {} -- Create empty table to store the generated tilemap
     for i=1, width do
         for j=1,height do
             if math.random() < 0.5 then // Generate a random number between zero and one (inclusive), which will be true with probability of half or lesser than that
                 table.insert(result[i][j], {x = i+math.floor((#result-1)*2/width)+1, y= j + math.ceil(height*0.5)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size
             elseif width > 3 then // If there are less than or equal to three tiles remaining (i.e., if we've generated enough for one more row)
                 table.insert(result[#result], {x= i+math.floor((width-1)*2/5), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             else // If there are less than or equal to three tiles remaining, generate one more row of 5x2 tiles instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             end
         elseif height > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif width > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more row instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif height > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif width > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             else // If there are less than or equal to two rows of generated tiles left, generate one more row instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif height > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif width > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more row instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             else // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             elseif height > 2 then // If there are less than or equal to two rows of generated tiles left, generate one more column instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             else // If there are less than or equal to two rows of generated tiles left, generate one more row instead
                 table.insert(result[#result], {x= i+math.floor((width-1)*4/9), y = j + math.ceil(height*0.3)}) -- Generate a tile at random position in the result array with x and y coordinates based on current map size (and adjusting for remaining tiles)
             end // End of if statements to generate randomly generated maps from 1x5, 2x5 or wider ones up to 9x5.
> 
It seems that looped somehow with the last conditional but still seems like a good aproach to me, what do you think?

It is important to explain that used a local instance from https://github.com/nomic-ai/gpt4all, I wonder if the results would be better on a full instance and if anyone could test it for me (I don't have an API to use it).
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Sat Apr 01, 2023 7:14 am Hi, I'm still looking for problems to be solved with this project and I decided to try to find out a method to create proceduraly generated levels on the game.
To try to find an example I tested chatGPT for the first time to try to accomplish this and here is the answer I received:
It's not a sokoban, but sokoban with gravity, blocks (not just squares) and two agents, one of them is bigger and has property to move "heavy" blocks.

For the procedural generated sokoban maps you are need:
1. Sokoban solver, that can find and check the shortest solution.
2. Create any map, add random positions for chests and right places for them.
3. If not possible to solve, add extra ways.
3a. Repeat 3.
4. If possible to solve, try to remove several ways.
5. Repeat 4 until no extra ways are on the map: keep ways, that the solver had used.
Last edited by darkfrei on Sat Apr 01, 2023 10:21 am, edited 1 time in total.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

darkfrei wrote: Sat Apr 01, 2023 9:55 am
glitchapp wrote: Sat Apr 01, 2023 7:14 am Hi, I'm still looking for problems to be solved with this project and I decided to try to find out a method to create proceduraly generated levels on the game.
To try to find an example I tested chatGPT for the first time to try to accomplish this and here is the answer I received:
It's not a sokoban, but sokoban with gravity, blocks (not just squares) and two agents, one of them is bigger and has property to move "heavy" blocks.
Hi darkfrei, I know, it is my first promt to chatGPT to try to solve a problem in lua and I was not sure if it would understand such a big question... it turns out it does, this is my second promt:

<my_promt> I need a function in lua to generate procedurally generated maps for a sokoban game with gravity, blocks (not just squares) and two agents, one of them is bigger and has property to move "heavy" blocks.
<chatGPT> One way to achieve this would be by using the `math` library in LuaJIT 2.0+ or a similar package for procedural generation functions (e.g., `generate_map`). Here's an example function that generates a map with two agents, one of them being bigger and able to move heavy blocks:

Code: Select all

```luvit
function generateMap(numAgents) -- numAgents is the number of agents in your game
  local x = math.random() * (1024 - 512 + 1):floor():tointeger()   // generates a random X coordinate for each agent on the map
  local y = math.random()*(1024-512+1)//:floor():tointger()    // generates a random Y coordinate for each agent on the map
  if (numAgents == 2 and x > floor(x/3)) then -- bigger agents can move heavy blocks, so we need to check that they're not too close together in space. Otherwise it might be difficult or impossible to generate maps with two players of different sizes moving around each other without colliding
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they're not too close together)
  elseif numAgents == 3 then   // if there are three agents, we need to check that none of them have already moved into each other's space. Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding (either because they can move heavy blocks too)
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding
  elseif numAgents == 5 then   // if there are five agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of empty spaces and/or collision issues (either because none or only one player has moved into each other's space)
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 7 then   // if there are seven agents, we need to check that none of them have already moved into each other's space. If not, the map will have a lot of empty spaces (either because they can move heavy blocks too) or collision issues (because all players might be moving around without colliding).
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space) 
elseif numAgents == 9 then   // if there are nine agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of empty spaces and/or collision issues because all players might be moving around without colliding (either because none or only one player has moved into each other's space)
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 10 then   // if there are ten agents, we need to check that none of them have already moved into each other's space. If not, the map will have a lot of collision issues (either because they can move heavy blocks too) or empty spaces (because all players might be moving around without colliding).
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space) 
elseif numAgents == 15 then   // if there are fifteen agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of empty spaces and/or collision issues (either because none or only one player has moved into each other's space)
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 16 then   // if there are sixteen agents, we need to check that none of them have already moved into each other's space. If not, the map will have a lot of collision issues (either because they can move heavy blocks too) or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 20 then   // if there are twenty agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of collision issues (either because none or only one player has moved into each other's space) and/or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 30 then   // if there are thirty agents, we need to check that none of them have already moved into each other's space. If not, the map will have a lot of collision issues (either because they can move heavy blocks too) or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 40 then   // if there are forty agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of collision issues (either because none or only one player has moved into each other's space) and/or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 50 then   // if there are fifty agents, we need to check that none of them have already moved into each other's space. If not, the map will have a lot of collision issues (either because they can move heavy blocks too) or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming none of them have already moved into each other's space). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 60 then   // if there are sixty agents, we need to check that they can move heavy blocks too. If not, the map will have a lot of collision issues (either because none or only one player has moved into each other's space) and/or empty spaces
    local bigAgentX = math.random()*1024:floor():tointeger() -- generates a random X coordinate for the bigger agent on the map (assuming they can move heavy blocks too). Otherwise it might be difficult or impossible to generate maps with all players moving around without colliding and/or having empty spaces
  elseif numAgents == 70 then   // if there are seventy agents, we need to check that none of them have already moved into each other's

It seems that it did not really understand that there are only 2 agents and created rules for up to 70 ... this was not intendeded but it could eventually be a cool new mechanics for multiplayer or more complicated puzzles...

I did a third promt and this time seems the function is better:

Promt: write a function in lua to generate procedurally generated maps for a sokoban game with gravity, blocks (not just squares) and two agents, one of them is bigger and has property to move "heavy" blocks.

Code: Select all

function createMap() {
    local x = math.random(1024); // random starting position for the agent with heavy block moving ability (x coordinate)
    local y = math.floor((math.pow(5, 3)) / 8 + math.mod(-y - 769, 8)); // randomly generate a new map by dividing an existing one into eight equal parts and then picking the first part to start with (x coordinate)
    local z = x; // set starting position for agent moving heavy blocks at y-coordinate
    
    while true do -- loop until all of the space is filled up or there are no more moves left in this direction. 
        if math.abs(y - floor((math.pow(5,3))/8 + x) > (x * z / 2016)^2 then break; // check to see whether agent can move any further downwards without hitting the bottom of a level or running into another block with heavy moving ability
        if math.abs(-y - floor((math.pow(5,3))/8 + x) > (x * z / 1024)^2 then break; // check to see whether agent can move any further upwards without hitting the top of a level or running into another block with heavy moving ability
Unfortunately the I.A. get stuck in a loop and keep repeating the last line... I still think it can serve as a starting point and as a way to aproach the problem...

If anyone has access to the API of the full instance of chatGPT it may be interesting to compare results and see if they are better...
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

darkfrei wrote: Sat Apr 01, 2023 9:55 am
glitchapp wrote: Sat Apr 01, 2023 7:14 am Hi, I'm still looking for problems to be solved with this project and I decided to try to find out a method to create proceduraly generated levels on the game.
To try to find an example I tested chatGPT for the first time to try to accomplish this and here is the answer I received:
It's not a sokoban, but sokoban with gravity, blocks (not just squares) and two agents, one of them is bigger and has property to move "heavy" blocks.

For the procedural generated sokoban maps you are need:
1. Sokoban solver, that can find and check the shortest solution.
2. Create any map, add random positions for chests and right places for them.
3. If not possible to solve, add extra ways.
3a. Repeat 3.
4. If possible to solve, try to remove several ways.
5. Repeat 4 until no extra ways are on the map: keep ways, that the solver had used.
Hi Darkfrei, it seems like a lot of work but a great challenge too. I think I may eventually try to solve every little piece of the problem one by one with aid from A.I. or not and if I manage to solve all of them and add the wanted procedural level generation feature I will post it here for everyone just in case anyone else find it useful.

Thanks for the steps, not sure I will manage to accomplish but thanks for splitting the problem into more manageable problems.
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

I've recently managed to create a blue noise dithering shader by simply asking chatGPT of how to achieve that. The results are impressive and pleasant to my eyes and I wonder if anyone else could find it useful. It gives a very nice retro feeling that may be useful, specially on pixel art.
Screenshot
Screenshot
dithering2.jpg (125.6 KiB) Viewed 9662 times
Screenshot 2
Screenshot 2
lastdithering.jpg (575.69 KiB) Viewed 9650 times
https://codeberg.org/glitchapp/fish-fil ... enoise.lua

Since the shader will be use in my current project I did not created a specific thread for it. Feel free to use it if you like it!
Attachments
blueNoiseLoveShader.love
ready to use shader
(730.43 KiB) Downloaded 226 times
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

just in case anyone is interested in the shader provided above, I recently added two improvements:
neweffects.jpg
neweffects.jpg (1.14 MiB) Viewed 9606 times
The first screenshot on the left is a blue noise dithering shader which now includes quantization so that the colors are limited and look more retro as it was intended. The one on the right add on top of all of that the possibility of adding a palette texture to simulate the color palette limitations of old retro machines.
results.jpg
results.jpg (364.65 KiB) Viewed 9605 times
Shaders can be found here:

https://codeberg.org/glitchapp/fish-fil ... zblueNoise
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hi, I've recently packaged a reduced version of the game for Windows, Os-X and as AppImage for anyone to test it (there's also a .love file): check details here: https://codeberg.org/glitchapp/fish-fil ... e/releases

There are a few unresolved issues like resolution graphics resize, the exit areas of some levels are missing and other minor bugs, but if you want to do some betatesting please download the full game from source, the reduced version lacks exceptions for some missing content but those are not bugs on the full game.

There is not going to be much more updates from now on, so if anyone is interested to do betatesting, contribute and / or fork / maintain or even port the project this is probably the right moment, otherwise I hope you enjoy it!
User avatar
GVovkiv
Party member
Posts: 686
Joined: Fri Jan 15, 2021 7:29 am

Re: Help implementing game logic from fish fillets

Post by GVovkiv »

glitchapp wrote: Fri Jun 23, 2023 6:58 am Hi, I've recently packaged a reduced version of the game for Windows, Os-X and as AppImage for anyone to test it (there's also a .love file): check details here: https://codeberg.org/glitchapp/fish-fil ... e/releases
Are you tried optimizing assets themselves?
Like "png optimizers" or sound optimizing?
With lossless optimizing you wouldn't save much, but couple megs is still something.
Especially if you not going to add more or edit already existing assets
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests