Pig dice game is a game that I made that user plays it against computer
it gives the user to either roll or pass

and the computer will try to roll until they’re  more than 20

The program works this way

get random number and seed it

then get random start for who will start first and seed

if  who ever rolled ‘1’ will lose his points and starts again at ‘0’

if other than ‘0’ it will keep adding points

who ever reach 100 is the winner

 

let us look at the code and then I will be including screenshots of the game

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
using namespace std;

int player1 (int & playerscore );//to declare the player function
int player2(int & computerscore);//Player 2 function declartion
int again();
bool holded = false; // boolean to use when hold
int rolled(); /// declaration of a random roll (get random number between 1 to 6
int main(){ //// The main function to run the functions
int max = 100;
int randomplayer; // get random player to start with
int playerscore = 0;
int computerscore= 0;

randomplayer = rand() % 2 +1;

while((playerscore != max) && (computerscore != max)){
if (randomplayer ==1){ // do the random player
player1(playerscore);
randomplayer =2;
}
else if (randomplayer==2){
player2(computerscore);
randomplayer = 1;
cout<<“You want to (R)oll or (H)old : “<<endl;
}
if (playerscore >= max){
cout<<“PLAYER WON”<<endl;
break;
}
else if (computerscore >= max){
cout<< “COMPUTER WON”<<endl;
break;
}
}
cout<<“You wana again?????????”<<endl;
char yes = ‘y’;
cin>>yes;
if (yes == ‘y’ or yes == ‘Y’){
cout<<“You want to (R)oll or (H)old : “<<endl;
return main();
}
return 0;
}

int rolled()/// roll function
{
int roll;
roll = rand()% 6 + 1; // get random numbers between 1 to 6

return roll;
}

int player1 (int & playerscore){ // player 1 function
char user; // do char to get the letter ‘r’ or ‘h’
cin>>user; // get the input
int player1roll; // declare the roll and assign it to the roll function
while (user==’r’or user == ‘R’){ // if user input is ‘R’ or ‘r’ do the below
player1roll = rolled();
cout<<“The Player roll is : “<<player1roll<<endl;
if (player1roll == 1){ // if roll is ‘1’ it user will lose all points
cout<<“You rolled 1 you lost your points!”<<endl;
playerscore =0;
holded = true; // and is holded
break;

}

else if (player1roll != 1){ // if it is not then add the socres and move on
playerscore += player1roll;
cout<<“You have a score of : “<<playerscore<<endl;
cout<<“You want to (R)oll or (H)old : “;
cin>>user;
}
}

while (user== ‘h’ or user == ‘H’){// if user hold then just hold and break and go to the computer turn
holded = true;
break;
}

return playerscore;
}

int player2 (int & computerscore){

int computeroll;
computeroll = rolled();
if (computeroll != 1){
computerscore += computeroll; /// add the computer roll to the computer score
cout<<“The computer rolled : “<<computeroll<<endl; /// cout it
cout<< “Computer score is : “<<computerscore<<endl;// cout the score
while (computerscore < 20){ // if the computer score is less than 20 it will keep rolling, this should be a bad practice, and I think I need
// to find a better way, because once the computer score is ’20’ it will no longer do anything
computerscore+=computeroll;// add scores
cout<<“The computer rolled again : “<<computeroll<<” the score of the computer is now : “<<computerscore<<endl;
if (computerscore >= 20){// other wise ‘if its 20’ then do nothing give player chance
break;
}
}
while ((holded == true) && (computerscore >=20)){
computerscore+=computeroll;
cout<<“The computer rolled again : “<<computeroll<<” the score of the computer is now : “<<computerscore<<endl;
if( computerscore >= 40){
break;
}
}

}
else if (computeroll == 1){/// if computer roll is 1, then computer loses all points
cout<<“The computer rolled ‘1’ it lost all its points, its your turn now : “<<endl;
computerscore = 0;
}

return computerscore;
}

This is how the game looks like

 

 

computerloser

humancomputer

winner

 

I have always liked playing with graphics, but never that how to animate them using code, even though I have used 3d max or blender or maya, but never delved to the point that I had to use code to animate them, the only thing I did is just animating a ball without even using a single code. But I had the opportunity to use the SFML library and did a bouncing ball

 

#include <SFML/Graphics.hpp>
using namespace sf;

int main( ) {
int size = 500; this is the size of the window
int hight = 500; the height of the window
/* open the window with size 50×500 and title “My Window” */
RenderWindow window(VideoMode(size, hight), “ball bouncing”);
int xspeed = 1;
int yspeed = 1;
CircleShape circle(100);
circle.setFillColor(Color::Red);
circle.setPosition(0,0);
while (window.isOpen( )) {

//run the program as long as the window is open
window.draw(circle);
circle.move(xspeed,yspeed);
window.display( );
window.clear();
if(circle.getPosition().y> 400){/// if the ball is bigger than 400 it will bounce and will move back
yspeed=-yspeed;
circle.setFillColor(Color::Blue);/// it will change the color! to give it more better look
}
if (circle.getPosition().y < 0){
yspeed++;/// if it is less than zero then will go bigger and will go bigger
circle.setFillColor(Color::Yellow);
}

if(circle.getPosition().x > 350 ){
xspeed=-xspeed;// if it is bigger than 350 then it will reduce it which will make it bounce
circle.setFillColor(Color::White);
}
if (circle.getPosition().x < 0 ){
circle.setFillColor(Color::Red);
xspeed++;
}
Event event;
while (window.pollEvent(event)) {
if (event.type == Event::Closed) {/// this will handle the close event so that when click at the “x” on the window it will close the windo
window.close( );
}
}
}
return 0;
}

