Page 1 of 1
custom scoring system...this is a tough one...
Posted: March 24th, 2012, 12:48 am
by lzilberm
Hey everyone...
I have a somewhat challenging task. I need help developing a custom scoring system according to the following criteria...
So first of all we are using PAS to make a video game used in lab research..
that means we need to track the performance of the subjects over time...the subjects will play the game every day.
In PAS we have developed different mazes...when the player gets to the right place in the maze he/she is transported to a new random maze....if the player makes a mistake he/she is transported to the starting point of the same maze.
I basically need to output the performance of the various players...or their success rate....
I need the computer to remember the performance of the different player profiles....
This can all be sent to a notes file...actually that is preferred.
So basically tracking....
PLAYER NAME....DATE.............PERFORMANCE (success/total plays)
success = everytime the player gets to the new maze
failure = everytime the player is transported to the start within that same level.
thanks to everyone who takes a look at this...it's much appreciated...
~~lzilberm
Re: custom scoring system...this is a tough one...
Posted: March 24th, 2012, 5:13 am
by kddekadenz
Listen to this
awesome playlist while I search my drive for the script
EDIT:
Code: Select all
//timer
timer = [
time = (format "%1 Seconds" $seconds)
seconds = (+ $seconds 1)
sleep 1000 [timer]
]
seconds = 0
timer
//fail
failed = [
tries = (+ $tries 1)
]
tries = 0
//trigger
level_trigger_1 = [showgui win]
level_trigger_2 = [failed]
newgui win [
guitext (format "Congratulations %1, you made it!" (getname))
guitext (format "You needed %1 seconds." (time))
guitext (format "You needed %1 tries." (tries))
guibar
guilist [
guibutton "[Next map]" "sp $nextmap"
guibar
guibutton "[Restart]" "restart"
guibar
guibutton "[Quit game]" "quit"
]
]
This is based on a scriptlib for a jump n run game I never released (shall I do it?).
I called it scriptlib.cfg and added to the map cfg:
Code: Select all
nextmap = "direction of map"
exec "directory/scriptlib.cfg"
Level trigger 1 will show the winning GUI.
Level trigger 2 will make you fail - you may want to add a invisible portal back to start on top of it (/newent teleport tag -1)
Re: custom scoring system...this is a tough one...
Posted: March 24th, 2012, 5:36 am
by kddekadenz
WTF, just read that it should be persistent..
I think you need RPG mode for this..
So, here is basically the idea how to solve this using rpg mode:
1) set up 2 global variables in variables.cfg of your game (e.g. wins,fails)
Code: Select all
wins = (r_global_new 0)
fails = (r_global_new 0)
2) make a win and a fail trigger
script for fail:
Code: Select all
r_script_signal interact [
r_global_set $fails ((r_global_get $fails) + 1))
]
-> use the mentioned teleport method
script for win:
Code: Select all
r_script_signal interact [
r_global_set $fails ((r_global_get $fails) + 1))
r_teleport player 0 $nextmap //maybe name the maps with numbers? nextmap = random Number between 1 and mapcount
]
3) add possibilty to check fails per win
e.g. trigger:
Code: Select all
r_script_say "[check fails per win]" [
cpw = (r_global_get $fails)/(r_global_get $wins)
r_response (format "%1" (cpw)) -1
Note: I didn't tested this and I'm sure there is somewhere a mistake. But it's enough to get the basic idea.
Re: custom scoring system...this is a tough one...
Posted: March 25th, 2012, 12:11 am
by Sircameron
kddekadenz wrote:WTF, just read that it should be persistent..
I think you need RPG mode for this..
So, here is basically the idea how to solve this using rpg mode:
1) set up 2 global variables in variables.cfg of your game (e.g. wins,fails)
Code: Select all
wins = (r_global_new 0)
fails = (r_global_new 0)
2) make a win and a fail trigger
script for fail:
Code: Select all
r_script_signal interact [
r_global_set $fails (+ (r_global_get $fails) 1)
]
-> use the mentioned teleport method
script for win:
Code: Select all
r_script_signal interact [
r_global_set $wins (+ (r_global_get $wins) 1)
r_teleport player 0 $nextmap //maybe name the maps with numbers? nextmap = random Number between 1 and mapcount
]
3) add possibilty to check fails per win
e.g. trigger:
Code: Select all
r_script_say "[check fails per win]" [
cpw = (r_global_get $fails)/(r_global_get $wins)
r_response (format "%1" (cpw)) -1
Note: I didn't tested this and I'm sure there is somewhere a mistake. But it's enough to get the basic idea.
edited what you started so it will add the variables properly. Im not skilled enough to script the random maps teleport.. Goodluck
Re: custom scoring system...this is a tough one...
Posted: March 27th, 2012, 1:15 pm
by lzilberm
Will the win and fail data be outputed into a notepad file? Where do I go to see the scores?
Re: custom scoring system...this is a tough one...
Posted: March 27th, 2012, 5:21 pm
by Sircameron
The best way to test that its adding correctly is to type the following into the console
it will tell you the number of wins in the top left corner.. As for where its stored in the variables.cfg although it doesnt print out in the file during gameplay.. So its a good idea to test it that way in the console with the code given
Re: custom scoring system...this is a tough one...
Posted: April 12th, 2012, 1:43 pm
by lzilberm
I have this code...but I think it is in the wrong format. Does anyone have any insights?
/******************************************************/
// Include files
#include <iostream> // used for cin, cout
#include <conio.h>
#include <windows.h>
#include <string>
#include <fstream>
#include <sstream>
#include <ctime>
using namespace std;
// Global Type Declarations
// Function Prototypes
string stringify(double x){
ostringstream o;
o << x;
return o.str();
}
int print_report(string report_var) {
ofstream myfile;
myfile.open ("todays_report.txt");
myfile << report_var;
myfile.close();
return 0;
}
int main ()
{
using namespace std;
double player_wins, player_fails, player_games;
cout << "Enter Player ID: " ;
cin >> player_id;
cout << "Enter Player Wins: " ;
cin >> player_wins;
cout << "Enter Player Fails: " ;
cin >> player_fails;
player_data(player_id,player_wins,player_fails);
}
//this functions get Name,Wins,Losts and print the report in the end.
int player_data(string player_id,double player_wins, double player_fails){
using namespace std;
double player_games;
string report = "";
// Current date/time based on current system
time_t now = time(0);
//player_wins = 1;
//player_fails = 3;
player_games = player_wins + player_fails;
//Converting double to string
//---------------------------
string player_wins_str = stringify(player_wins);
string player_fails_str = stringify(player_fails);
string player_games_str = stringify(player_games);
report = report + "Player ID: " + player_id + "\n";
report = report + "Date: "+ time_t + "\n\n";
report = report + "Wins: " + player_wins_str + "\n";
report = report + "Fails: " + player_fails_str + "\n";
report = report + "% Success: " + player_wins_str + " / " + player_games_str + "\n\n";
report = report + "_________\n\n";
//creating a report file
print_report(report);
}
Re: custom scoring system...this is a tough one...
Posted: April 12th, 2012, 5:14 pm
by Sircameron
If you're going through all that trouble you could add the date to the "todays_report.txt" filename itselfand have something like "(mm/dd/yyyy)_report". Unless you just plan on recording the data to something else each day.. You would have a separate .txt file for each day as opposed to one for every day. Just an idea
Re: custom scoring system...this is a tough one...
Posted: April 16th, 2012, 2:00 pm
by lzilberm
maybe this will help.....
What is a win?
~~~~~A win is when the player gets to the correct part of the maze and is transported to a new random maze. There is a hidden object at the correct part of the maze that is picked up and sends the player to the new random maze.
What is a loss?
~~~~~A loss is when the player goes to the wrong part of the maze and is transported to the start point of that same maze. There is a hidden teleport object at the wrong end of the maze that takes the player to a defined starting point.
have all the information outputed to a notebook file
input the players name
input the date
______________
in the notebook file
Player_name:
Date:
Number of wins:
Number of losses:
Number of wins/number of losses.
Re: custom scoring system...this is a tough one...
Posted: July 20th, 2012, 2:29 am
by schoenbt
Hello lzilberm!
I'm working on a similar task - have you been successfull with the code? Is it possiple to get an proper output of the "gamers performance"?
yours
torsten
lzilberm wrote:Hey everyone...
I have a somewhat challenging task. I need help developing a custom scoring system according to the following criteria...
So first of all we are using PAS to make a video game used in lab research..
that means we need to track the performance of the subjects over time...the subjects will play the game every day.
In PAS we have developed different mazes...when the player gets to the right place in the maze he/she is transported to a new random maze....if the player makes a mistake he/she is transported to the starting point of the same maze.
I basically need to output the performance of the various players...or their success rate....
I need the computer to remember the performance of the different player profiles....
This can all be sent to a notes file...actually that is preferred.
So basically tracking....
PLAYER NAME....DATE.............PERFORMANCE (success/total plays)
success = everytime the player gets to the new maze
failure = everytime the player is transported to the start within that same level.
thanks to everyone who takes a look at this...it's much appreciated...
~~lzilberm