Viewing 20 posts - 101 through 120 (of 134 total)
  • Author
    Posts
  • #27878
    Ed PEd P
    Participant
      @edps
      Forumite Points: 39

      Retro would not be a bad topic addition. Most of the games I purchase are from Gog and fit into the retro category. I have all but given up on modern games as they require two or more hours of concentrated effort, and some idiot games only allow saves at points they specify.

      Retro games + mods are very playable especially some of the Skyrim mods.

      #28029
      TipponTippon
      Participant
        @tippon
        Forumite Points: 0

        Well, I’ve just done my first bit of programming 😀

        I’ve been going through a load of the Codecademy basics, so have only just started the Python course. It’s not as hard as I was expecting, so that’s a bonus. Codecademy seems to skip forward though. One of the tests used concatenation before it was introduced in a following lesson. It was confusing, but there were links to get help, so I got past it. One of the other tests used this:

        exercises_completed = 13
        points_per_exercise = 5
        point_total = 100

        and told me to update the point_total to the existing point_total plus exercises_completed x points_per_exercise, but it had only shown addition and subtraction so far. I created a new variable, but was marked as wrong. I went back to the previous few pages to see what I’d missed, and when I returned to it, the exercise had marked my answer as correct, so I don’t know what their correct answer was. This was how I finished that exercise:

        total = int(exercises_completed)*int(points_per_exercise)
        point_total +=total

        I’ve gone onto the mad libs game now, which really drums in how repetitive programming can be! It’s great though, because I’ve just ‘written’* a game 😀

        Thanks again for the Codecademy links Ed 🙂

         

        *not really written, just copied, but I’m claiming a victory 😀

        #28034
        Wheels-Of-FireWheels-Of-Fire
        Participant
          @grahamdearsley
          Forumite Points: 4

          I am not familiar with Python syntax but as they asked you to “update” point_total you probably don’t need a new variable. The syntax in BASIC would be :

          point_total=point_total+(exercises_completed*points_per_exercise)

          #28042
          Wheels-Of-FireWheels-Of-Fire
          Participant
            @grahamdearsley
            Forumite Points: 4

            The full program in C/C++ would be as below (Note the use of point_total += instead of point_total = point_total but either will work)

            #include “pch.h”

            #include <iostream>

            using namespace std;

            int main()

            {

            int exercises_completed = 13;

            int points_per_exercise = 5;

            int point_total = 100;

            cout << “Old Total = ” << point_total << endl;

            point_total += exercises_completed * points_per_exercise;

            cout << “New Total = ” << point_total << endl;

            }

            #28058
            Wheels-Of-FireWheels-Of-Fire
            Participant
              @grahamdearsley
              Forumite Points: 4

              I just read back my last reply and it seems to be a bit negative, it was not meant to be !

              Keep up the good work ?

              #28060
              Ed PEd P
              Participant
                @edps
                Forumite Points: 39

                If you take a look at the CodeAcademy site the lessons move quite slowly at first which is a good idea. Imo Python is far more idiosyncratic wrt what works and what does not. Getting the syntax under your belt is a good start.

                Some of the Codeacademy tips are pretty good e.g. use spaces rather than tabs as the editors sometimes get confused with tabs versus spaces. (indentation is used instead of the much saner brackets and semi colons.)

                #28061
                TipponTippon
                Participant
                  @tippon
                  Forumite Points: 0

                  I am not familiar with Python syntax but as they asked you to “update” point_total you probably don’t need a new variable. The syntax in BASIC would be : point_total=point_total+(exercises_completed*points_per_exercise)

                  That’s interesting, thanks 🙂 I didn’t think of brackets, and probably wouldn’t have either because they’re used elsewhere. I’ll have a play when I’m on the computer tomorrow 🙂

                  It’s strange to see the differences between the languages for the same task. It makes you realise that they really are languages, and it’s not just a buzzword or something daft.

                  I just read back my last reply and it seems to be a bit negative, it was not meant to be ! Keep up the good work ?

                  Nah, I read it as someone offering advice, which I’m grateful for 🙂

                  One thing that I found weird last night was saving in Notepad++. I saved some examples as .txt files just for reminders, but I saved the game as a .py file. As soon as I clicked save, the text colours changed, and things like brackets were highlighted. Daft as it might sound, it made it feel more like programming than just copying and modifying text 😀

                  #28063
                  Ed PEd P
                  Participant
                    @edps
                    Forumite Points: 39

                    Tippon, once you have played with a few languages you will find similarities across many of them. There are unfortunately  a few exceptions such as Lisp , Forth and APL (insanity personified). However, generally speaking once you are comfortable with one language it is a reasonably simple task to move to another.

                    #28089
                    Wheels-Of-FireWheels-Of-Fire
                    Participant
                      @grahamdearsley
                      Forumite Points: 4

                      Yep Ed. Variables, loops, conditional branches and then array and string handling. After that its mostly language specifics and GCE maths ?

                      #28090
                      Wheels-Of-FireWheels-Of-Fire
                      Participant
                        @grahamdearsley
                        Forumite Points: 4

                        Speaking of language specifics, Atari BASIC has a simple PLOT X,Y command that will put a filled in 8×8 square (CHR$ number something cant remember which) at position X,X as long as you are in character screen mode. Can’t find anything like it for a C console app.

                        #28092
                        Wheels-Of-FireWheels-Of-Fire
                        Participant
                          @grahamdearsley
                          Forumite Points: 4

                          Er position X,Y obviously ?

                          #28093
                          Ed PEd P
                          Participant
                            @edps
                            Forumite Points: 39

                            Tippon,

                            I find that with Python I’m always learning as there are so many different libraries to make tasks ‘easier’.

                            If you have Ubuntu in a VM I recommend that you follow (i/e. copy and paste) the steps in this article to get a Chrome web-driver up and running. You can use Firefox and even IE, but I recommend chrome as there is a lot of code available with Google.

                            Once you have this installed you will have access to Selenium a library that gives you a lot of web page manipulation.

                            I’ll then post a short snippet that will first bring up the BBC web site (and allow you to go through its irritating log-ons/cookie/oks etc), then save the necessary cookies and exit. I’ll also give a second short snippet that opens a fresh BBC web page and loads the cookies you previously saved..

                            This is a bit like having your own web page docker as other than the cookies you deliberately save all other signs of your presence are lost when the python script closes.

                            When you have the required libraries established Python takes very little code to do amazing things.

                            #28096
                            Wheels-Of-FireWheels-Of-Fire
                            Participant
                              @grahamdearsley
                              Forumite Points: 4

                              <p style=”text-align: justify;”>Still don’t know Python but you are going to find that some of the things you thought were commands  are actually calls into functions or classes that must be included to work.</p>

                              #28097
                              Wheels-Of-FireWheels-Of-Fire
                              Participant
                                @grahamdearsley
                                Forumite Points: 4

                                And i still dont want the HTML formatting posts !

                                #28098
                                Ed PEd P
                                Participant
                                  @edps
                                  Forumite Points: 39

                                  Python Libraries are like DLLs i.e a lot of routines. procedures, functions that are bundled together. With a little bit of extra work they will also work in C.

                                  #28119
                                  Wheels-Of-FireWheels-Of-Fire
                                  Participant
                                    @grahamdearsley
                                    Forumite Points: 4

                                    Just going to point out that a DLL is a dynamicly linked library. It is pulled in at run time.

                                    #28120
                                    Ed PEd P
                                    Participant
                                      @edps
                                      Forumite Points: 39

                                      Python is INTERPRETED so everything is at run-time, including .py scripts and so-called compiled .pyc files. A pyc file is still interpreted, it just loads more quickly.

                                      [edit] Python lets it all hang-out and allows libraries to be loaded anywhere you want as long as it is before any calling program.

                                      #28123
                                      Wheels-Of-FireWheels-Of-Fire
                                      Participant
                                        @grahamdearsley
                                        Forumite Points: 4

                                        Ah go play with that then

                                        #28192
                                        Wheels-Of-FireWheels-Of-Fire
                                        Participant
                                          @grahamdearsley
                                          Forumite Points: 4

                                          Well I didn’t exactly have a play but I did look up .PYC files. It looks like Python can compile libraries into an intermediate portable or P Code format to save space and speed the interpratation. Sorry to go on about the out dated Atari BASIC but it does a similar thing by tokenising every line you enter for the same reasons. If you SAVE a program to disc you get the tokenised version complete with variable table but if you use LIST “D:MYPROG.TXT” you just get an ASCII text file that you can reload with ENTER. If you use ENTER then the program gets tokenised as it is read in and merged with any program in memory (as long as the line numbers are different).

                                          #28208
                                          Ed PEd P
                                          Participant
                                            @edps
                                            Forumite Points: 39

                                            Tippon,

                                            as promised if you followed the instructions to load chromedriver or installed chromium and chromium-chromedriver using Synaptic then the following script allows you to set up an instance of chrome that can be either persistent or non-persistent. Enjoy:

                                            ##### Python script follows

                                            #!/usr/bin/python2.7
                                            # -*- coding: utf-8 -*-
                                            # the starting ‘hash-bang’ #! tells the interpreter it must be Python 2.7
                                            # the second tells it that utf-8 encoding is being use. Does not matter here, but sometimes useful

                                            from selenium import webdriver
                                            from selenium.webdriver.chrome.options import Options
                                            # remove next two lines if debugging finished
                                            import logging
                                            from tkMessageBox import showinfo

                                            from time import localtime
                                            from time import time
                                            from time import sleep

                                            # selenium will complain if it cannot find the chromedriver.
                                            #The easy fix is to copy chromedriver to /usr/bin

                                            # set up logging, remove when debugged
                                            logging.basicConfig(level=logging.DEBUG,
                                            format='(%(threadName)-9s) %(message)s’,)

                                            # remove irritating ‘controlled by automation’ bar
                                            # sets up selenium browser, using default path for webdriver
                                            chrome_options = Options()
                                            chrome_options.add_argument(“–disable-infobars”)
                                            # if you remove the following option you get a ‘clean’ browser each time
                                            # If just copying code first make a ‘Data’ folder in the same place as script
                                            chrome_options.add_argument(“user-data-dir=./Data/”)
                                            # sets browser size and position
                                            # not all browser sizes work – depend on site being visited
                                            chrome_options.add_argument(“–window-position=0,0”)
                                            chrome_options.add_argument(“window-size=519,520”)

                                            # put the options in browser
                                            browser = webdriver.Chrome(chrome_options=chrome_options)

                                            # give it a second then move browser
                                            sleep(1)
                                            browser.set_window_position(x=500, y=0)
                                            sleep(0.5)

                                            logging.debug(“Loading BBC Home Page”)
                                            browser.get(‘http://bbc.co.uk&#8217;)
                                            browser.title

                                            logging.debug(“Using old cookies loaded”)

                                            browser.title
                                            logging.debug(“Waiting 200 ticks”)
                                            sleep(100)

                                            # close current web page
                                            browser.close()
                                            # quit
                                            browser.quit()

                                          Viewing 20 posts - 101 through 120 (of 134 total)
                                          • You must be logged in to reply to this topic.