I'm running a day for 30 kids aged 11-18 about computer game programming. They have all opted to do it, but they have no experience at all of programming. My main aim is for them to learn a few things:
programming is hard/challenging
programming is something they can learn to do
being a computer games programmer != playing games all day
a little more insight into how games actually work
I'd thought of splitting them into two groups, of younger/less experience and older/more experience, then doing slightly different things.
I'd considered showing them Scratch, Game Maker, before showing them the basics of Python and getting them to write a simple text based game (perhaps something like, computer picks a random number, you have to guess it in as few guesses as possible, computer says higher/lower for each guess).
Does anyone have any ideas of things to do/show them/ways to teach them?
I have an app I was working on to learn more about wxPython( I have been primarily been a scripter ). I forgot about it now I am opening it back up. It's a screen scraper, and I have it working almost the way I want it, going to build a regex parser to strip out the links in every scrape that I don't need. The questions I have are this. In it current state, if I check more than one site, it goes out and scrapes, and returns it in separate windows, the for:each section in the Clicked function. I want to put them in a frame, in the window, altogether. I also want to know if I can take the list they are read into and send it to a checklist, so someone could check off separate items, I want to build a save function and keep certain ones. In regards to a save function, I want to keep saved checks, are there calls to the widgets to save their states? I know it's a lot, but thanks for the help.
Hi!
I'm learning C right now and so I'm fiddling about with pointers. Is there a way to determine the word width of the CPU in C because I'm writing a small program which prints it's own stack (Because I'm curious how it is structured), so that information would come in handy. Right now I'm using an int pointer, as an integer is 4 Bytes wide and I'm using a 32-bit Intel Atom CPU.
Thanks in advance, C gurus ;o)
I have this code:
a=[['a','b','c'],['a','f','c'],['a','c','d']]
for x in a:
for y in x:
if 'a' in x:
x.replace('a','*')`
but the result is:
a=[['a','b','c'],['a','f','c'],['a','c','d']]
and bot a=[['b','c'],['f','c'],['c','d']]
What should I do so the changes will last?
I have another memset question. It appears as if the code I am editing may have some issues (or it's not done the same way in different files)
A::LRM las[9]; //A and LRM are both structures with BOOLS and INTS
memset(&las, 0, sizeof(las));
typedef Sec SecArray[16];
SecArray rad_array;
memset(rad_array, 0, sizeof(SecArray));
The second example appears to be correct because rad_array is the same as the first position in the array. Then the sizeof(SecArray)) would make sense. The first one doesn't seem correct to me. All structs are just BOOLs and INTS nothing dynamic in them.
My understanding from my other post about memset was that it followed this format.
memset("pointer to object", "what to set it to", "size of object")
Can anyone tell me what exactly is going on here if I am incorrect with my theory.
have file data of format
3.343445 1
3.54564 1
4.345535 1
2.453454 1
and so on upto 1000 lines and i have number given such as a=2.44443 for the given file i need to find the row number of the numbers in file which is most close to the given number "a" how can i do this i am presently doing by loading whole file into list and comparing each element and finding the closest one any other better faster method?
my code:i need to ru this for different file each time around 20000 times so want a fast method
p=os.path.join("c:/begpython/wavnk/",str(str(str(save_a[1]).replace('phone','text'))+'.pm'))
x=open(p , 'r')
for i in range(6):
x.readline()
j=0
o=[]
for line in x:
oj=str(str(line).rstrip('\n')).split(' ')
o=o+[oj]
j=j+1
temp=long(1232332)
end_time=save_a[4]
for i in range((j-1)):
diff=float(o[i][0])-float(end_time)
if diff<0:
diff=diff*(-1)
if temp>diff:
temp=diff
pm_row=i
Hi all,
We have a process which takes a very large csv (1.6GB) and breaks it down into pieces (in this case 3). This runs nightly and normally doesn't give us any problems. When it ran last night, however, the first of the output files had lost precision on the numeric fields in the data. The active ingredient in the script are the lines:
while lineCounter <= chunk:
oOutFile.write(oInFile.readline())
lineCounter = lineCounter + 1
and the normal output might be something like
StringField1; StringField2; StringField3; StringField4; 1000000; StringField5; 0.000054454
etc.
On this one occasion and in this one output file the numeric fields were all output with 6 zeros at the end i.e.
StringField1; StringField2; StringField3; StringField4; 1000000.000000; StringField5; 0.000000
We are using Python v2.6 (and don't want to upgrade unless we really have to) but we can't afford to lose this data. Does anyone have any idea why this might have happened? If the readline is doing some kind of implicit conversion is there a way to do a binary read, because we really just want this data to pass through untouched?
It is very wierd to us that this only affected one of the output files generated by the same script, and when it was rerun the output was as expected.
thanks
Jack
Hi All,
I'm trying to detect if a file exists at runtime, if not, create it. However I'm getting a 'The process cannot access the file 'myfile.ext' because it is being used by another process.' error when I try to write to it.
Any ideas how to fix it?
Thanks
Hello, everyone!
I have a game I'm working on. My players are stored in a vector, and, at the end of the game, the game crashes when trying to insert the high-scores in the correct positions.
Here's what I have (please ignore the portuguese comments, the code is pretty straightforward :P):
//TOTAL_HIGHSCORES is the max. number of hiscores that i'm willing to store. This is set as 10.
bool Game::updateHiScores()
{
bool stopIterating;
bool scoresChanged = false;
//Se ainda nao existirem TOTAL_HISCORES melhores pontuacoes ou se a pontuacao for melhor que uma das existentes
for (size_t i = 0; i < players.size(); ++i)
{
//&& !(players[i].isAI())
if (players[i].getScoreValue() > 0 && (hiScores.size() < TOTAL_HISCORES || hiScores.back() < players[i].getScore()))
{
scoresChanged = true;
if(hiScores.empty() || hiScores.back() >= players[i].getScore())
hiScores.push_back(players[i].getScore());
else
{
//Ciclo que encontra e insere a pontuacao no lugar desejado
stopIterating = false;
for(vector<Score>::iterator it = hiScores.begin(); it < hiScores.end() && !(stopIterating); ++it)
{
if(*it <= players[i].getScore())
{
//E inserida na posicao 'it' o Score correspondente
hiScores.insert(it, players[i].getScore());
//Verifica se o comprimento do vector esta dentro do desejado, se nao estiver, este e rectificado
if (hiScores.size() > TOTAL_HISCORES)
hiScores.pop_back();
stopIterating = true;
}
}
}
}
}
if (scoresChanged)
sort(hiScores.begin(), hiScores.end(), higher);
return scoresChanged;
}
What am I doing wrong here?
Thanks for your time, fellas.
I use SVN, and am learning how to use it along with eclipse IDE. The first time I add classes to my package, there is no problem, the generated class files get into SVN smoothly. The moment I edit them, I get this message - "WEB-INF/classes" is obstructed. I try the "clean-up" command and the clean up command says "WEB-INF/classes" folder is locked.
I use TortoiseSVN as my SVN client.
I know why this is happening. It probably because the Eclipse overwrites all the files while generating classes and then causes this -
Is it inappropriate to commit the class files into SVN? If not, what should I do to commit these class files smoothly?
How do i get access to an element in a set ?
vector<int> myvec (4,100);
int first = myvec.at(0);
set<int> myset;
myset.insert(100);
int setint = ????
Can anybody help ?
Hello,
As my project to do over this summer I would like to create a program that answers a Skype call using the Skype API and allows a user to connect to another VOIP provider (through SIP) and make calls by dialling through the client callers Skype application.
I understand that the Skype API allows me to answer and receive keypad input, but I'm stuck on actually sending the sound of the call to a SIP client.
Is there an API/library that would allow me to take the Skype receiving audio as input in the SIP client?
Is this even possible?
I'm not tied to a language but I had planned on using Python.
Thanks.
One-Liner to list TXT-files.
import java.io.File;
import java.io.FilenameFilter;
...
files = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".txt");
}
}
);
Source.
Is there an one-liner to list dirs in a dir?
I am currently undertaking software engineering program in one of the local universities at my country.
And i am interesting in software and hardware.
So i decided to learn it by myself.
One of my seniors told me to start with PIC 16 or 18 first.
Anyone of here has any links for the related website?
And where can i get a device to program PIC other than ebay?
thx in advance.
Can anyone suggest a guideline on when to use SnapsToDevicePixels in WPF 4.0?
Should it only be used occasionally if there is an issue, liberally throughout an App, only on certain controls or what?
Hello,
I have a form that certain data, which then gets calculated and gets displayed in a table.
All the data gets saved in a 2 dimensional array.
Every time i go back to the form the new data gets saved in the array.
That data will be displayed in the next table row and so on.
I have used print_r($_Session) and everything gets properly saved in the array.
Although i have no idea how to acces the session variables area, floor, phone, network etc wich are now in the array.
Without arrays i stored them in a variable for example $phone , and did calculations with it.
But now when i use the arrays, i keep on getting undefined index phone etc...
How can i acces these variables, been looking at this for hours without getting any closer to a solution.
Any help much appreciated.
Regards.
First page:
if (empty ($ _POST))
(
Mode = $ name $ _POST ['state name'];
$ Area = $ _POST ['size'];
$ Floor = isset ($ _POST ['floor'])? $ _POST ['Floor'] 0, / / if checkbox checked value 1 else 0
$ Phone = isset ($ _POST ['phone'])? $ _POST ['Phone']: 0;
$ Network = isset ($ _POST ['network'])? $ _POST ['Network']: 0;
/ / Control surface
if (is_numeric ($ area)) / / OK
(
if (isset ($ _SESSION ['table']))
(
/ / Create a new row to the existing session table
$ Table = $ _SESSION ['table'];
$ Number = count ($ table);
$ Table [$ count] [0] = $ file name;
$ Table [$ count] [1] = $ size;
$ Table [$ count] [2] = $ floor;
$ Table [$ count] [3] = $ phone;
$ Table [$ count] [4] = $ network;
$ _SESSION ['Table'] = $ table;
)
else
(
/ / Create the session table
$ Table [0] [0] = $ file name;
$ Table [0] [1] = $ size;
$ Table [0] [2] = $ floor;
$ Table [0] [3] = $ phone;
$ Table [0], [4] $ = network;
$ _SESSION ['Table'] = $ table;
)
header ("Location: ExpoOverzicht.php");
)
else
(
echo "<h1> surface Wrong - New try </ h1>";
)
)
When i made the php code withotu the arrays i declared like this, and it worked fine.
But now there in the array, and i have no idea how to "acces them"
$standnaam = $_SESSION["standnaam"];
$oppervlakte = $_SESSION["oppervlakte"];
$verdieping = $_SESSION["verdieping"];
$telefoon = $_SESSION["telefoon"];
$netwerk = $_SESSION["netwerk"];