digidestined23
Posts: 1
Joined: Mon Feb 01, 2016 2:37 am

Help with virtual pet

Mon Feb 01, 2016 2:47 am

Hey everybody I'm actually in need of some help, this was the only way I could find to post and I just got a raspberry pi 2nd edition. My goal is to make an advanced virtual pet and I'm having trouble getting started it being my first time coding and such, if you have an info or tips please email me at jjgamer2234@gmail.com thank you guys I appreciate any help!

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: First time poster, have some general questions

Mon Feb 01, 2016 7:23 am

To digidestined23...

Just a quick point about your posting. What you are doing is referred to as "highjacking" this thread. Perhaps a kind administrator can move it to a separate thread? The problem (for the forum users) is that two topics on a thread make it confusing to read, and make it hard to locate solutions to issues later.

There is a new topic button / link. Use that for new issues. Perhaps you can do that yourself. If you do, post on here that you have done so and we won't be confused by you "double posting". You would have two posts refering to the same issue and people won't know where to post to.

As for your particular question, what you seem to want to do looks well within the range of things the Pi can do. We do need a bit more detail - what have you done so far and where did you get stuck?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Help with virtual pet

Mon Feb 01, 2016 8:50 am

Mod: Split to new topic.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
RaTTuS
Posts: 10753
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Help with virtual pet

Mon Feb 01, 2016 8:53 am

the only virtual pet I know is a tamagotchi
http://tamahive.spritesserver.nl/ is a hive of them
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
gunkan
Posts: 30
Joined: Thu Dec 17, 2015 7:17 am

Re: Help with virtual pet

Mon Feb 01, 2016 11:33 am

It's a nice project to start with. It's funny and educational. You have plenty of information about.

You have to create a state controled system. The base is graph theory.

Language is up to you, but you should separate logic from "view". Python is a good starting point. Javascript/HTML5 is great but i do hate javascript (from the very deep of my developer heart).

In the first version, forget graphics. Use command line and implement the basic commands:
>pet status
I am alive, but hungry
>feed the pet
...eating....
something like that

Good luck!

Heater
Posts: 17478
Joined: Tue Jul 17, 2012 3:02 pm

Re: Help with virtual pet

Mon Feb 01, 2016 11:52 am

gunkan,
Javascript/HTML5 is great but i do hate javascript (from the very deep of my developer heart).
Which is a shame. JS is a wonderful language. Especially if you are juggling multiple concurrent activities, as you might be doing in a bot or "pet" project. Easy for beginners to pick up but sophisticated enough to stretch experts a long way.

Best of all is that you can do your GUI in a browser using JS and modern HTML5 goodies and so your application as stand alone JS using node.js. The magic of JSON and websockets makes it really easy to communicate between the two. Same language everywhere, great.
Memory in C++ is a leaky abstraction .

User avatar
gunkan
Posts: 30
Joined: Thu Dec 17, 2015 7:17 am

Re: Help with virtual pet

Mon Feb 01, 2016 12:17 pm

I am terrible coder and Javascript allows me to write the biggest coding horrors on human development history. In the other hand, if you are a good developer, you can do anything with JS.

I write code for readability, reusability, modularity, security and testability. Not clever enought for Javascript :cry:

Must not be your first language to learn. But maybe digidestined23 will love javascript, it's a capable language for the pet simulator.

Heater
Posts: 17478
Joined: Tue Jul 17, 2012 3:02 pm

Re: Help with virtual pet

Mon Feb 01, 2016 12:34 pm

It's not clear to me that Python or any other language is better than JS at stopping people writing coding horrors.
I write code for readability, reusability, modularity, security and testability.
All worthy goals indeed. And all greatly appreciated in the JS world as well. See the node.js module system for example.
Must not be your first language to learn.
Not sure what you mean there, but JS is certainly the first language learned by many new to programming. By virtue of being used in browsers it is the most widely deployed language ever.
Memory in C++ is a leaky abstraction .

User avatar
gunkan
Posts: 30
Joined: Thu Dec 17, 2015 7:17 am

Re: Help with virtual pet

Mon Feb 01, 2016 12:50 pm

IMHO, C++ or JAVA are better first languages. The rules are more clear and the IDE and compiler will really help you to stop coding errors. When i first used javascript (Netscape Communicator) i already learned C, and Java was just a rumour -at least in my university-.

Even PHP is far easier to read than Javascript, and object model much more clear. PHP 5.X is a joy to code (PHP 3 and 4 got some problems wirh OOP).

Maybe i am too old and purist in the high art of software development. I do hate javascript and only using Jquery lib/framework for the interfaces.

