Matlab de Hakken! Fan-made vintage Tamagotchis

TamaTalk

Help Support TamaTalk:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Hey Thanks!

About the sickness thing, that's already fixed. The first hour of gameplay (The Babytchi stage) is now completely implemented. I'm currently trying to implement a basic save system.

About the blurriness, it's bothering me to no end as well but from what I've read there's not much I can do about it (besides using larger sprites of course). I'm keeping this fix for the latter stages.

I'll upload a more recent version later.

 
Here's my latest build:

https://drive.google.com/file/d/11lWpo4eLhYIC8nGedjK_7i4ZH5wJjWgN/view?usp=drivesdk

I think it's pretty much self-explanatory. This time I've actually implemented the P2 game instead of the P1 (@Tamacass).

Only thing you should know is that everything happens based on a timer that keeps advancing when the app has focus and is paused when the app is in the background. Events happen based on this timer, which you can reset by disciplining the tmgc. Babytchi must evolve 65 mins after being born, but in this version it doesn't, and nothing happens after a certain time. So if you want anything to happen after this point you should reset the timer by disciplining tmgc.

 
I used to say that the "catching up" period of my Matlab de Hakken PC app took around 8s for each hour that passed since the user closed the app. I eventually realized that that was completely wrong. My wife's i3 laptop took approximately more than a minute for each hour, which means that if you just close the app at night and open it up in the morning it can take around 10~15 minutes to catch up, which obviously is unacceptable.

I thus decided to work on a smart way to do the catching up and it's turning out to be a really complicated process. Mathematically it can be done without having to guess anything. But to program the behavior is the real challenge. I like programming challenges. However, you probably won't hear from me for a short while as I'm now going to delve into it completely until I figure it all out.

 
Last edited by a moderator:


I used to say that the "catching up" period of my Matlab de Hakken PC app took around 8s for each hour that passed since the user closed the app. I eventually realized that that was completely wrong. My wife's i3 laptop took approximately more than a minute for each hour, which means that if you just close the app at night and open it up in the morning it can take around 10~15 minutes to catch up, which obviously is unacceptable.

I thus decided to work on a smart way to do the catching up and it's turning out to be a really complicated process. Mathematically it can be done without having to guess anything. But to program the behavior is the real challenge. I like programming challenges. However, you probably won't hear from me for a short while as I'm now going to delve into it completely until I figure it all out.
You know what, I think I should get back to this once I've implemented everything else, because an efficient "catching up" mechanic will take quite a while to implement (the more I think about it the more complicated it turns out to be). It reminds me of these riddles one would give you which would keep your mind busy for days and days until you figure it out. (I feel like I'm programming a rubik's cube solver, without knowing how to solve a rubik's cube) I'm pretty sure only research-level programmers actually bother to delve into solving mathematical problems such as this one. Since I'd learn absolutely nothing in Android programming by forcing myself to solve this problem, I'm thinking I should go back to programming all the easy stuff and then I'll get back to it once everything else is done.

 
Last edited by a moderator:
Last edited by a moderator:
So based on the name "event driven simulation", a few videos and a few paragraphs, (and a lot of programming trial and error) I figured out that I didn't need to start reading lessons about Event Driven Simulations or anything. I just took the general idea and tried to apply it to a tmgc. At first I had trouble doing it but then at some point it became so obvious I couldn't think of any other way to do it.

For those interested I'm going to try to explain what the problem was and how I've found my way to solving it. I hope it won't get too tedious.

The problem is, be it in the PC or android version, there has to come a time when the user shuts off the program and/or machine. A real tamagotchi obviously doesn't have this issue but if you're going to code a PC or Android app, having a save feature is mandatory.

But the save feature isn't just your average save feature that just saves the tamagotchi's current state and loads it back up when you re-open the program. It has to actually simulate the passage of time until the moment when the user re-launched the app, to give the user the impression that the tamagotchi was still alive after shutdown.

Now this simulation is what I was referring to as the "catching up" mechanic. When you clicked "close window", the program would just save every necessary bit of info about the tmgc. Upon loading it would calculate how much time has passed since shutdown and simulate every time step from last shutdown to this re-launch. I erroneously said that this took about 8s for each hour that the app was closed, but that was so far from the truth it wasn't even funny. In fact the app took more than a minute to simulate each hour, which might be acceptable for a really patient and dedicated user (i.e. me) on a PC, but for the android app this is just impossible to work with.

