• Welcome to the Fable Community Forum!

    We're a group of fans who are passionate about the Fable series and video gaming.

    Register Log in

Programmers here?

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
Well, it's the internet, so I'm going to go ahead and assume that there are people here who know some programming.

Basically I'd like to learn how to program (from the beginning, the most code I know is basic HTML), and hopefully move onto developing for Android and Raspberry Pi as a hobby. Just wondering if anyone here knew the best language to learn/way to go about it?

The Raspberry Pi apparently uses Python predominately, so I'm leaning towards that to start with, but I don't really understand how it all fits together.
 

Lenop

Boyish member
Joined
Sep 13, 2012
Messages
134
Reaction score
117
Points
90
Age
37
The first language is the hardest. Once you know the fundamentals of programming, how it works, you'll be fine learning something else. It's just the part about learning to think like a programmer instead of like a human (note, programmers are not human), that's a big chunk of the uphill part of the learning curve.

Do what I did. I found a project that interested me, I was dicking around with the source of some modding tools I used often, and they were written mostly in C#. So I learned a little bit of C#. Of course I didn't understand the source, that's why I had some C# tutorials and references in my bookmarks, to teach me the basics so I could start to understand the source. If I used just the tutorial, I'd have gotten bored with it. If I used just the source, I'd learn very slowly if at all, I wouldn't understand anything and even if I did I'd only know how the tool worked. The combination is important. It provides a starting place and a goal.

Very important to take those baby steps, don't get too far ahead of yourself because you'll easily get frustrated and start thinking about quitting.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
The first language is the hardest. Once you know the fundamentals of programming, how it works, you'll be fine learning something else. It's just the part about learning to think like a programmer instead of like a human (note, programmers are not human), that's a big chunk of the uphill part of the learning curve.

Do what I did. I found a project that interested me, I was dicking around with the source of some modding tools I used often, and they were written mostly in C#. So I learned a little bit of C#. Of course I didn't understand the source, that's why I had some C# tutorials and references in my bookmarks, to teach me the basics so I could start to understand the source. If I used just the tutorial, I'd have gotten bored with it. If I used just the source, I'd learn very slowly if at all, I wouldn't understand anything and even if I did I'd only know how the tool worked. The combination is important. It provides a starting place and a goal.

Very important to take those baby steps, don't get too far ahead of yourself because you'll easily get frustrated and start thinking about quitting.

Yeah, I definitely agree with focusing my learning towards something I enjoy and can easily achieve. Wanting to learn is probably 80% of learning something. I know the dangers of directionless theory from my days studying music, so defs gonna keep it exciting.

What about the overall big picture though. From what I'm reading, every language seems to be based more or less on C. Would it help to start with a more universal language than a more narrowly scoped fork? Does it really matter? Why does someone choose one particular language over another? Are there specific things that are easier or can only be done in certain languages, or is it just down to personal preference?

I reckon Google had some nice guides available, worth checking out if you don't know the very basics.

https://developers.google.com/edu/python/
https://developers.google.com/edu/c /

I was probably going to go down a Youtube based thing with a little written theory to support it. I'm more of a visual person so reading walls of text, even with pics, probably wouldn't help me too much. What do you think of Python as a language?
 

DarkONI

The Shadow Modder
Premium
Joined
Jul 15, 2010
Messages
1,367
Reaction score
282
Points
275
What do you think of Python as a language?
I think it's a solid language, and a good way to learn programming. (Has a huge community, lots of guides, textbooks, classes, conferences and all that) Plus it's used pretty much everywhere.

However, as Lenop said, C# is a good start, too.
 

Lenop

Boyish member
Joined
Sep 13, 2012
Messages
134
Reaction score
117
Points
90
Age
37
Would it help to start with a more universal language than a more narrowly scoped fork? Does it really matter?
No and yes. This is a common but very good question to ask. A lot of people want to start with C++ or C#, for example, and think that they'll gain advantage by starting with C. This is incorrect. For people new to programming, this can cause a lot of confusion. For example, if I learn C first, then go on to C++, I will still be trying to do things the C way when C++ has better and more effective ways of taking care of business. Think logic here, if C was ideal for everything, people wouldn't have made a billion other languages out of it.

