Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Tutorial Doctor

Member Since 19 Oct 2013
Offline Last Active Yesterday, 07:34 PM

Topics I've Started

Game Development Barriers to Entry?

25 May 2015 - 02:22 PM

I feel way ahead of the gamers, but far behind the game. Pun not intended (but cool how it worked out that way). 

 

I have been experiencing a flux of them, and perhaps some of you have also. My main barriers are:

 

 

Information:

How do you make a game? That is the basic question. Lot's of resources. Can you learn that API? Can't program? Learn that first. Which language? Okay, now how do I do this...? Too hard, too basic, and incomplete tutorials. 

 

Even when you go to school, a GOOD education can still be hard to find. Tuition. I go solo, and that is even more true me. So that brings me to the next barrier:

 

Money:

If you are broke and unemployed like me, you can't buy half the tools, resources, information, that you would "prefer." But people "have to make a living right?" I don't blame them either. They say it takes money to make money. 

 

Skills:

No information and no money means you have to obtain that information the old school way. Trial and error? But I am broke now!

 

The main things that prevent me right now are information and skills. I am all free and open source right now. Blender, Godot, and finally a photo editor I can trust (sorry Gimp). 

 

I am not a beginner, so to speak, so I posted it for discussion in the lounge. 

 

What barriers do you, or have you experienced?

 


ELIZA Chatbot

20 May 2015 - 10:09 AM

A while ago I stumbled across a neat idea for a chatbot in 18 lines of code:

http://www.gamedev.net/topic/663348-chatbot-in-18-lines-of-code-python-help/

 

I modified it a bit with more features. Today I stumbled across a mention of a chatbot named ELIZA:

http://en.wikipedia.org/wiki/ELIZA

 

I searched for a Python implementation and this is where my search lead me:

http://www.jezuk.co.uk/cgi-bin/view/software/eliza

 