So I thought of a way to speed things up by only simulating time instants where something *actually* happened. So for example if all that happened between shutdown and relaunch was the tamagotchi lost a happy heart, just take off one happy heart and let the user play normally afterwards. 

But how do you know what's going to happen when the user leaves without knowing when he/she's going to come back? Easy! you just assume the user is not coming back at all and predict events up until the tamagotchi's death, each event being associated with a given time stamp. If the user comes back after the last event (death) then just give a (creepy and disturbing) death screen. If he comes back before that, find out where in the predicted timeline he has returned and apply all predicted events up to the user's return. Ta-daa.

But then how do you start predicting events? Well, that was the tough part. You might say, "the tmgc still has 3 hearts and lost its last heart 30s ago, so it's going to lose another heart in e.g. 3600-30=3570s." The problem is, a LOT of things can happen to a Tamagotchi that's not taken care of. And some events actually modify the instant when other events happen. For example, if you predicted that the TMGC should lose a heart in 1000s but fall asleep in 300s for 12h, obviously the heart loss should be postponed to 12 hrs later. So the sleep event is an example of an event that modifies the other predicted events and you should pay attention to when the tmgc is going fo fall asleep... if it's not already sleeping that is! The "evolution" event is even more nightmarish because it both depends on previous predicted events (care misses) AND it modifies heart loss instants, sleep/wake up instants etc.

This is hellish, so that's when you need math.

In event-driven simulation, you predict the time when a lot of events (in our case, heart loss, poop, sleep, sickness etc). are going to happen next and only care about the closest one (in time of course). Once you know what the next event will be you can modify the predictions made for other events if necessary. This is an iterative process that in our case is stopped whenever the tamagotchi's death is the next event. As soon as I figured that out I instantly found my way towards solving the problem (and my sanity).

So today I've been able to implement this prediction of all possible future events up until death except for the dreaded evolution event. I'm going to leave that for tomorrow and hopefully start implementing this in the PC or Android version of the app (I'm coding all of this in a separate draft program just to get the hang of things).

Now this was only a part if the whole system, the other one being the process of finding out where we are in the list of predicted events and applying them up to the current tamagotchis state. I'm not too worried about that though, this should be a trivial task.

I wonder if the complexity of the algorithm is the reason why Tamagotchi Simulator 3 and Eternitchi just freeze the passage of time when you close them. What do you think?

 
Last edited by a moderator:
Now this was only a part if the whole system, the other one being the process of finding out where we are in the list of predicted events and applying them up to the current tamagotchis state. I'm not too worried about that though, this should be a trivial task.
Well, it wasn't as difficult as the first part but it wasn't "trivial" either. It took me a while to figure out the simplest method to get this done, and there's still work to be done on the "future prediction" system because I didn't take the Babytchi and the Egg stages into account. The advantage however is that based on a few tests, this algorithm should take less than 5 ms upon closing the app and 5 ms upon reopening it. And it won't take any longer to predict what happened to the Tamagotchi if you've left for 12 hours than if you've left for 10 minutes :)  . That's about more than 100000 times faster!

This project is really putting me to the test but it hasn't heard the last of me. I'm planning to finish the Matlab version before the 15th of December (or as soon as I can really). I've made it a personal goal of mine to finish this project completely, because I got tired of starting projects and never getting them done. I hope I can make it before the next "work thunderstorm" (as I like to think of them) arrives.

Good day or night!

 
After a huge amount of work, I can now say that my faster catching up mechanic is functional. Now don't get me wrong, it's probably still crawling with bugs that I now have to hunt down and fix, but I think as long as the user starts his/her new egg in the day (from 10 AM to around 4 PM) there should be no problem. I'm going to continue working on this for about a week to iron out as many bugs as possible, and I'll be releasing a 3rd build of the Matlab version of the app around December 15th. After that I think I'm going to only focus on Android development, except I make no promise whatsoever on if and when I will be delivering a complete app, because "Winter is coming" at work, and I'm already bracing myself.

 
I think I'm done! :O 
I was far from done but NOW I think I'm done. It's becoming difficult to find any bugs in the game so I think it's a sign that it's almost ready to serve. I'm keeping the "release date" for my 3rd Build to the 15th of December just in case. Besides, I think I should hide my secret character's sprites so you people won't know what it is unless you get it :D  

I know the fact that it's coded in Matlab is kind of a turn off for a lot of you guys, but it's the first time I try to deliver a completely finished product to a large amount of people so I thought it would be wiser to start with what I'm best at. I'm starting to consider doing it all over again in Python using PyGame, but since it's a virtual pet, even having it run efficiently on a laptop/desktop isn't really exciting. If I have the time, I think it's way better to continue working on the Android app I've started.

In any case, I should be busy with work from the 15th onwards and I really don't think I'll be able to make any significant progress on this project, maybe not until July 2021! 😅 Up until then, I hope a lot of you guys will eventually try the app and some of you will even like it O:) (I do think it gets the job done honestly).