Why does someone choose one particular language over another? Are there specific things that are easier or can only be done in certain languages, or is it just down to personal preference?
Personal preference has a lot to do with it when it comes to similar languages. If two languages can both do the same thing, of course I'll use the one I'm more comfortable with. But some languages are, as you suspect, better at doing specific things... C++ and C#, both are good languages used for all sorts of things, for instance, Fable modders might be interested in knowing that both were used to create Fable Explorer. This is because C++ was faster for the math and data end of things, including handling the datatypes as C# doesn't support a lot of the stuff needed. At the same time, C# was ideal for handling the graphics end.

I was probably going to go down a Youtube based thing with a little written theory to support it. I'm more of a visual person so reading walls of text, even with pics, probably wouldn't help me too much. What do you think of Python as a language?
Python is a pretty good pick for a first language. It's particularly good for scripting, and it can be used for tons of things, crazy adaptable. But again, what matters more is what you'll be using the language with - if you lose interest you only hinder your own progress.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
I think it's a solid language, and a good way to learn programming. (Has a huge community, lots of guides, textbooks, classes, conferences and all that) Plus it's used pretty much everywhere.

Python is a pretty good pick for a first language. It's particularly good for scripting, and it can be used for tons of things, crazy adaptable. But again, what matters more is what you'll be using the language with - if you lose interest you only hinder your own progress.

Ok, so I'll go with Python then. Next thing: what program do I get to start messing around in it?
 

Lenop

Boyish member
Joined
Sep 13, 2012
Messages
134
Reaction score
117
Points
90
Age
37
First you need to decide between Python 2 and Python 3. If you are going to be working on something already in development, you definitely want to check out any literature that comes with it. Otherwise, if you just want to dick around and tinker on some things for yourself, Python 3 would probably be the better of the two choices.

The really cool thing about Python, and I wish more folks would do stuff like this, it comes with its own help and reference stuff. For example, download Python 3.3 or whatever the most recent one is and install it, then run python.exe. It says type help. Type help. It tells you to type help(). It's already turning you into a programmer. As for where to get this program, Python's site.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
Alright guys, prepare to be proud. I wrote a bit of code to tell you what the score of a scrabble word is going to be:

Code:
from sys import argv
from string import maketrans
 
i = 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
o = '0' '2' '2' '1' '0' '3' '1' '3' '0' '7' '4' '0' '2' '0' '0' '2' '9' '0' '0' '0' '0' '3' '3' '7' '3' '9' '0' '2' '2' '1' '0' '3' '1' '3' '0' '7' '4' '0' '2' '0' '0' '2' '9' '0' '0' '0' '0' '3' '3' '7' '3' '9'
t = maketrans(i, o)
 
def main():
  try:
    print sum(int(x) for x in argv[1].translate(t)) + len(argv[1])
  except IndexError:
  print 'Type a word, you shmuck'
 
if __name__ == '__main__':
  main()

I had to make each letter worth one less point and then add the length of the string, because the maketrans function didn't want to translate a single letter into a two digit number for the letters worth ten points. I also had to replace the if and else statement with a try and except, because I couldn't find another way to say "do this if I don't type anything".

EDIT:

Now I've made it so you can use the words with friends scores by putting -w before the word

Code:
from sys import argv
from string import maketrans

i = 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
s = '0' '2' '2' '1' '0' '3' '1' '3' '0' '7' '4' '0' '2' '0' '0' '2' '9' '0' '0' '0' '0' '3' '3' '7' '3' '9' '0' '2' '2' '1' '0' '3' '1' '3' '0' '7' '4' '0' '2' '0' '0' '2' '9' '0' '0' '0' '0' '3' '3' '7' '3' '9'
w = '0' '3' '3' '1' '0' '3' '2' '2' '0' '9' '4' '1' '3' '1' '0' '3' '9' '0' '0' '0' '1' '4' '3' '7' '2' '9' '0' '3' '3' '1' '0' '3' '2' '2' '0' '9' '4' '1' '3' '1' '0' '3' '9' '0' '0' '0' '1' '4' '3' '7' '2' '9'
s = maketrans(i, s)
w = maketrans(i, w)


def main():
  
  try:
   if argv[1] == '-w':
    print sum(int(x) for x in argv[2].translate(w)) + len(argv[2])
   else:
    print sum(int(x) for x in argv[1].translate(s)) + len(argv[1])
  except IndexError:
   print 'Type a word, you shmuck'

if __name__ == '__main__':
  main()
 

Lenop