Heater
Posts: 17478
Joined: Tue Jul 17, 2012 3:02 pm

Re: Help with virtual pet

Mon Feb 01, 2016 1:23 pm

gunkan,

I do like a good programming language debate. It's always amazed me people with decades of experience programing experience can arrive at such contrary views of programming languages and language features.

For the record my experience of working in different languages runs something like this:
BASIC, Assembler, ALGOL, C, PL/M, Coral 66, Ada, Lucol, Java, PHP, C++, Javascript. Some of those being. Projects ranging from big length safety critical systems to "web monkey" grade hacking.

C and C++ are where I go for speed and/or small size. I would not suggest C++ for begineers, I don't belive there is a single human being who understands the full complexity of that language and how all it's parts interact. Not even Bjarne Stroustrup himself judging by comments he has made at C++ conferences. Still, millions of people learn with C++ on their Arduinos so there must be a sensible subset in that language.

PHP I promised never to use again after taking over a web site project back in 1998 or so. I'm not sure how it is easier to read. Looks damn ugly to me :)

Java has no reason to exist. We have C++ right? It's total insistence on object orientation is just horrible.

JS is something I casually ignored until quite recently. It's that silly little scripting language web monkeys use to animate buttons isn't it? It's interpreted and slow isn't it?

Then I discovered JS is quite sophisticated. With it's first class functions, lambdas, object system.. it has features that Java and C++ are only just now acquiring.

Then I discover modern JS engines are pretty fast. Early experiments showed that for many applications JS is nearly as fast as C++ !

One can of course apply the "high art of software development" to JS development as much as most other languages. Start by using a linter in your editor and getting your unit tests in place.

JQuery is horrible. It's been kind of necessary to paper over browser difference for a long time and to make the DOM usable. There are better ways today.

If you want object orientation JS now has classes:

Code: Select all

class Polygon {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
  
  get area() {
    return this.calcArea();
  }

  calcArea() {
    return this.height * this.width;
  }
}
Not that OOP is the answer to everything.

Now perhaps we should let digidestined23 get back to his pet project. I'm thinking Python would be a great place to start. Especially as there so many people using it on the Pi and hence a lot of help is available easily.
Memory in C++ is a leaky abstraction .

User avatar
gunkan
Posts: 30
Joined: Thu Dec 17, 2015 7:17 am

Re: Help with virtual pet

Mon Feb 01, 2016 2:36 pm

I like too this debate, but i think we are spoiling the thread :lol: Sorry for my poor english.

I, as you, was there in all the big changes on the software development.

- PHP was a quick sketch in first versions, but now is a full grown system and really powerfull (facebook). PHP 7.0 is pure speed and frameworks like Laravel show the beauty of the PHP code. PHP was the first reason, for me, to not use Javascript. Give me anytime PHP on server vs Node.js.

- I love C, really powerfull. Good old times with Linux Slackware. When i need going to low level, nothing beats Visual C++ (rightnow i am working on bluetooth LE on VC++). Hard? Not really, but the code can get out of your hand easilly. But javascript can go out of control much more easier.

- Java it's good enough and perfect for understanding algorithms. The garbage collector solves one of the biggest flaws of C (at a cost, of course). Android is an example of the past, present and future of Java. The main problem with Java is Oracle :lol: Being able to use java code cross platform is priceless.

- Jquery is a interface oriented development. It gets the job done. Most of the Jquery flaws are part of html and javascript legacy flaws.

- I used javascript in the beggining of the web and now i am using it again. Eagerly waiting for javascript being able to sign local documents (they are working on it right now). This is going to replace the use of java on browsers in Spain in order to use goverment electronic services.

- ECMAScript committee added more and more content to Javascript. But why not solve early problems? I don't really have time to go in detail about all the problems i am finding on Javascript. Just scope of variable type makes me going to the old school days: code and test, code and test, wonder why is not working, try to solve.

If you are brave enought with javascript, go on! I am just so slow minded and stupid for Javascript. I just hope that, in this life on in another, ECMAScript commite found the lost souls of my Computer Science teachers. They will find no solace/relief and will burn in hell for all the eternity :lol:

https://www.quora.com/What-are-some-goo ... ript-jokes

ejolson
Posts: 6670
Joined: Tue Mar 18, 2014 11:47 am

Re: Help with virtual pet

Mon Feb 01, 2016 7:34 pm

