You are browsing as a guest. Sign up (or log in) to start making projects!

Tic-Tac-Cube

  • 29 Devlogs
  • 123 Total hours

A C++ game like Tic-Tic-Toe, except that you're on a Rubik's cube, and can choose to turn a side or rotate the cube instead of making a turn.

Open comments for this post

25m 4s logged

Devlog #29 (57bac36):

Guess what I did:

  • a: Made my code work again
  • b: Add new features
  • c: Complete the button rice
  • d: Look up the GitHub Repo for DeepSeek because I got bored and discover how to add badges to my README.

I had way to much fun doing this (it was d)

2
0
102
Open comments for this post

9h 24m 4s logged

Devlog #28 (ac77900):

I added an entire separate .cpp file for handling buttons because I wasn’t satisfied with how they were working (I love ricing).

Yes, it did take 9 hours. I have a skill issue. There are 3 main things I improved on:

  • The buttons are now more customizable, as they now accept JSON files as setup input instead of like only 4 parameters.
  • A function was added to change the button upon hover
  • It’s more organized since the files are separate.

(I haven’t actually tested the code out yet, I feel pressured to get the devlog out ASAP)

0
0
4
Open comments for this post

1h 19m 11s logged

Devlog #27 (a1b005f):

I highkey have trouble keeping track of what I did between devlogs sometimes, so I’m adding the SHA of the Git commit to devlogs.

So I tried to create a dedicated c++ file for handling buttons, since I wanted to have even more control over them, but ran into the issue of not having a way to share variables across different files. I know global variables are kinda bad, but I mean in this scenario they’re like config stuff that isn’t really going to be that harmful…

Most of the time was spent creating the button.cpp and button.h files, and they’re not even in GitHub yet lol

0
0
14
Open comments for this post

45m 40s logged

Devlog #26:

Pretty short devlog. I added some simple QoL changes: the main menu title is now centered, and the popup and some captions now have a margin around them so they aren’t stuck right on the edge.

Also this was technically done a couple of devlogs ago, but I added shell scripts to compile and run the program so I don’t have to type g++ -std=c++17 -Wall -Wextra -Werror -pedantic -o build/tic-tac-cube src/main.cpp src/board.cpp src/bot.cpp src/logs.cpp -lraylib every single time I want to compile the program.

0
0
18
Open comments for this post

7h 35m 34s logged

Devlog #25:

I tried to make the UI look good. It isn’t necessarily good, but it’s better than it used to be IMO.

I just changed the color scheme, and now the text is round and the boxes are rounded.

I also reworked the board position display system. Since the squares are just buttons, and the button class can display text, I just made the board display text by itself.

For context I wrote the button class to draw and handle buttons. There might be a class for this or something but idc i just wrote it myself like 17 days ago.

0
0
68
Open comments for this post

7h 27m 39s logged

(How is it) Devlog #24 (Already):

Lowkey, when I started this project I was expecting to take 1 week max, and it was supposed to be like practice for making a more advanced project. I’ve since decided to not make the more advanced project (for now). Now, it’s been more than 2 weeks since I’ve started it, and it’s still in rough shape and probably not ready for release.

The UI still sucks, but I added like a popup system for displaying messages, such as telling the user why they won/lost without the win being visible due to the nature of the board being a cube. I was going to make a class to handle all the popups, but I settled for global variables and functions. Probably not the best practice, but it works, and if it ain’t broke don’t fix it.

I also added a entire new menu, the help menu. It could probably use some improvements, so if you have anything you’re curious about or confused about, drop a comment. There’s like 8 people that have seen this project, so I’m really expecting anything, but it would be appreciated greatly.

I lowkey forgot to add one break statement, so I spent like 30 minutes trying to figure out why it wasn’t working

Still, how the hell did this take 7 hours? I swear I’m not inflating my time by any means.

0
0
15
Open comments for this post

2h 28m 8s logged

Devlog #23:

“Minor” improvements that take like hours to do is literally my entire C++ learning experience so far. This time, I improved the “wild card” function that rotates the cube randomly. Before, it just actually rotated randomly, and now, I changed it to check and make sure that moves it makes does not cause the opponent to win on the very next move.

fyi i DO write these devlogs myself without ai, I just literally need Vim keybinds to function as a person and therefore type all the devlogs inside of NeoVim before pasting them into the devlog. felt like writing this after i discovered that the “please write this yourself, humans read it” text at the bottom actually flashes red when you paste text.

0
0
10
Open comments for this post

3h 26m 55s logged

Devlog #22:

I made the buttons look nicer by centering the text inside of them. It was much harder than it looked and I had to work with “Vector2” in Raylib. I may or may not have spent like half and hour trying to find documentation on it, only for me to discover that it’s a struct inside of Raylib. Still not entirely sure what a struct is. So I may or may not have spent another half and hour trying to declare the struct inside of the main.cpp file, before I finally gave up and asked DeepSeek. Turns out, it’s just Vector2 something{(float)x, (float)y}. It’s not exactly simple if you don’t have much experience with C++, but I started coding in C++ 16 days ago and I understand it just fine.

Halfway through, while testing, I accidentally overrode the main file and had to restore it and re-add all the changes I make. I don’t like committing before the program doesn’t have that many bugs, so a lot of progress was lost. This is like the second time I’ve done this, and if you’re curious what I did, well… The command used to compile my program for testing is g++ -std=c++17 -o build/program src/main.cpp src/board.cpp src/bot.cpp src/logs.cpp -lrayib. This compiles the code for all the C++ files and the Raylib library, and creates and executable inside the build/ directory. Except I forgot to type build/program, and so GCC just overrode main.cpp. Honestly though, it didn’t do that much harm, thanks to the test.cpp file having a similar version of code as the code that was overridden, and also git.

hackatime isn’t working so i can’t even post this devlog

nvm it just worked

nvm it broke again

honestly this is one of the first times anything has broken in my experience as someone who joined hack club like 3 months ago. im sure everyone involved in fixing this is trying their absolute best.

0
0
12
Open comments for this post

2h 29m 29s logged

Devlog #21:

I am very very very very bad at debugging code. Somehow I managed to fix the major rendering bug and also make the fork handling better within 2 hours. I don’t believe I’ve mentioned anything about it before, but there was a rendering glitch upon the bot winning the game right after the user has made a cube turn that allowed the bot to win the game. I’m still not sure wy that happened, but I fixed it by re-rendering the entire board before drawing the board position again. If that didn’t make sense to you, it doesn’t make much sense to me either. If it did, well good for you ig.

I feel like the fork handling deserves and entire paragraph, so here:

I changed the win blocking function to also log the direction that potential win is in, by logging “position 1” of that specific potential win. The possible neutralizing moves of the directional indicator value is then compared against the potential win location neutralizing move to try to find a match. If a match is found, that means that the move is guaranteed to neutralize the given threat.

That paragraph did not make much sense, even to me. If you read my code, it’ll probably make more sense, as long as you do not get permanent brain damage from reading the it (I need to learn how to write better code)

0
0
69
Open comments for this post

9h 24m 44s logged

Devlog #20:

I abandoned searching for potential forks and stopping them from ever forming in favour of handling forks that have already been formed. After more than one win for the opponent is detected, the bot registers that it is a fork. It then calculates which moves are best to neutralize the threat. There are four ways for each single win to be neutralized, so I need to make one of these four moves, for each of the two cases. In some cases, one or more of the moves overlap, in which case the overlapped move will be immediately returned, but most of the time, the bot just picks from one of the 8 possible neutralization moves randomly.

This is definitely less efficient than just figuring out how to prevent forks from ever forming, but I mean it’s a good implementation for the cube part of this game.

(Sometimes it messes up and I just win instantly)

0
0
26
Open comments for this post

5h 10m 6s logged

Devlog #19:

In an effort to procrastinate fixing the bot fork bug while still doing something useful, I 1) took a 2 day break from this project to work (and ship) something else, and 2) fixed a very annoying bug where the user would be X every single time. I solved the issue by switching from older, more C-like rand() from cstdlib to the more modern #include <random>. I highkey copied the code from Stack Overflow, but at least it’s better than relying on AI.

That solved like half of the problem, but then I discovered that I wasn’t actually resetting the board properly when manually exiting a game, since I was looking through the logs. I made the logs are procrastination, but they’re actually really nice.

In case you were wondering btw, most of the time logged in this devlog was spent on trying to fix the fork bug, but I’ll make a dedicated devlog only when I’ve actually fixed the bug.

0
0
35
Open comments for this post

3h 57m 9s logged

Devlog #18:

I worked on the logs even more, and now they are in separate files. You wouldn’t believe the amount of time this took me. Evidently, I’m not a very good C++ dev, and when I was searching on Stack Overflow and other sites, I kept running into things I don’t understand like &, auto, and probably many others. So of course, I resorted to coding my own functions at the most low level C++ possible without actually being totally backwards compatible with C.

Essentially, every time the game starts, function runs that tries to generate a log file with the current time. There is a theoretically possible edge case where the user opens the project more than once in a single second, so I added some code to make absolute sure not to override any existing files. That took me like at least 15 minutes to half and hour, for an edge case that probably can only happen in testing, and that will not actually affect the game at all. Yay, what great decision making skills.

I still haven’t fixed the fork detection and response function, but at least I can now have a way to find out what is going wrong. The only progress with finding out what is wrong is just narrowing the error location down to the function where I already knew there was going to be an error. Yay.

0
0
10
Open comments for this post

2h 3m 47s logged

Devlog #17:

Guess what I did today: a) fixed the fork, b) optimized UI, c) hunted bugs, or d) added a random new c++ file for the sole purpose of logging information because I don’t want to use an IDE or configure NeoVim.

The answer, of course, is D. I really need a way to figure out what is happening inside my code. Even though I wrote the code, it’s still kinda a black box to me, so I need to have some logs to figure out why the program is not working as expected. I have yet to actually implement the function or add out a way to have different logs files for different sessions though, I’m doing that next.

0
0
9
Open comments for this post

8h 21m 49s logged

Devlog #16:

I added creating and defending against forks. One of my previous projects, Gomoku Balanced, had some decent defense and offense, which was even able to beat some people, according to the reviews on my ship. The one thing it was missing was the ability to detect potential forks and combat them, which was why I was able to beat it almost every single time. This bot, however, will not be the same. Mostly because the board is kinda small. I literally just added every single possibility of a fork to the to the bot.

I just got notified that I have like 8 hours without a devlog, and since I am horrible at coding, the bot function I’m working on isn’t even working yet. I’m also just not getting it done within 2 hours. The function is supposed to block the fork, but it doesn’t work for some reason. DeepSeek (AI) gave me a list of 20 reasons it’s breaking, but I’m not about to blindly trust AI. I mean it doesn’t raise any errors, so that’s good. For me at least, I spend a lot of time just trying to get the code to compile properly. And in this case, even when the code compiles, half the time it just runs into a runtime error and crashes.

The bot crashed like 20 times. They were all runtime errors, and I use C++, so I have absolutely no idea where the error occurs. Also, I want to be different, and therefore I use NeoVim, and since I don’t want to spend time that I could be building actually good projects for Stardance in the time it takes to configure NeoVim, and therefore I can’t see any warnings or errors. I did try using CLion and VSCode, but CLion takes up a lot of RAM and VSCode is made by Microsoft (and VSCodium and Code OSS don’t have that many plugins). Also, when I was using CLion, the errors didn’t really appear… and CLion also does a bunch of stuff and creates a bunch of mysterious files. I don’t really like doing stuff without knowing what they do, so I just ditched CLion altogether.

Did I seriously go on a paragraph-long rant about how using NeoVim leads to not being able to know why my code sucks? Is the paragraph-long rant in question also probably longer than the entire rest of the devlog? (Yes and yes);