Boyish member
Joined
Sep 13, 2012
Messages
134
Reaction score
117
Points
90
Age
37
I like your exception handler. This is the start of something good. Might I recommend...
Code:
def main():
    game = 0
    score = 0
    game = input("W for Words with Friends; S for Scrabble. Uppercase please.\n")
    word = input("Type your word, uppercase only.\n")
    SVALUES = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10]
    WVALUES = [1,4,4,2,1,4,3,3,1,10,5,2,4,2,1,4,10,1,1,1,2,5,4,8,3,10]
    for i in range(len(word)):
        rank = ord(word[i]) - ord('A')
        if game == "W":
            score = score + WVALUES[rank]
        else:
            if game == "S":
                score = score + SVALUES[rank]
            else:
                print("User error, program will now crash.")
    wait = input(score)
main()
Very basic. Can be messed with a bit to look prettier and be friendlier. Wanted to figure out a way to award points for using all seven letters (50 for Scrabble, 35 for WwF) but I remembered you can simply add a single letter to make bigger words. For the same reason I didn't block using words longer than seven letters.

My python is rusty. And I mean that in a non-naughty way.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
I like your exception handler. This is the start of something good. Might I recommend...
Code:
def main():
    game = 0
    score = 0
    game = input("W for Words with Friends; S for Scrabble. Uppercase please.\n")
    word = input("Type your word, uppercase only.\n")
    SVALUES = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10]
    WVALUES = [1,4,4,2,1,4,3,3,1,10,5,2,4,2,1,4,10,1,1,1,2,5,4,8,3,10]
    for i in range(len(word)):
        rank = ord(word[i]) - ord('A')
        if game == "W":
            score = score + WVALUES[rank]
        else:
            if game == "S":
                score = score + SVALUES[rank]
            else:
                print("User error, program will now crash.")
    wait = input(score)
main()
Very basic. Can be messed with a bit to look prettier and be friendlier. Wanted to figure out a way to award points for using all seven letters (50 for Scrabble, 35 for WwF) but I remembered you can simply add a single letter to make bigger words. For the same reason I didn't block using words longer than seven letters.

My python is rusty. And I mean that in a non-naughty way.

Yeah I wanna figure out how to get the scoring to work better. Like it makes sense that if you're gonna put that letter on a double or triple letter score, type two of three of that letter? Maybe add an if for a word multiplyer.

I've also just finished with this similar one. It's much more useful:

Code:
from sys import argv
from string import maketrans
from itertools import permutations
from pprint import pprint
 
i = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
s = '0221031307402002900003373902210313074020029000033739'
w = '0331032209413103900014372903310322094131039000143729'
s = maketrans(i, s)
w = maketrans(i, w)
 
# gets the permutations of the word, and turns it into a readable list.
set1 = set(map(''.join, permutations(argv[1])))
sowpods = open('/home/daniel/Python/sowpods.txt').read()
 
def main():
  for str in set1:
  if '\n' + str + '\n' in sowpods:
    print str
    print sum(int(x) for x in str.translate(s)) + len(str)
  else:
    del str
 
if __name__ == '__main__':
  main()

It will search the official scrabble dictionary (which I downloaded), and see which combinations of letters are acceptible, and how many points they're worth. I'm actually super chuffed, because now I can cheat at words with friends.

EDIT: actually I just realised I can only cheat at scrabble. I dont have an argument that tells it to use the WwF translation.

EDIT2: Ok so I cleaned it up and added a WwF argument:

Code:
from sys import argv
from string import maketrans
from itertools import permutations
from pprint import pprint
 
i = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
s = '0221031307402002900003373902210313074020029000033739'
w = '0331032209413103900014372903310322094131039000143729'
s = maketrans(i, s)
w = maketrans(i, w)
 
#the dictionary to search through.
sowpods = open('/home/daniel/Python/sowpods.txt').read()
 
def main():
  if argv[1] == '-w':
  set1 = set(map(''.join, permutations(argv[2])))
  for str in set1:
    if '\n' + str + '\n' in sowpods:
      print str
      print sum(int(x) for x in str.translate(w)) + len(str)
    else:
      del str
  else:
  set1 = set(map(''.join, permutations(argv[1])))
  for str in set1:
    if '\n' + str + '\n' in sowpods:
    print str
    print sum(int(x) for x in str.translate(s)) + len(str)
    else:
    del str
 
if __name__ == '__main__':
  main()