I changed whrandom to random (don't know how this will affect the program, but it seems to work:

 

The reason I am looking into chatbots is for AI game characters. I really want it as simple as possible. Anyone think this would be a suitable base AI that could be implemented in any programming language?

It seems customizable enough.

 

This search was inspired by:

http://www.science20.com/eye_brainstorm/why_my_computer_didnt_do_all_my_homework-93905


Massive Python Example Script

19 May 2015 - 06:03 PM

TL;DR

 

I am trying to make a massive example script, demonstrating all of the core syntax of Python (beginner to intermediate and maybe advanced). It could serve as a tutorial even. 

 

I want it to be one sample project that includes all of the following syntax for python, but I can't think of a good example. Could use some help. I also want to do the same thing for LUA and eventually C#. I would like to use the same example. I used the analogy of cooking to make an intro to computer programming course, so I guess I could go with that, but I don't exactly know how I would incorporate all of the following constructs. 

 

I could do the whole boring data base thing, but it's boring. 

 

Currently the examples are unrelated. 

 

Here is what I have so far:

# -*- coding: utf-8 -*-
print "Python Examples\n --By The Tutorial Doctor\n"

## PRINTING

print 'Hello'

print 'Hello','Editorial'

# Concatenate/Append text (gives errors if not strings)
print 'Hello' + 'Folks'

print 'Hello' + ' Folks' # have to add your own space

print 27


# VARIABLES
#There are different types of variables: character, string, integer, float, boolean, array/list, dictionary, and a few others.

# A character
at = "@"

# A string
name = 'Jackie'

# An integer
favorite_number = 4

# A float
height = 6.5

# A boolean
IamCool = True 

# You can assign a new value to a variable
IamCool = False 

# An array
array_of_colors = ['red','orange','yellow','green','blue','indigo','violet']
array_of_numbers = [23,13.4,1,782]
mixed_array = ['Zillow',34.9,True,798]

# A dictionary
description = {'eyeColor':'brown','physique':'muscled','demeanor':'confident'}
print description['eyeColor']
print description['physique']
print description['demeanor']

# EXTRA

# ID of a variable
print id(name)

#####

# STRINGS
# A string is string of characters 

## Empty string
first_name = ""
last_name = ""


## Asign a value to a string
first_name = "joe"
last_name = "shmo"
occupation = "Truck Driver"


## Adding strings (concatenation)
print first_name + last_name

## Adding a space between string variables
print first_name + " " + last_name

## Starting a new line (escape characters)
print first_name + "\n" + last_name 

## Adding variables inside of a string (string formatting)
print "Hello %s" %(first_name)

## Multiple variables inside of a string
print "Hello %s %s" %(first_name,last_name)

## There is another way to format strings
greeting = 'Hello {name}, my name is {myname}'
print greeting.format(name='Joseph',myname='Joey')

## Print a string several times
print first_name * 4

## Get index of a string
## Indices begin at 0
print first_name[0]
print first_name[1]
print first_name[2]

## A multi-line string
"""Multi-Line strings are sometimes used as multi-line comments, since python doesn't have syntax for multi-line comments."""


# STRING FUNCTIONS
print first_name.capitalize()
print len(occupation) 

#####

# INTEGERS
# An integer is a whole number

number1 = 12
number2 = 144
number3 = "67" #not an integer

#Add
print number1 + number2

#Subtract
print number2 - number1

#Multiply
print number1 * number2

#Divide
print number2/number1

#Exponents
print number2**number1
#Same
print pow(number2,number1)

#Square root
print number2**(1/2.0)

#Order of operations
print (number1 + number2) * 3 + (number1**3)

# Increment an integer
number1 = number1 + 1
print number1

# Convert a string to an integer
number3 = int(number3)

#####

#FLOAT
# A float is a decimal. Many of the integer operations can be applied to floats.
pi = 3.14
print pi
#####

# TUPLES
## Tuples are like lists, but cannot be changed (they are immutable).

x = 0
y = 1


## Create a Tuple
position = (50,200)


## Get tuple index
print position[x]

#####

# LISTS/Array
# Called a list in python.

# Create a list
Clients = ['Cierra','Lisa','Ibrahim','Eric','Nancy','Terry','Sarah']
print Clients

Employees = ['Eric','Margaret','Paul','Ole','Yul']
print Employees

### LIST FUNCTIONS
# List Index
print Clients[0]

# List index range
print Clients[0:4]

# Append to a list
Clients.append('Joe')
print Clients
#Same as:
#Clients[len(Clients):] = ['Joe'].

# Remove from a list
Clients.remove('Joe')
print Clients

# Insert item into a list at a location
Clients.insert(0,'Lee')
print Clients

# Reverse a list
Clients.reverse()
print Clients

# Sort a list
Clients.sort()
print Clients

# Remove an item at a location
Clients.pop(0)
print Clients

# Return the index of an item in the list
print Clients.index('Lee')

# Extend a list with another list
Clients.extend(Employees)
print Clients
# Same as:
#Clients[len(Clients):] = Clients

# Count how many times an item appears in a list
print Clients.count('Lisa')


### EXTRA

# Loop through a list
for item in Clients:
	print item
	
#Remove a list from a list
for i in Clients:
		if i in Employees:
			Clients.remove(i)
print Clients

#####

### DICTIONARIES/Associative array

# Create a dictionary (dictionary_name = {key:value})
inventory = {'light':'flashlight'}
print inventory


# Print the value of a key
print inventory['light']


# Update Dictionary 
inventory.update({'map':'New York'})
inventory.update({'phone':'Flip Phone'})
print inventory


# Update the key if it is already in the dictionary
inventory.update({'map':'Atlanta'})
inventory.update({'map':'New York'})
print inventory['map']


# Get all keys (outputs as a list)
print inventory.keys()


# Get all values (ouptuts as a list)
print inventory.values()


# Copy dictionary items as a list of tuples
# Basically converts a dictionary to a a list of tuples.  
print inventory.items()


# Length of a dictionary
print len(inventory)


# Delete inventory item
del inventory['map']
print inventory


# Iterate over dictionary
#print iter(inventory)
#print inventory.iterkeys()
#print inventory.itervalues()

# Remove item, and returns its value
inventory.pop('phone')
# Alternately: inventory.popitem()
print inventory

# View keys of a dictionary
print inventory.viewkeys()

# View values of a dictionary
print inventory.viewvalues()

# View all items in a dictionary
print inventory.viewitems()

#####

### CONDITIONALS

on = True
number = 51

# If equal to
if on == True:
	print on

# Same (for booleans)
if on:
	print on

# If not equal to
if on != False:
	print on

# If greater than
if number > 23:
	print number

# If less than
if number < 77:
	print number

#####

## BOOLEANS (BEG)
# if, else, and else if(elif)

location = 0
	
if location == 50:
	print 'Halfway there.'
elif location > 50 and location < 100:
	print 'More than halfway there.'
elif location < 50 and location > 0:
	print 'Less than halfway there.'
elif location == 100:
	print "You are there!"
elif location < 0:
	print "You're moving in the wrong direction!"
elif location > 100:
	print "You've gone too far."
elif location ==  0:
	print "You aren't moving!"

#####

### WHILE LOOP
age = 0
old_age = 30

while age < old_age:
	print 'Still young @ ' + str(age)
	age = age + 1
if age ==  old_age:
	print "You've reached the pinnacle @ " + str(age)
	
#####

### FUNCTIONS
# A function is a group of statements

IamCool = True
### BUILT-IN FUNCTIONS
# print() - Prints values to the screen
print(name)
print(favorite_number)

# Two ways to print
print height
print IamCool,",I am cool"

print array_of_colors
print array_of_numbers


# raw_input() - Gets input from the user
occupation = raw_input('What is your occupation? ')
print 'You are a ' + occupation

# len() - Gets the length of a string
print(len(name))

# type() - Gets the type of a value
print(type(height))

# str() - Converts a value to a string
print(type(str(height)))

# int() - Converts a value to an integer
print(type(int(height)))

# list() - Converts a value to a list

# float() - Converts a value to a float

# round() - Rounds a number to a given percision
print(round(height,2))
print(round(height,1))


# pow() - Raises a number or integer to a power 
power = pow(height,favorite_number)
print(power)

# sum()- sum of all elements in an iterable 
print 'sum of array is',sum(array_of_numbers)

# help() - prints Python help information
#help() commented out for now


# Create a function
def MyFunction():
	print name
	print height
	print favorite_number

# Use/Call a function
MyFunction()

## Function arguments
# One argument
def Write(first_name):
	print first_name
	
Write('Ole')

# More than one argument (separated by commas)
def Add(a,b):
	print 'The sum is ' +  str(a + b)

Add(2,3)
Add(2.89,34.2)

# Function return
def Multiply(a,b):
	product = a*b
	return product

print 'The product is',Multiply(2,89)

#####

### FOR LOOP

print range(0,10)

# Loop over a range
for i in range(0,10):
	print i
# For each element inside of the range, print the element.

# Loop over a string
name = 'Joseph'
for letter in name:
	print letter

# Loop over a list
my_list = ['eggs','milk','bread']
for item in my_list: 
	print item

#####

# WHILE LOOP
i = 1
while i<11:
	print "uh",i, "and"
	i = i + 1 #increment i

### CLASSES

# A class
class Fruit():
	def __init__(self,color,taste,type='Fruit'):
		
		# Member Variables
		self.color = color
		self.taste = taste
		self.type = type
	
	# A Method	
	def eat(self, item):
		print "Eating " + item

# An object
apple = Fruit("red","sweet")

# Accessing member variables
print(apple.color)
print(apple.taste)
print(apple.type) # default value. a non-required argument.

# Using methods
apple.eat("vegetables")

#####

# Try to do something, and if there is an error, do something else
try:
    print "Hello World"
except:
	print('Goodbye World')

# Types of exceptions
exceptions= """except IOError:
    print('An error occured trying to read the file.')
    
except ValueError:
    print('Non-numeric data found in the file.')

except ImportError:
    print "NO module found"
    
except EOFError:
    print('Why did you do an EOF on me?')

except KeyboardInterrupt:
    print('You cancelled the operation.')

except:
    print('An error occured.')
"""

#####

### PART 2 ###

# -*- coding: utf-8 -*-
# BOOLEANS

cold = False
hot = False
normal = False

cloudy = False
partly_cloudy = False
sunny = False


temp = 12
overcast = 68


if temp < 65:
	cold = True
	

if temp > 85:
	hot = True


if temp > 65 and temp < 85:
	normal = True

	
if overcast > 55:
	cloudy = True


if overcast < 30:
	sunny = True

	
if overcast > 30 and overcast < 55:
	partly_cloudy = True
	
	
if (cold and cloudy) and (cold and partly_cloudy):
	print 'Its gonna be a yucky day'
else:
	print 'Its an okay day out!'
	
	
if (cold and cloudy) or (cold and partly_cloudy):
	print 'Its gonna be a yucky day'
else:
	print 'Its an okay day out!'
	
	
if hot and sunny:
	print 'Its gonna be steaming!!'

class Animal():
	# two underscores mean the variable is private
	__name = ""
	__height = 0
	__weight = 0
	__sound = ''
	def __init__(self,name):
		self.__name = name
		
	def get_name(self):
		print self.__name

a = Animal('a')

a.get_name()

# CONDITIONALS

adult = False
miniumum_age = 18

def CheckAge():
	age = int(raw_input('How old are you: '))
	if age >= miniumum_age:
		adult = True
		print 'You are legal'
	elif age < miniumum_age:
		print 'That is not old enough'
		adult = False
	
	if not adult:
		CheckAge()
CheckAge()

# FUNCTIONS (INTERMEDIATE)
welcome = 'Welcome to Editorial! '
response = raw_input('How are you today? ')
computer_response = 'It seems you are ' + response

# Create a function
def PrintSomething():
	print 'Hi'
	
# Call the function
PrintSomething()

# Function arguments/parameters
def PrintArgument(argument):
	print argument

PrintArgument(welcome)
PrintArgument(computer_response)

def push_argument(*argparams):
	print argparams
push_argument('a','b')


def push_keys(**keyparams):
	print keyparams
push_keys(ok='right')


def default_parameters(a='A',b='B'):
	print a,b
default_parameters(a='Not A',b='Not B')


def fixed_passed_parameters(a,b):
	print a,b
fixed_passed_parameters('a','b')


#String Funtions
import string

name = 'john jacob jingleheimer schmidt'

place = 'Wasington D.C.'
print place

place = place.lower()
print place

place = place.upper()
print place

## FOMATTING
formatted_string ='My name is %s' % ('Mr Editorial')
print formatted_string

multiVariable_formatted_string = "He crossed the %(blank)s at %(time)d o'clock" % {'blank':'street','time':12}
print multiVariable_formatted_string


## CLASSES
place = string.capitalize(place)
print place

split_name = string.split(name,None,-1)
print split_name

joined_split_name = string.join(split_name)
print joined_split_name

print string.capwords(joined_split_name,None)

# -*- coding: utf-8 -*-

# BETTER WAY

temperature = -10

initial_position = 0
final_destination = 100
halfway_point = (final_destination-initial_position)/2
location = ''
	
while temperature < final_destination:
	diff = final_destination-temperature
	temperature = temperature + 1
	if temperature == halfway_point:
		location= 'Halfway there.'
		print str(temperature) + ' is ' + location + str(diff) + ' More to go!'
	elif temperature > halfway_point and temperature < final_destination:
		location= 'More than halfway there.'
		print str(temperature) + ' is ' + location + str(diff) + ' More to go!'
	elif temperature < halfway_point and temperature > initial_position:
		location= 'Less than halfway there.'
		print str(temperature) + ' is ' + location + str(diff) + ' More to go!'
	elif temperature == final_destination:
		location= "There!"
		print str(temperature) + ' is ' + location + ' No more to go!'
	elif temperature < initial_position:
		location= "Negative!"
		print str(temperature) + ' is ' + location + str(diff) + ' More to go!'
	elif temperature > final_destination:
		location= "Too far."
		print str(temperature) + ' is ' + location + str(diff) + ' More to go!'
	if temperature >= (temperature-1):
		print 'going in the right direction'
	else:
		print 'Wrong way Josè!'




if wall is in front turn, else go.

15 May 2015 - 07:14 AM

How is that for a maze navigation system? With a few modifications it theoretically seems like it would work.

Functionality and Simplicity

15 May 2015 - 07:04 AM

Functionality and Simplicity
Cool thing about programming is that there are many ways to go about solving a problem. Two approaches may work, but of the two, wouldn't you choose the most efficient? And if both are equally efficient, meeting all requirements, wouldn't you then choose the simplest?

So, you have functionality and simplicity. I see no reason for one or the other to be ignored.

I am wondering, do you think a genius program is one that achieves these two criteria?

What criteria do you use to judge the genius of the programmer that wrote the program?

PARTNERS