here is screen shots of the ball bouncing

balalalal

ballagain

ballwall

 

ball

 

Encode or Decode:

Creating a program that encode and decode could be frustrating at first, but once you get the idea it will be fun!

When I did this assignment I had to search for the ASCII table and take a deep look at it, and write down my thoughts about how to approach this program,

# include <iostream>
# include <sstream>
# include <string>
#include <locale>
# include <ctype.h>
using namespace std;
int main(){
string message;
string key;
int nkey;
string convert;
char input;
cout<<” You want to Encode or Decode?”<<endl;
cin>>input;
cin.ignore();
bool wrong;
if ((input != ‘e’ or input != ‘E’)&&( input != ‘d’ or input!= ‘D’)){ // this is to make sure that the user entered ‘e’ or ‘E’ or ‘d’ or’D’ to encode or decode
wrong = true; // if this the user entered other than that then it will return true for the wrong

 

 

printsforencode

decoded

}
else {
wrong = false;// here wrong will be false
}
while ( wrong == true){
if ((input == ‘e’ or input == ‘E’) or (input == ‘D’ or input == ‘d’)){
wrong = false;/// here to make sure if the program dedicated  the right keys
}
else {
cout<<“Please choose ‘E’ for encode OR ‘D for decode’”<<endl;

prentwrong
cin>>input;
cin.ignore();
}
}

while ( (input == ‘E’ or input == ‘e’) && (wrong == false)){
wrong = false;
cout<<“Enter the message you want to encoded here :” <<endl;
getline(cin,message);// get the message
cout << “Enter key”<<endl;
getline (cin,key);
cin.ignore();
for ( unsigned int b = 0 ; b <= message.size(); b++){
if (key.size()!= message.size()){
key += key[b]; // if the key is less then the message size then repeat that this will make sure that the key size is the same size as the message
}
}
for (unsigned int j= 0, h = 0 ; j < message.size(); j++,h++){ // loop through the message and get the number that represents each letter
nkey = key[h];
nkey = message[j] + key[h];
if (message[j] == ‘ ‘ ){
key[h–];
continue;
}
while (nkey > 126 ) {
nkey = nkey – 93;// to make sure that the numbers will stay in printable characters we do 126 -33
}
convert += static_cast<char>(nkey);

}
cout<<“The Encoded Message is – > “<<convert<<endl;
input++;
}

// so here if we enter the message “hello” to be encoded and use the keys “abc” it will result in

encodedhello

 

So hello rotated with the key abc will be ljrpt

while ((input == ‘d’ or input == ‘D’) && (wrong == false)){
wrong = false;
string dmessage;
string dkey;
int dnkey;
string dconvert;
cout<<“Enter decoded message here :” <<endl;
getline(cin,dmessage);
cin.ignore();
cout << “Enter key”<<endl;
getline (cin,dkey);
cin.ignore();
for ( unsigned int m = 0 ; m <= dmessage.size(); m++){
if (dkey.size()!= dmessage.size()){
dkey += dkey[m];
}
}
for (unsigned int o = 0, n= 0 ; o < dkey.size();o++,n++){
dnkey = dkey[n];
if (dmessage[o] == ‘ ‘){
dkey[n–];
continue;
}
dnkey = dmessage[o] – dkey[n];
while (dnkey < 33){
dnkey = dnkey + 93;
}
dconvert += static_cast<char>(dnkey);

}
cout<<“decoded text out of loop is – > “<<dconvert<<endl;
input++;

}

and then here is the decoded “hello” using the key “abc” we will be back

decodehelloman
return 0;

}

I was searching on the internet to answer the question “why and how Xbox can be used to spy on you” and I what I found was really impressive and very bad. One thing that Microsoft made on the Xbox is the camera that is being active even when your console is off and can listen to your commands and even can read your heart beats with the right software Sean Hollister  stated. Sean Hollister  also stated that “Microsoft says it doesn’t plan to abuse that power, and claims it couldn’t even if it tried. The company told us that the Kinect’s cameras and microphones aren’t actually recording or transmitting any audio or video data back to Microsoft’s servers without the user’s explicit consent, and all ambiently collected data is anonymized. While some voice commands are processed at Microsoft’s servers, they’re converted to text before they ever leave the machine, and biometric data is translated into numerical values that simply indicate, say, where a player’s limbs are during online multiplayer games. While Microsoft says the Kinect is an “integral part” of the new Xbox, it also claims that sensing”(Could the NSA use Microsoft’s Xbox One to spy on you?)