Heater wrote:For the record my experience of working in different languages runs something like this:
BASIC, Assembler, ALGOL, C, PL/M, Coral 66, Ada, Lucol, Java, PHP, C++, Javascript. Some of those being. Projects ranging from big length safety critical systems to "web monkey" grade hacking.
Out of curiosity what programs have you written in Algol?
Heater wrote:Now perhaps we should let digidestined23 get back to his pet project. I'm thinking Python would be a great place to start. Especially as there so many people using it on the Pi and hence a lot of help is available easily.
Scratch also seems well suited for a virtual pet project. As a bonus it will be graphical from the beginning. A web search on "scratch virtual pet" shows a number of tutorials how to get started.

fruitoftheloom
Posts: 25839
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Help with virtual pet

Mon Feb 01, 2016 7:50 pm

digidestined23 wrote:Hey everybody I'm actually in need of some help, this was the only way I could find to post and I just got a raspberry pi 2nd edition. My goal is to make an advanced virtual pet and I'm having trouble getting started it being my first time coding and such, if you have an info or tips please email me at jjgamer2234@gmail.com thank you guys I appreciate any help!
As already stated you need to start your own post and supply information, also posting your email in an open forum is an invite to spammers :D
The information is out there....you just have to let it in.

My other Linux machines are a ChromeBox & Intel CoreDuo Desktop

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Help with virtual pet

Mon Feb 01, 2016 7:59 pm

This project can include so many things that people have done with the Pi that it could go on forever :). I would try to find little behaviours that can easily be added, just so I can have a nice stream of successes, rather than create a huge mess that gets so depressing that I'd give up.

Programming graphics can take a while to get right, so I would start with Scratch. Create a nice picture of your 'pet' and it's cage, field or house. Make the pet move from side to side. Make it stop randomly and face the front. Make it say hello when you click the mouse. Make it sleep, eat and drink. Just keep adding behaviours, with some random selection so that it seems independent. Get friends to come and play with it, and see what they think. Scratch has some limitations, when compared to C, JavaScript and other languages, but it can give some quick results. Replace Scratch when you are ready.

When you have a few behaviours, consider using the GPIO to detect lights, movement, or even temperature and respond to them.

There are a few tutorials available that will help you with a lot of that above, but do post again if you get stuck. I am sure many will love to know how you are doing.

Heater
Posts: 17478
Joined: Tue Jul 17, 2012 3:02 pm

Re: Help with virtual pet

Mon Feb 01, 2016 8:23 pm

ejolson,
Out of curiosity what programs have you written in Algol?
Good question.

Thing was that we were introduced to programming by way of BASIC in technical college. That BASIC was running on some mainframe somewhere and we communed with it over a teletype and acoustic coupled modem. We also learned assembler that year on that same machine.

On arrival at university there was BASIC and Algol. Of course I had to learn the latter. I don't recall exactly what I did with it apart from plotting a lot of stuff as part of my physics studies and helping an EE guy write an electronic schematic drawing program. I do recall being reprimanded by the computer centre for hogging the pen plotter too much :)

In my first ever paid work we were given the 6809 microprocessor to build something with. No SBC hardware, no assembler, no support, just the naked chips. The procedure was:

1) Build a circuit board with 6809, RAM, ROM, interrupt controller, serial port etc.

2) Write the algorithms we wanted it to run in pseudo code (ALGOL)

3) Compile that ALGOL into 6809 assembler by hand.

4) Assemble that assembler language into HEX machine code. By hand.

5) Get a young data entry girl to type that HEX onto a paper tape.

6) Load the paper tape to an PROM programmer and blow some PROMS.

7) Plug the PROMS into our board and watch it run. Or not.

We soon had a program loader/debug monitor running on that chip and then the actual project application itself.

More abstractly, I have almost never programmed in anything but ALGOL. You notice that most of the languages I listed in my history above are basically, conceptually, all the same as ALGOL. The syntax varies but the capabilities are the same. It's all, sequence, selection, iteration. Perhaps with object orientation thrown in, which is not all it's cracked up to be.

Not as if they were offering a totally different outlook on programming. Like Lisp, Scheme, Prolog, Haskel and so on.

JS is probably the most radically different language I have ever used, with it's first class functions, lambdas, event driven model, and so on. Want to do "Functional Programming"? No problem in JS.
Memory in C++ is a leaky abstraction .

texy
Forum Moderator
Forum Moderator
Posts: 5172
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Help with virtual pet

Tue Feb 02, 2016 7:37 am

gunkan wrote:I like too this debate, but i think we are spoiling the thread :lol: Sorry for my poor english.
Exactly - please keep it on topic. Lets see what comments the OP comes back with regarding programming language preference although admittedly the initial post is somewhat vague.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “General discussion”