• Welcome to the Cricket Web forums, one of the biggest forums in the world dedicated to cricket.

    You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join the Cricket Web community today!

    If you have any problems with the registration process or your account login, please contact us.

Cricket Sim 2004

Andrew_14

School Boy/Girl Captain
I am developing a game of my own in Visual C++. I am only new to programming, but here's what it will feature:

*Write-to-Scorecard feature. It will write the match you most recently played's scorecard to a text file.

*Records. Will keep a records.dat file, containing the highest batsman score, bowlers, team innings, lowest scores etc.

*Realistic outcomes. Game engine will produce realistic outcomes for each player and team.

*Databases. Create your own squads by creating a Cricket Sim 2004 database, instructions on formatting included with game.

The game will be available in a couple of weeks, mabey a month. I may release a demo.

If you wish to be a tester, SIGN UP HERE.
 

Neil Pickup

Cricket Web Moderator
As an experienced programmer (:D) I'm happy to help out, I'm getting good at breaking things.

I do think your release schedule's a touch on the optimistic side, mind! :)
 

Andrew_14

School Boy/Girl Captain
Neil Pickup said:
As an experienced programmer (:D) I'm happy to help out, I'm getting good at breaking things.

I do think your release schedule's a touch on the optimistic side, mind! :)
I actually need help in something (if you know C++).

I am fairly new to C++, and I am making a cricket simulator.

The simulator writes a config.ini file. In the configuration file, it says:

1
1

This means that write-to-scorecard is enabled, and so is records mode. I am not sure how I would get the program to read this.

What I mean is, I want, for example, the simulator to read the first 1, and sign the value one to a. Then, it can read the second line, and sign 1 to b.

More clearly, how do I get it to read a certain line, and assign the line value to a integer?

How would I do this?

Thanks.
 

Andrew_14

School Boy/Girl Captain
Interesting. The databases I am constructing for it are fairly accurate in terms of which teams do well. Not just that, but it goes in depth with their home records and how they perform away, same with the players.

If you create a databse for it, which I am trying to make as easy as possible, yes it will be quite accurate.

I don't fully understand thos competitions, but I think that's what your trying to ask...
 

Neil Pickup

Cricket Web Moderator
I've not used C++ before (mainly because I can't afford it/haven't found a free giveaway copy yet) - but I can give you the code I use in Pascal in Beach Cricket to load from the file and assign the data into the variables, it's not likely to be vastly different in C++.

FileName:=Dir+'\data\config.ini'; (where Dir is a string variable of the game directory)
AssignFile(ConfigFile,FileName); (tells the program to read data off the filename - may be different in C++)
Reset(ConfigFile); (reset the file to the beginning so you read the first line first)
ReadLn(ConfigFile,STemp); (read the first line of the file and put it in the string "STemp")
a:=StrToInt(STemp); (convert the string STemp to the Integer A)
ReadLn(ConfigFile,STemp); (read the next line of the file and put it in the string "STemp" - just over-writes)
b:=StrToInt(STemp); (convert the string STemp to the Integer B)

Repeat for as long as you want - you will probably need loops and arrays in your player data file loading. Magpie loads 1500 players and around 200 variables for each, so it has a 200-variable loop repeating 1500 times, loading each data into an array named PlayerData[x,y] where x is 1 to 1500 and y is 1 to 200.

CloseFile(ConfigFile); (tells the program to stop reading - important you include this or you get all sorts of read-write errors).

Hope that helps!
 
Last edited:

Magrat Garlick

Global Moderator
Sounds pretty good to me mate...I'd be glad to test a small bit of it, at least :)

Is simming done ball-by-ball, and in that case, would it be possible to get ball-by-ball scorecard output? Nothing fancy, just . . . . . W for example... :)
 

Andrew_14

School Boy/Girl Captain
Thanks Neil. Well, here is the code I am using to load from the conifguration file at present:

char str[2000];
fstream file_op("config.ini",ios::in);
while(!file_op.eof())
{
file_op.getline(str,1);
a = str;
} file_op.close();

That seems to work. file_op.getline(str,1); means it grabs 1 character from the file. It's gonna be a bumer trying t get it to laod databases. I need to find out how to load specific lines.
 

Top