Anyway you still can’t tell that I made any changes to the bot from a single screenshot, so I’m just going to attach one of my old ones.

0
0
13
Open comments for this post

2h 8m 43s logged

Devlog #15:

I updated the bot to give it two of the most important features: winning the game, and trying to prevent your opponent from winning.

This was done by saving every single possible way to have a two-in-a-row on the board, connected and disconnected, 24 possible combinations in total. And of course, because I’m not experienced enough to do it any other way, it was all written by hand. And since I don’t like using AI, and don’t really trust it, I wrote all of it myself, and used only used AI to check that I didn’t mess something up.

Now how the hell do I make it detect forks….

0
0
9
Open comments for this post

6h 25m 48s logged

Devlog #14:

In search of a better way to make a bot, I went on the world’s most reliable website: Wikipedia- and struck gold. The page on tic-tac-toe contains a strategy section, containing the optimal strategy that always leads to a draw. Of course, my game isn’t actually the same as Vanilla tic-tac-toe, so the player will probably still win most of the time. I haven’t actually implemented most of the rules, only the last few that are the least important. In my defense, they were the easiest to make. I did kinda struggle with the bot trying to mark a place that already has been placed, and it took like half and hour for me to figure that out.

IDK what I should do for the screenshot, you can’t really tell that I changed anything.

1
0
15
Open comments for this post

6h 47m 38s logged

Devlog 13:

I spent like 6 hours making the bot, and it’s absolutely stupid. I made two ways to get a move: scanning for 2-in-a-rows, and placing randomly. Even though the 2-in-a-row scan runs first, it still only plays randomly. As of right now, the bot has never won a single game against me and is always O for some reason. I probably messed up the setup code.

but at least i made something that are somewhat functional…..

(I was writing this devlog and trying to get a screenshot of the game, and somehow it actually worked and blocked my move somehow, IDK if it was a coincidence)

0
0
5
Open comments for this post

2h 3m 18s logged

Devlog #12:

So I was going to implement the singleplayer mode, but turns out there was still a bunch of bugs and inconveniences that took me upwards of an hour to fix. Also, I lowkey put a break statement somewhere I shouldn’t have, and got the programming equivalent of a short-circuit.

In the end, it did work fine, and now I actually will build the bot and singleplayer mode.

0
0
9
Open comments for this post

7h 56m 5s logged

Devlog #11:

I was going to make a singleplayer mode for the game, but somewhere along the way I kinda messed my code up a lot, and had to undo nearly 6 hours of changes since the last devlog.

I then spent like an hour fixing bugs and trying to organize code, mostly by moving code that could/should be reused. I’m going to start writing more functional code for singleplayer now :)

Also I switched from Vim to NeoVim in case you care, and since not a lot of changes were actually implemented, Imma just attach a screenshot of a file opened in NVim

0
0
6
Open comments for this post

1h 20m 36s logged

Devlog #10:

I added an endscreen to the game. Before, when you won the game or lost the game, it would just go back to the main menu. Now, it displays a message according to which side won the game, and pauses for exactly one seconds before exiting back to the main menu. It probably still can be confusing since there’s no indication of where in the board the sequence that won the game is, and there is still a possibility that a cube rotation wins the game off the board, and I have no idea how to make more clear to the user what happened to win the game.

0
0
7
Open comments for this post

2h 25m 59s logged

Devlog #9:

I added colors to the game. Colors are a crucial part in Rubik’s cubes, so it just makes sense to add it to this game, yknow.
I basically just copied the code that rotates the board positions that I had to spend like 6 hours coding , and made it work with colors. Not actually that hard, but still almost made me go insane with how much mindless typing I had to do. It’s funny that when I am stuggling with things like using my brain and fixing broken code, I would like nothing more than some mindless coding, but now that I actually am doing this stuff, I am just wanting to do anything but.
UI still looks ugly as hell, need to improve that later.

0
0
11
Open comments for this post

2h 25m 47s logged

Devlog 8:

