از پارسکدرز بیشترین بهره را ببرید و رویای کاری خود را زندگی کنید.
دو سال پیش منتشر شده
تعداد بازدید: 301
کد پروژه: 353658
شرح پروژه
سلام
فیلم کل پروژه رو پیوست کردم
Announcements
#TODO: Self guidance and directed study - Nov. 1, 2022
Posted by Alex Chen
Hey all,
I won't be here today. Here is a concept called scope I want you to know and I found a great interactive and visualized resource from U Waterloo.
https://cscircles.cemc.uwaterloo.ca/11b-how-functions-work/
Please study through it as it will be the expansion knowledge on pass by value/reference we learned so far and if you have any question, you could ask me when I am here. This will be part of evaluation.
We will continue Sets on Wed, Dictionaries on Thurs.
Mr. Chen
#TODO: 2D list and exercises
Posted by Alex Chen
Creating a Tic-Tac-Toe Game
At this point, we’ve covered most of the basic syntax of Python!
Let’s apply what we’ve learned so far to a Tic-Tac-Toe game. The first step in creating any sort of application (including games) is to spend time thinking about design. You’ll recall from our study of the Waterfall SDLC that every minute spent designing software will save many more minutes in actual coding/debugging time.
Data Design
First, let’s think about how we will represent the Tic-Tac-Toe board data in our program. We could use 9 variables, one for each square to keep track of whether it contains an “X”, “O” or is empty, but by now you should appreciate that this is probably not the most efficient approach. If you think about it, we’re going to have several functions in this program and need to pass the Tic-Tac-Toe board data to these functions. Passing nine arguments every time will be cumbersome!
Because the nine squares of a Tic-Tac-Toe board are related, it makes more sense to use a list to keep this data grouped together. From what we know so far, you could define the board data like this:
1
ttt_board = [ " ", " ", " ", " ", " ", " ", " ", " ", " " ]
Here we have a list containing 9 blank spaces since each square will initially not contain any X’s or O’s. This approach will work, but it’s a little awkward because the Tic-Tac-Toe game board has two dimensions (3 rows and 3 columns). So, for example, to make the middle square an “X” we would need to refer to it like so:
1
ttt_board[4] = "X"
This means that to make this work we’ll need to be able to translate a user move consisting of a row and column into a single index value for our list. Hhmm.. sounds tricky… there must be a more elegant solution.
There is! Recall earlier I said that a list in Python may contain any kind of data? Well, it turns out that a list can actually contain other lists! A list inside a list is called a nested list.
Here’s what we’ll do: We’ll define a list that contains three nested lists. Each nested list will represent one of the rows in our Tic-Tac-Toe board:
1
ttt_board = [ [ " ", " ", " " ], [ " ", " ", " " ], [ " ", " ", " " ] ]
The beauty of nested lists is that we can refer to a specific element of a nested list by providing two indices. The first index refers to which nested list we want (starting from 0, as usual), and the second index refers to the element within that nested list (again starting from 0). For example, to put an “X” in the middle square we can now do it like this:
1
ttt_board[1][1] = "X"
The first index is the row, and the second is the column. This data representation is much more natural than using a flat list with nine elements and one index.
Functional Design
Now that we know how we’ll represent the Tic-Tac-Toe board data, let’s think about the functional design. I explained the process of top-down design:
The overall task that the program must perform is broken down into a series of subtasks.
Each of the subtasks is examined to determine whether it can be further broken down into more subtasks. This step is repeated until no more subtasks can be identified.
Once all of the subtasks have been identified, they are written in code.
If we start at step 1, with paper and pencil in hand we can write some pseudocode that explains how the overall game will work:
Above is an overall description of how the game
همه صفحات پروژه رو پیوست کردم
یه کدی باید نوشته بشه که بازی x , o باشه
باید بره تو ریپل لاگین کنه:
https://www.google.com/search?q=replit&client=ms-android-samsung-rev2&source=android-home&source=hp&ei=waJiY_P5NuTA9APcrqLIDg&gs_ssp=eJzj4tVP1zc0TMsyL7LMyipQYDRgdGDwYitKLcjJLAEAaCEHpw&oq=replit&gs_lp=EhFtb2JpbGUtZ3dzLXdpei1ocLgBAfgBASoCCAAyCxAuGIAEGMcBGNEDMggQABiABBixAzILEAAYgAQYsQMYgwEyCxAuGIAEGMcBGK8BMgUQABiABDILEAAYgAQYsQMYgwEyCxAAGIAEGLEDGIMBMgUQABiABMICCxApGLEDGIMBGJECwgIIECkYgAQYsQPCAg0QKRiABBixAxiDARgKwgIOECkYgAQYsQMYxwEYowLCAgIQKcICBxApGIAEGAPCAgsQKRiABBixAxiDAcICBBApGA3CAgUQKRiABMICBxApGLEDGArCAhEQABiPARiPARjqAhiMAxjlAsICCxAuGIAEGLEDGIMBwgIREC4YgAQYsQMYgwEYxwEY0QPCAggQABixAxiDAcICDhAuGIAEGMcBGK8BGNQCwgIUEC4YgAQYsQMYgwEYxwEY0QMY1ALCAg4QLhixAxiDARjHARivAagCHkiuH1DaB1jFGHAAeADIAQCQAQCYAbEDoAGIDaoBCTAuNC4xLjEuMQ&sclient=mobile-gws-wiz-hp
نام کاربری و رمز عبور رو بزنه(تو عکس ارسال شده)
تا فردا صبح فقط وقت دارم
4365*
این پروژه شامل 2 فایل مهم است، لطفا قبل از ارسال پیشنهاد حتما نسبت به بررسی این فایل اقدام فرمایید.
مهارت ها و تخصص های مورد نیاز
مهلت برای انجام
1روز
وضعیت مناقصه
بسته
درباره کارفرما
عضویت دوازده سال پیش
نیاز به استخدام فریلنسر یا سفارش پروژه مشابه دارید؟
قادر به انجام این پروژه هستید؟
متأسفانه مهلت ارسال پیشنهاد این پروژه به پایان رسیده و پروژه بسته شده است؛ اما فرصتهای متعددی در سایت موجود میباشد.
به رایگان یک حساب کاربری بسازید
مهارتها و تخصصهای خود را ثبت کنید، رزومه و نمونهکارهای خود را نشان دهید و سوابق کاری خود را شرح دهید.
به شیوهای که دوست دارید کار کنید
برای پروژههای دلخواه در زمان دلخواه پیشنهاد قیمت خود را ثبت کنید و به فرصتهای شغلی منحصر به فرد دسترسی پیدا کنید.
با اطمینان دستمزد دریافت کنید
از زمان شروع کار تا انتهای کار به امنیت مالی شما کمک خواهیم کرد. وجه پروژه را از ابتدای کار به امانت در سایت نگه خواهیم داشت تا تضمین شودکه بعد از تحویل کار دستمزد شما پرداخت خواهد شد.
میخواهید شروع به کار کنید؟
یک حساب کاربری بسازید
بهترین مشاغل فریلنسری را پیدا کنید
رشد شغلی شما به راحتی ایجاد یک حساب کاربری رایگان و یافتن کار (پروژه) متناسب با مهارتهای شما
است.
پیدا کردن کار (پروژه)
تماشای دمو روش کار