Next thing is to make it find permutations of strings of varying lengths, so that it will find ALL possible words. EG find out that you can play 'gay' and 'raw' when you input 'GYAWRFW' or whatever.



Hehe, gay and raw.
 

Lenop

Boyish member
Joined
Sep 13, 2012
Messages
134
Reaction score
117
Points
90
Age
37
I'm actually impressed. I'm glad you're still interested in it. Honestly, you've probably walked over the bodies of millions of people with some distorted idea of what programming is supposed to be who all lost interest about an hour into the first day of learning.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
I'm actually impressed. I'm glad you're still interested in it. Honestly, you've probably walked over the bodies of millions of people with some distorted idea of what programming is supposed to be who all lost interest about an hour into the first day of learning.

Well I kinda already knew how it worked, the basic structure of it. I really just needed a syntax and vocabulary to learn.

I've actually completed it properly now. It will tell you all the possible acceptable words below 7 letters in length, out of the string you give it. Now I have to figure out how to work in the scoring for it.
 

DarkONI

The Shadow Modder
Premium
Joined
Jul 15, 2010
Messages
1,367
Reaction score
282
Points
275
I've actually completed it properly now. It will tell you all the possible acceptable words below 7 letters in length, out of the string you give it. Now I have to figure out how to work in the scoring for it.
Keep it up, I hope you are finding all this fun though.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
Alright guys, I've decided I wanted to move onto a "harder" programming language than Python. I decided on c++ as it's more ubiquitous. I wrote this (after many many many hours repeatedly yelling "WHY WONT IT WORK" and then realising why I was an idiot). Let me know if my comments actually reflect what the line does. I had the most trouble getting the while loop to do what I wanted.

Basically all it does is ask you for a word and tells you whether it's in the dictionary or not.

Code:
#include <iostream>
#include <string>
#include <fstream>
 
using namespace std;
 
int main(){
    cout << "What's your word?\n";
    //Definitions
    ifstream sowpods; // says that the sowpods variable is an input file (which allows it to use the open function
    sowpods.open ("sowpods.txt"); // says that the value of the "sowpods" variable is the contents of the sowpods.txt file
    string str; // says that the "str" variable is a string
    string sow; // says that the "sow" variable is a string
    cin >> str; // says that the value of the "str" variable is the console input
    // Checker
    while(getline(sowpods, sow)){ // 'getline' says to get every line from the sowpods variable, assign each line to the value sow, and 'while' says that while the getline function is 'true'
    if(sow == str){
        cout << "'" << str << "'" <<" is a word.\n";
        main();
        }
    }
    cout << "'" << str << "'" << " is not a word.\n"; // output this if the while loop terminates without finding a word
    main();
}
 

Dark Drakan

Well-Known Member
Guildmaster
Town Guard
Premium
Joined
Feb 6, 2006
Messages
18,656
Reaction score
2,306
Points
365
Age
38
It is something im going to get into soon also, should have done it a long time ago and originally went to college to learn it. However the damn lecturer left before the course started and I ended up having to do a different one, now if I can learn some C++ and find my way around VB.net ive been offered a job so I have got to pick some of this up & fast. At the min it still melts my brain because its been so long since ive done ANY sort of programming that things have moved on from what I knew. Started to make me feel like some relic that is just getting with the times. :lol:
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
andee u jst rite stuf nd it maeks stuf werk its rly ezy
 

ByronT

Your health is low.
Joined
Dec 18, 2012
Messages
7
Reaction score
4
Points
24
Age
45
This is also something I've been looking into recently, mainly due to an interest in some serious nuts'n'bolts modding of Fables 1 & 3, and Black and White. So thanks also for the good advice.
 

Arseface

Look at me still talking when theres science to do
Premium
Joined
Dec 28, 2006
Messages
5,471
Reaction score
813
Points
315
Ok guys, just an update for all you who are avidly following my fledgeling new hobby. I've started on a thing called Project Euler. It's basically a website which shows you a bunch of problems (mostly of a mathematical nature) and you have to write a program to solve it. I'm working through it in C++, Java and Python, (C++ and Java are easy, I can basically copypaste the code between them), and am up to Problem 11. Some examples of the problems are like


The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385​
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025​
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025
symbol_minus.gif
385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?

You get the idea. The use of large prime numbers in some of the questions have made me have to work out a really efficient one (it was taking hours looking for factors below half of the number we were checking). It's pretty fun and challenging.
 
Top