I'll be posting the 3rd build in the next few days - it's kind of my Christmas gift to you guys! See you then!

 
It’s awesome how you put this together!

Yet another time I wished I had an Android phone.  :(

Have you considered making an .ipa for iOS devices? I’m not sure what kind of work goes into something like that, I’ll be the first to admit I’m not the most tech-savvy.
Hey thanks!

I'm really sorry for no iOS support yet, but I don't have the slightest clue where to start iPhone development (I've never had anything Apple, a little too pricy for my taste).

I have no plan of doing anything iPhone related yet as I'm only starting Android development, and a lot of work is ahead of me for the next few days, weeks and months.

 
Hey thanks!

I'm really sorry for no iOS support yet, but I don't have the slightest clue where to start iPhone development (I've never had anything Apple, a little too pricy for my taste).

I have no plan of doing anything iPhone related yet as I'm only starting Android development, and a lot of work is ahead of me for the next few days, weeks and months.
alright so I looked it up and apparently it might be easier than I thought:

https://www.devteam.space/blog/how-to-convert-an-android-app-to-ios/#:~:text=You need to do the,an iOS app very quickly.

I'll try to use it and see if it works. If it does you'll have to tell me if it worked for your iPhone

 
Last edited by a moderator:
Alright so Build 3 is here!

I've improved many things from the user interface to some aspects of the gameplay to what's displayed in the console. Only thing I can't do is make the MCR start up quicker, that's beyond my reach!

You'll find everything you need (including instructions on how to setup and start) here:

https://drive.google.com/drive/folders/1Tnx9Gc7V5srS09-wXH-XZNHgw4yb-iYn?usp=sharing

I've added menus so you can reset the Tamagotchi without having to delete the "tmgc_save.mat" file. (The reset option closes the app and you will find a new egg when you re-open it). I've also added basic Help and About menus. And finally there is a "save" button that saves your progress instantly. (The game used to only save when the user leaves, which could potentially be disastrous in case the computer crashes or resets).

I've changed the way evolutions work too. They're still based ONLY on the number of care misses, but now they're a little more forgiving. The way it was, I could never get any character other than the worst care character. 

There's also a trick (that you can figure out on your own if you're just a little tech savvy) to raise as many characters as you want (it involves keeping copies of the file "tmgc_save.mat" under different file names). This trick should be the basis of the next big improvement of the app (don't ask me when it's coming), i.e. allowing the user to raise multiple characters (without manually fiddling around with save files).

About the secret character: Yes.

I've been raising a character for about 5 days now, to find as many glitches as possible. It evolved into a Takotchi yesterday (I hadn't improved the evolution system yet). This is what the app looks like now:

Capture.png

If you want to see more, I'll be logging about it starting from tomorrow. Maybe showing you what the app looks like will make you want to try it for yourself. And if you do and find trouble, do not hesitate to contact me for support!

Have a good day or night!

 
Oh, of course! I’m working from home right now, so I’ll be able to help test whenever.  ^_^
So, I haven't forgotten about you but that website I was talking about is closed. Apparently iOS programming is done in C. I do have experience in C, but what I do not have is 1/time, 2/ an iPhone, so I'm really sorry. :/ 

 

Latest posts

Back
Top