Why would a company like Microsoft spy on people?

Although Microsoft stated that they are not going to spy on people, but Sean brought an example of Skype giving access to private Skype video and audio calls, years before, Skype assured that it is impossible to do such a request like “giving access to private Skype video and audio calls, and now…?

Would Microsoft help the government to spy on people?

Here would be the answer

Xbox One by Moo Jay

 

 

One fact makes the social media strong when it comes to the topic of politics, is how it changed Arabs from being with to against their government. This does not makes me agree with what Arabs doing today in their countries, in fact I disagree with all of it for the fact that what they did is wrong, actually it was wrong from the start, because it just produced more anger and hate. The issue that the Arabs facing is the impact of Social Media in which they see for example videos or words that produces anger without knowing why they are even doing this. For instance if we delve more into this topic you will find out that Arabs always throws their own issues to Americans meaning that “America is the problem with everything” so this makes it even worse, if someone fail his course then yeah it is “Americans”

How this have even took place at first? and how this idea of “Americans” came to Arabs? One answer is reading off the internet and not knowing what is the source’s point meaning that “bad people” or “bad Arabs” have used this social media to brainwash Arabs and make Americans the main issue of everything. Also to be more fair I am not leaving the other side, as an Arab I have faced a lot of bad Americans who treated me as “The bad Muslim” and I do not mind it is totally okay for me, in fact it made me more open and try fix their thoughts about “me” not anyone else. Social Media is not something we should ignore, but something we should pay attention to more so that bad people do not use it to drive our “good guys” from the right roads, to the bad, and turn them to “bad guys” and the examples can be seen everywhere.

Now let us turn back to what I have said at first, when I stated that “bad people” used the social media to do bad things and brainwash the good guys, here I mean the bad guys who came from the government itself this is what destroyed the Arab dream and turned “Arabs spring” to “Arabs hill”.

This is my opinion and my opinion does not mean I am with either side, I am just arguing questions have been asked through the last 4 years, this is not meant to be disrespectful, instead it is for education.

When I first watched the video that the group presented I thought that it was so bad that people were running away and leaving the guy alone and not even try to save him. The fact that people were leaving him and not helping him is so bad to us, and I agree, but what about if we take the other side of it, and answer the question why people tried to avoid involving to help that guy? Well the answer could be many, and one can be “I do not want to get into trouble!” this means that “LEAVE ME ALONE” which means “I only care about myself” this is a hard fact to except but nowadays, we can not trust people and if you look deep into it, you will find that avoiding it would be better for you I will include more than one situation

1- what about if the guy is holding a gun or knife or anything that might hurt you?

2- what about if they were friends joking?

3 – what about if actually they were doing it so that they get you into trouble?

This can be different from country to country , and I thought that it would’ve been more interesting to know what other countries have.

Now we all agree that the internet is full of good things and bad things, and based on what the person’s (user’s) interest that good or bad things comes. But based on last class discussion, I had a lot of points to point out that, even though based on your interest (searching habits) you can find the good or bad things, but in fact, there are words that the users could search and find a lot of the worst things he could ever find, taking example here, if I am taking religion course, and wanted to search “Isalm” or “Christianity” or any other religion, I will sure find the worst pictures and topics that I will never want to read or see. This issue can not be fixed and will not be fixed even if it is as simple, uploading the  picture or writing about that topic. This issue is based on education, today’s internet  has greatly changed from the one years and years ago, now we have so many users, and that opened a way for ignorant to separate their ignorance on the internet, and you can not tell them to not use the internet because of their ignorance, but you can educate them. Now the greatest impact of the internet that changed the way how I think about people of internet, is by doing the bad search habit, where I can find the things that I do not want to see, and just learn how to next time skip falling in the same mistake that those who fell. It was when I searched “Islam” in English, and I saw the worst pictures I’ve seen in my life. Now the internet is different from country to country for one reason, is that if you search in English for something good you can find the good, but if you search in Arabic, you will sure find few good things and the rest bad things that could lead to depression that will lead the user at the end to search what is the easiest way to suicide.

This post represent only my opinion.

The internet is a world where we can meet people from all over the world, people from china can talk with the people from The US. Which is really a nice thing about the internet. Years ago before coming to the United states to finish my bachelor degree, My thoughts about the US was all that its full of those danger  people like the movies, and therefore I never thought of completing my bachelor there, but after I started playing video games over the internet, I  have met some awesome and great people who I will never meet in my home country and this has changed whole my life and made me fight to get to the US to complete my degree.

Lawrence Lessig: Laws that choke creativity

I really like the TED talk by Lawrence Lessig, the points he made about how the information is separated in the internet. This generation is the generation of creators, and I totally agree with Lessig, that years ago, people were watching TV, but this generation people make TVs. And considering accessing information online is violation is something bad, because if we can not read off internet we will then not read anything. But I still think that the way how internet is so wide and open, it gives a very wide space for people to use information in bad ways. The good side about it, is the freedom that the internet has, people can say their opinions about their government using the internet.But it should not be considered as literature for this generation, because this is a part where it passes morals sometimes, which is a very important part of our culture.