You can finally actually interact with the GUI. You can click the red squares to place an X or an O, or click on one of the white squares to rotate the cube. It’s kinda bad right now, and if you click one of the cube rotation things longer than 33 milliseconds, it will move several times. I mean, it’s good enough, I guess, apart from the fact that it looks… (I don’t know enough english to come up with a word that’s good enough, and my english grade in school is 95%)

0
0
7
Open comments for this post

6h 4m 29s logged

Devlog #7:

I got the GUI working for the game. I mean, technically, to be a GUI you have to be able to interact with it, and in it’s current state, uh you can’t really do anything and you’re just stuck there forever. I mean unless you decide to close the game window or press escape (which closes the game window). Ideally, I would like for the escape key to not close the window, but whatever at this stage it really does not matter.

List of stuff I need to do:

  • Make it so that the user can actually interact with the game.
  • Make a bot or something
  • Make the UI nicer
  • Put in on Itch.io

this actually looks kinda intimidating. what have i gotten myself in to

0
0
8
Open comments for this post

4h 55m 33s logged

Devlog #6:

I got a working GUI for the main menu! This is my first GUI that is actually like usable, but since the actual gameplay doesn’t have a GUI yet, it does nothing except closing when the exit button is pressed. I made the UI with Raylib, and apart from the occasional existential crisis, everything went pretty well.

now how the hell do i make the actual game ui

0
0
11
Open comments for this post

2h 28m logged

Devlog #5:

I added a main menu to the game. It’s still only Text UI, so it may not make sense why it took so long, but I moved all the functions inside a class, make a header file so that the class can be accessed in other C++ files, discovered that it doesn’t work, had an hour long conversation with deepseek about why this didn’t work, and finally got it working- just to implement one feature that would’ve taken like 5 minutes had I just made everything in one file. At least it’s going to be organized for when I add the GUI or other features.

0
0
6
Open comments for this post

3h 25m 47s logged

Devlog #4:

You can now actually win the game! I wrote a function that scans all the possible ways to win on every face, with amounts to 6x8=48 possible combinations. So there’s a chance that you rotate a face of the cube, and win or lose instantly due to the face you rotated to already having like 2 in a row.

Now, I just need to make the GUI, not sure how I’m even going to implement it. I know 2 of the options are Raylib and SDL2, but I honestly have no idea which one to pick.

0
0
12
Open comments for this post

3h 30m 39s logged

Devlog #3:

I made the cube turning mechanic. Although I have made programs like this before (like my CubeTrainer), I struggled a lot with making the code, especially the Z function, and the two functions that depend on it, L and R. This was entirely human error and typos though, and not really like intellectually challenging.

So I added the ability to turn the cube finally. Most of the main features of the game are done now, I just need a GUI, main menu, bot, and… lowkey ran out of ideas so yeah.

To be very honest, my experiences with GUIs in C++ is limited to drawing a single dot in sdl2, and that took me 3 hours to do. And I lowkey cannot find any tutorials on SDL2 that can satisfy my attention span. I am very much someone that learns by doing, and most SDL2 tutorials I found just tell me to copy and paste code word for word.

0
0
10
Open comments for this post

3h 51m 12s logged

Devlog #2:

This is like my 3rd day of serious C++ coding, and I’ve already build a functional version of tic-tac-toe. That wasn’t really supposed to be impressive, but I am kinda surprised I managed to pull this off so quickly (by my standards, for context it took me like 3 year to make an actually decent Python project).

So yeah, I made tic-tac-toe. So far it only works in the terminal as I have no idea how to make a functional GUI in C++. There are also safeguards in place to prevent placing where it’s already marked or out of bounds. I still need to implement rotating the cube, but that can’t be that hard….

0
0
15
Open comments for this post

2h 22m 10s logged

Devlog #1:

I suck at C++, so I decided to make tic-tac-toe on the different faces on a Rubik’s cube. Right now the program just prints out the default position (all blank), and you can’t change it or anything.

Yes, this took me two hours. There were a lot of bugs and I have almost never used C++ before (I had to google how to output text like twice)

0
0
10

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…